How to use the moment.now 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 SayMoreX / saymore-x / app / model / file / File.ts View on Github external
// this is used to pacify SM Classic when it requires a date but we don't know it
      //celnoos.log("SKIPPING 0001-01-01");
      return "";
    }

    let date: moment.Moment;

    date = moment(dateString, "YYYY-MM-DD", true /*strict*/);
    if (!date.isValid()) {
      //console.error(`Could not parse ${dateString} strictly.`);
      date = moment(dateString, moment.ISO_8601); // e.g. "2010-01-01T05:06:07"
      if (!date.isValid()) {
        this.setTextProperty(
          "notes",
          `Parsing Error: SayMore could not parse "${dateString}" unambiguously, so it will be set to empty. Encountered on ${moment(
            moment.now()
          ).toString()}`
        );
        return ""; // Our GUI controls need an unambiguous date, so it's safer to just clear the date and leave it for the human to fix it using the error we put in the notes
      }
    }
    const ISO_YEAR_MONTH_DATE_DASHES_FORMAT = "YYYY-MM-DD";
    // if there is time info, throw that away.
    const standardizedDate = date.format(ISO_YEAR_MONTH_DATE_DASHES_FORMAT);
    return standardizedDate;
  }
  protected addDateProperty(key: string, date: Date, persist: boolean = true) {
github terrestris / react-geo / src / Panel / TimeLayerSliderPanel / TimeLayerSliderPanel.tsx View on Github external
private _TimeLayerAwareSlider: any;
  private _wmsTimeLayers: any[];
  private _interval: number;

  /**
   * The default props of LayerSetBaseMapChooser
   *
   * @static
   * @type {DefaultLayerSetBaseMapChooserProps}
   * @memberof LayerSetBaseMapChooser
   */
  public static defaultProps: DefaultTimeLayerSliderPanelProps = {
    className: '',
    onChange: () => {/* empty */},
    timeAwareLayers: [],
    value: moment(moment.now()),
    dateFormat: 'YYYY-MM-DD',
    tooltips: {
      setToNow: 'Set to now',
      hours: 'Hours',
      days: 'Days',
      weeks: 'Weeks',
      months: 'Months',
      years: 'Years',
      dataRange: 'Set data range'
    }
  };

  /**
   * Constructs time panel.
   */
  constructor(props: TimeLayerSliderPanelProps) {
github ArkEcosystem / mobile-wallet / src / app / modals / pin-code / pin-code.ts View on Github external
this.authProvider.getUnlockTimestamp().subscribe((timestamp) => {
      if (!timestamp || lodash.isEmpty(timestamp)) {
        return;
      }

      // If an unlock time is set in storage
      // Check if this time has already been spent
      const now = moment.now();
      const diff = moment(timestamp).diff(now, 'seconds');

      if (diff <= 0) {
        this.authProvider.clearAttempts();
        this.attempts = 0;
        return this.loadUnlockTime();
      }

      this.unlockDiff = diff;

      this.password = '';
      this.message = 'PIN_CODE.WRONG_PIN_MANY_TIMES';

      // Start the countdown
      this.unlockCountdown$ = timer(0, 1000).pipe(
        map(x => this.zone.run(() => this.unlockDiff--)),
github appcypher / events-manager-io / client / src / components / ProfileEventCards.js View on Github external
// If image is not provided, use a placeholder image
      if (!picture1) {
        picture1 = placeholder;
      }

      // Extracting date and time.
      const year = date.slice(0, 4);
      const month = date.slice(5, 7);
      const day = date.slice(8, 10);
      const hour = date.slice(11, 13);
      const min = date.slice(14, 16);
      const date2 = `${day}/${month}/${year}`;
      const time = `${hour}:${min}`;

      // Check if event is out of date.
      const outOfDate = moment(date).isBefore(moment.now()) ? 'io-done' : '';

      // Increment count.
      count += 1;

      // Return a card.
      return (
        <div>
          <div><img alt="" src="{picture1}">
            <div>
              <div>
                <div>
                  <h5>{title}</h5>
                  <span> {}}
                  &gt;</span></div></div></div></div></div>
github cloudfoundry / stratos / src / frontend / app / store / actions / internal-events.actions.ts View on Github external
constructor(
    public eventType: string,
    public eventSubjectId: string,
    public eventState: InternalEventState
  ) {
    eventState.timestamp = moment.now();
    if (!eventState.severity) {
      eventState.severity = InternalEventSeverity.SYSTEM;
    }
  }
}
github olawalejarvis / reflection_app_server / src / usingJSObject / models / Reflection.js View on Github external
create(data) {
    const newReflection = {
      id: uuid.v4(),
      success: data.success || '',
      lowPoint: data.lowPoint || '',
      takeAway: data.takeAway || '',
      createdDate: moment.now(),
      modifiedDate: moment.now()
    };
    this.reflections.push(newReflection);
    return newReflection
  }
  /**
github DFEAGILEDEVOPS / MTC / admin / services / check-window.service.js View on Github external
checkWindows.map(cw => {
      const adminStartDate = moment(cw.adminStartDate)
      const checkStartDate = moment(cw.checkStartDate)
      const checkEndDate = moment(cw.checkEndDate)

      if (checkStartDate.isAfter(checkEndDate)) {
        throw new Error('Check start date is after check end date')
      }

      const isPast = moment(checkEndDate).isBefore(moment.now())
      const isCurrent = moment(checkStartDate).isSameOrBefore(moment.now()) && moment(checkEndDate).isSameOrAfter(moment.now())
      const isFuture = moment(checkStartDate).isAfter(moment.now())

      const checkWindow = {
        id: cw.id,
        name: cw.name,
        adminStartDate: adminStartDate.format('D MMM YYYY'),
        checkDates: dateService.formatCheckPeriod(checkStartDate, checkEndDate),
        isPast
      }

      if (isPast) {
        checkWindow.canRemove = false
        pastCheckWindows.push(checkWindow)
      }
      if (isCurrent) {
        checkWindow.canRemove = false
        newCheckWindows.push(checkWindow)
github arjun27 / rubberduck / src / content_script / utils / api / base / cache.ts View on Github external
private getValidCacheEntries() {
    const { storage } = this.store.getState();
    const cache = storage.apiResponses;
    const now = Moment.now();

    let filteredCache = Object.keys(cache).reduce((res, key) => {
      const keyExpiry = cache[key].expiry;
      const isValid = Moment(keyExpiry).isAfter(now);

      if (isValid) {
        res[key] = cache[key];
      }
      return res;
    }, {});

    return filteredCache;
  }
github lyneca / eidoclock / src / js / clock.js View on Github external
function getTimeUntilDay() {
    return getExpiryTime() - moment.now().valueOf();
}