How to use the moment-timezone.min 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 LessWrong2 / Lesswrong2 / packages / lesswrong / lib / karmaChanges.js View on Github external
if (previousBatchExists && openedBeforeNextBatch) {
        // Since we know that we reopened the notifications before the next batch, the last batch
        // will have ended at the last daily reset time
        const lastBatchEnd = lastWeeklyReset
        // Sanity check in case lastBatchStart is invalid (eg not cleared after a settings change)
        if (lastBatchStart < lastBatchEnd.toDate()) {
          return {
            start: lastBatchStart,
            end: lastBatchEnd.toDate()
          };
        }
      }

      // 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,
github LessWrong2 / Lesswrong2 / packages / lesswrong / lib / karmaChanges.js View on Github external
if (previousBatchExists && openedBeforeNextBatch) {
        // Since we know that we reopened the notifications before the next batch, the last batch
        // will have ended at the last daily reset time
        const lastBatchEnd = lastDailyReset
        // Sanity check in case lastBatchStart is invalid (eg not cleared after a settings change)
        if (lastBatchStart < lastBatchEnd.toDate()) {
          return {
            start: lastBatchStart,
            end: lastBatchEnd.toDate()
          };
        }
      }

      // 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(oneDayPrior, moment(lastOpened)) : oneDayPrior
      return {
        start: startDate.toDate(),
        end: lastDailyReset.toDate(),
      };
    }
    case "weekly": {
      // Target day of the week, as an integer 0-6
      const targetDayOfWeekNum = moment().day(settings.dayOfWeekGMT).day();
      const lastDailyResetDayOfWeekNum = lastDailyReset.day();
      
      // Number of days back from today's daily reset to get to a daily reset
      // of the correct day of the week
      const daysOfWeekDifference = ((lastDailyResetDayOfWeekNum - targetDayOfWeekNum) + 7) % 7;
      
      const lastWeeklyReset = moment(lastDailyReset).subtract(daysOfWeekDifference, 'days');
      const oneWeekPrior = moment(lastWeeklyReset).subtract(7, 'days');
github OpenCTI-Platform / opencti / opencti-front / src / private / components / stix_observable / StixObservableAverages.js View on Github external
render() {
    const {
      t, fld, classes, stixObservable,
    } = this.props;
    const scores = stixObservable.stixRelations.edges.map(n => n.node.score);
    const expirations = stixObservable.stixRelations.edges.map(n => moment(n.node.expiration));
    const weights = stixObservable.stixRelations.edges.map(n => n.node.weight
    );
    const minExpiration = moment.min(expirations);
    return (
      <div style="{{">
        
          {t('Averages of context relations')}
        
        
          
            {t('Confidence level')}
          
          
          
            {t('Score')}</div>
github teamapps-org / teamapps / teamapps-client / ts / modules / util / FullCalendarMonthGrid.ts View on Github external
private eventToSegments(event: EventApi): Segment[] {
		let startMoment = toMoment(event.start, this.calendar);
		let endMoment = event.end != null ? toMoment(event.end, this.calendar) : null;
		if (event.end == null) {
			let start = startMoment.clone().startOf("day").hour(8);
			let end = startMoment.clone().startOf("day").hour(16);
			return [new Segment(moment(start), moment(end), true, true, event)];
		} else if (startMoment.day() === endMoment.day() &amp;&amp; endMoment.valueOf() - startMoment.valueOf() &lt; 86400000 /*day*/) {
			return [new Segment(startMoment, endMoment, true, true, event)];
		} else {
			let segments: Segment[] = [];
			let segStart = startMoment;
			let segEnd = startMoment;
			while (segEnd.valueOf() &lt; endMoment.valueOf()) {
				segStart = segEnd;
				segEnd = moment.min(endMoment, segStart.clone().startOf("day").add(1, "day"));
				segments.push(new Segment(segStart.clone(), segEnd.clone(), +segStart === +event.start, +segEnd === +event.end, event));
			}
			return segments;
		}
	}
github bgerm / scheduler3000 / src / components / Scheduler / AllDay / positionEvents.js View on Github external
     (x) => moment.min(events.getIn([x, 'endDate']), endDate).valueOf()],
    ['asc', 'desc']
github eventespresso / event-espresso-core / assets / src / vo / date-time / datetime.js View on Github external
static min( ...datetimes ) {
		return this.fromMoment(
			moment.min(
				this[ privateMethods.extractMomentsFromDateTimes ](
					...datetimes
				)
			)
		);
	}
github bgerm / scheduler3000 / src / components / Scheduler / AllDay / positionEvents.js View on Github external
const positionedEvent = (eventKey, events, weekStartDate, weekEndDate) =&gt; {
  const evnt = events.get(eventKey);

  const eventStartDate = evnt.get('startDate');
  const eventEndDate = evnt.get('endDate');

  const adjStartDate = moment.max(eventStartDate, weekStartDate);
  const adjEndDate = moment.min(eventEndDate, weekEndDate);

  return {
    id: eventKey,
    span: adjEndDate.diff(adjStartDate, 'days') + 1,
    start: adjStartDate.diff(weekStartDate, 'days') + 1,
    startDate: adjStartDate,
    endDate: adjEndDate,
    moreLeft: eventStartDate &lt; weekStartDate,
    moreRight: eventEndDate &gt; weekEndDate
  };
};