How to use the moment.relativeTimeThreshold function in moment

To help you get started, we’ve selected a few moment examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenBazaar / openbazaar-desktop / js / models / order / Contract.js View on Github external
timeFromNowVerbose(secs) {
    const prevMomentDaysThreshold = moment.relativeTimeThreshold('d');

    // temporarily upping the moment threshold of number of days before month is used,
    // so in the escrow timeouts 45 is represented as '45 days' instead of '1 month'.
    moment.relativeTimeThreshold('d', 364);

    const str = moment(Date.now())
      .from(
        moment(Date.now() + (secs * 60 * 60 * 1000)), true
      );

    // restore the days timeout threshold
    moment.relativeTimeThreshold('d', prevMomentDaysThreshold);

    return str;
  }
github OpenBazaar / openbazaar-desktop / js / models / order / Contract.js View on Github external
timeFromNowVerbose(secs) {
    const prevMomentDaysThreshold = moment.relativeTimeThreshold('d');

    // temporarily upping the moment threshold of number of days before month is used,
    // so in the escrow timeouts 45 is represented as '45 days' instead of '1 month'.
    moment.relativeTimeThreshold('d', 364);

    const str = moment(Date.now())
      .from(
        moment(Date.now() + (secs * 60 * 60 * 1000)), true
      );

    // restore the days timeout threshold
    moment.relativeTimeThreshold('d', prevMomentDaysThreshold);

    return str;
  }
github gnosis / conditional-markets-interface / app / src / utils / timeFormat.js View on Github external
hh: "<%d hours",
    d: "<1 day",
    dd: "<%d days",
    M: "<1 month",
    MM: "<%d months",
    y: "<1 year",
    yy: "<%d years"
  }
});

// Round relative time evaluation down
moment.relativeTimeRounding(Math.ceil);

// Relative time threshold to a fixed value instead of a range
moment.relativeTimeThreshold("s", 60);
moment.relativeTimeThreshold("m", 60);
moment.relativeTimeThreshold("h", 24);
moment.relativeTimeThreshold("d", 31);
moment.relativeTimeThreshold("M", 12);
github OpenBazaar / openbazaar-desktop / js / models / order / Contract.js View on Github external
timeFromNowVerbose(secs) {
    const prevMomentDaysThreshold = moment.relativeTimeThreshold('d');

    // temporarily upping the moment threshold of number of days before month is used,
    // so in the escrow timeouts 45 is represented as '45 days' instead of '1 month'.
    moment.relativeTimeThreshold('d', 364);

    const str = moment(Date.now())
      .from(
        moment(Date.now() + (secs * 60 * 60 * 1000)), true
      );

    // restore the days timeout threshold
    moment.relativeTimeThreshold('d', prevMomentDaysThreshold);

    return str;
  }
github OpenBazaar / openbazaar-desktop / js / views / modals / orderDetail / summaryTab / Summary.js View on Github external
renderTimeoutInfoView() {
    const paymentCurData = this.model.paymentCoinData;
    const orderState = this.model.get('state');
    const prevMomentDaysThreshold = moment.relativeTimeThreshold('d');
    const isCase = this.model.isCase;

    if (!this.shouldShowTimeoutInfoView) {
      if (this.timeoutInfo) this.timeoutInfo.remove();
      this.timeoutInfo = null;
      clearTimeout(this.disputeCountdownTimeout);
      return;
    }

    // temporarily upping the moment threshold of number of days before month is used,
    // so in the escrow timeouts 45 is represented as '45 days' instead of '1 month'.
    moment.relativeTimeThreshold('d', 364);

    let state = {
      ownPeerId: app.profile.id,
      buyer: this.buyer.id,
      vendor: this.vendor.id,
      moderator: this.moderator && this.moderator.id || undefined,
      isFundingConfirmed: false,
      blockTime: paymentCurData && paymentCurData.blockTime,
      isDisputed: orderState === 'DISPUTED',
      hasDisputeEscrowExpired: false,
      canBuyerComplete: this.model.canBuyerComplete,
      isPaymentClaimable: false,
      isPaymentFinalized: false,
      showDisputeBtn: false,
      showDiscussBtn: orderState === 'DISPUTED',
      showResolveDisputeBtn: false,
github ailabstw / pttai.js / src / utils / utilDatetime.js View on Github external
import moment from 'moment'

import { language } from './utils'

moment.relativeTimeRounding(Math.floor)
moment.relativeTimeThreshold('s', 60)
moment.relativeTimeThreshold('m', 60)
moment.relativeTimeThreshold('h', 24)
moment.relativeTimeThreshold('d', 31)
moment.relativeTimeThreshold('M', 12)

if (language === 'zh') {
  moment.defineLocale('zh-tw', {
    months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
    monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
    weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
    weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'),
    weekdaysMin: '日_一_二_三_四_五_六'.split('_'),
    longDateFormat: {
      LT: 'Ah點mm分',
      LTS: 'Ah點m分s秒',
      L: 'YYYY-MM-DD',
      LL: 'YYYY年MMMD日',
      LLL: 'YYYY年MMMD日Ah點mm分',
github GenesisVision / web-client / packages / investor / src / setupMoment.js View on Github external
import moment from "moment";

moment.defaultFormat = "YYYY-MM-DD HH:mm:ss";
moment.relativeTimeThreshold("ss", 3);
moment.relativeTimeThreshold("s", 60);
moment.relativeTimeThreshold("m", 60);
moment.relativeTimeThreshold("h", 24);
moment.relativeTimeThreshold("d", 30);
moment.relativeTimeThreshold("M", 12);
moment.locale("en", {
  relativeTime: {
    s: "%d seconds",
    m: "%d minutes",
    h: "%d hours",
    d: "%d days"
  }
});
github microsoft / 0xDeCA10B / demo / client / src / components / model.js View on Github external
import React from 'react';
import Dropzone from 'react-dropzone';
import ClipLoader from 'react-spinners/ClipLoader';
import GridLoader from 'react-spinners/GridLoader';
import Classifier from "../contracts/Classifier64.json";
import CollaborativeTrainer from '../contracts/CollaborativeTrainer64.json';
import DataHandler from '../contracts/DataHandler64.json';
import IncentiveMechanism from '../contracts/Stakeable64.json';
import ImdbVocab from '../data/imdb.json';
import { getNetworkType, getWeb3 } from '../getWeb3';
import { OnlineSafetyValidator } from '../safety/validator';
import { OriginalData } from '../storage/data-store';
import { DataStoreFactory } from '../storage/data-store-factory';
import { checkStorages, renderStorageSelector } from './storageSelector';

moment.relativeTimeThreshold('ss', 4);

const INPUT_TYPE_IMAGE = 'image';
const INPUT_TYPE_TEXT = 'text';

const styles = theme => ({
  root: {
    ...theme.mixins.gutters(),
    paddingTop: theme.spacing(2),
    paddingBottom: theme.spacing(2),
    marginBottom: theme.spacing(2),
    display: 'flex',
    flexDirection: 'column'
  },
  info: {
    paddingBottom: theme.spacing(1),
  },