How to use the moment-timezone function in moment-timezone

To help you get started, we’ve selected a few moment-timezone 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 kevinsuh / toki / src / bot / controllers / work_sessions / startWorkSession.js View on Github external
.then((dailyTasks) => {

									// if there is an already open session we will store it
									// and if it is paused

									let now           = moment();
									let endTime       = moment(openWorkSession.endTime);
									let endTimeString = endTime.format("h:mm a");
									let minutes       = Math.round(moment.duration(endTime.diff(now)).asMinutes());
									var minutesString = convertMinutesToHoursString(minutes);

									let dailyTaskTexts = dailyTasks.map((dailyTask) => {
										return dailyTask.dataValues.Task.text;
									});

									let sessionTasks = commaSeparateOutTaskArray(dailyTaskTexts);

									currentSession = {
										minutes,
										minutesString,
										sessionTasks,
										endTimeString,
github LessWrong2 / Lesswrong2 / packages / lesswrong / lib / karmaChanges.js View on Github external
}

      // If you've never opened the menu before, then return the last daily batch, else
      // create batch for all periods that happened since you last opened it
      const startDate = lastOpened ? moment.min(oneWeekPrior, moment(lastOpened)) : oneWeekPrior
      return {
        start: startDate.toDate(),
        end: lastWeeklyReset.toDate(),
      };
    }
    case "realtime":
      if (!lastOpened) {
        // If set to realtime and never opened before (eg, you just changed the
        // setting), default to the last 24 hours.
        return {
          start: moment().subtract(1, 'days').toDate(),
          end: now
        }
      } else {
        return {
          start: lastOpened,
          end: now
        }
      }
  }
}
github getsentry / sentry / src / sentry / static / sentry / app / components / stackedBarChart.jsx View on Github external
timeLabelAsRange(interval, point) {
    const timeMoment = moment(point.x * 1000);
    const nextMoment = timeMoment.clone().add(interval - 1, 'second');
    const format = this.use24Hours() ? 'MMM Do, HH:mm' : 'MMM Do, h:mm a';

    // e.g. Aug 23rd, 12:50 pm
    return (
      <span>
        {timeMoment.format(format)}
        →
        {nextMoment.format(format)}
      </span>
    );
  }
github getsentry / sentry / src / sentry / static / sentry / app / components / stackedBarChart.jsx View on Github external
timeLabelAsHour(point) {
    const timeMoment = moment(point.x * 1000);
    const nextMoment = timeMoment.clone().add(59, 'minute');
    const format = this.use24Hours() ? 'HH:mm' : 'LT';

    return (
      <span>
        {timeMoment.format('LL')}
        <br>
        {timeMoment.format(format)}
        →
        {nextMoment.format(format)}
      </span>
    );
  }
github epam / cloud-pipeline / client / src / components / runs / AllRuns.js View on Github external
getFilterParams () {
    const statuses = this.state.filter.statuses && this.state.filter.statuses.length
      ? this.state.filter.statuses
      : getStatusForServer(this.props.params.status);
    const startDateFrom = this.state.filter.started && this.state.filter.started.length === 1
      ? moment(this.state.filter.started[0]).utc(false).format('YYYY-MM-DD HH:mm:ss.SSS')
      : undefined;
    const endDateTo = this.state.filter.completed && this.state.filter.completed.length === 1
      ? moment(this.state.filter.completed[0]).utc(false).format('YYYY-MM-DD HH:mm:ss.SSS')
      : undefined;
    const parentId = this.state.filter.parentRunIds && this.state.filter.parentRunIds.length === 1
      ? this.state.filter.parentRunIds[0] : undefined;

    return {
      page: this.state.currentPage,
      pageSize,
      statuses: statuses,
      pipelineIds: this.state.filter.pipelineIds,
      dockerImages: this.state.filter.dockerImages,
      owners: (!this.props.allUsers && this.props.status === 'active' && this.props.authenticatedUserInfo.loaded)
        ? [this.props.authenticatedUserInfo.value.userName]
        : this.state.filter.owners,
      startDateFrom,
      endDateTo,
      parentId,
github keen / explorer / lib / js / app / components / explorer / visualization / keen_viz.js View on Github external
results.result.forEach((result, key) => {
         results.result[key].timeframe.start = moment(result.timeframe.start).tz(results.query.timezone).format(dateFormat);
         results.result[key].timeframe.end = moment(result.timeframe.end).tz(results.query.timezone).format(dateFormat);
       });
    }
github artsy / reaction / src / Components / v2 / AuctionCard.tsx View on Github external
export const relativeTime = (timeIn, now) => {
  const time = moment(timeIn, "YYYY-MM-DD")
  const abs = Math.abs
  if (abs(time.diff(now, "days")) >= 1) {
    return `${time.diff(now, "days")}d`
  } else if (abs(time.diff(now, "hours")) >= 1) {
    return `${time.diff(now, "hours")}h`
  } else if (abs(time.diff(now, "minutes")) >= 1) {
    return `${time.diff(now, "minutes")}m`
  }
  return `${time.diff(now, "seconds")}s`
}
github EvaEngine / EvaEngine.js / src / services / now.js View on Github external
getMoment() {
    return this.now ? moment.unix(this.now) : moment();
  }
github universoimpulso / atena / components / achievementsTemporary / achievementsTemporaryUtils.js View on Github external
const wasEarnedToday = earnedDate => {
  return moment(earnedDate).isSame(moment(new Date()), 'day')
}