How to use the moment.max 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 ecomfe / esui-family / dep / ub-ria-ui / 1.0.0-beta.3 / src / Spinner.js View on Github external
function updateDate(direct) {
            var input = this.getInput();
            var scale = typeof this.scale === 'object' ? this.scale : parseToNum(this.scale);
            var timeFormat = this.format;
            var value = m(input.value, timeFormat);
            var max = this.max;
            var min = this.min;

            // 如果用户手动输入一个非法值,会默认显示最小值
            value = value.isValid() ? value : min;
            if (direct === Direct.UP) {
                value = value.add(scale.value, scale.key);
                if (m.max(value, max) === max) {
                    value = m(value, timeFormat).format(timeFormat);
                }
                else {
                    if (!!this.turn && this.turn !== 'false') {
                        value = m(min, timeFormat).format(timeFormat);
                    }
                    else {
                        value = m(max, timeFormat).format(timeFormat);
                    }
                }
            }
            else {
                value = value.subtract(scale.value, scale.key);
                if (m.min(value, min) === min) {
                    value = m(value, timeFormat).format(timeFormat);
                }
github sentinel-hub / EOBrowser / src / components / FIS / index.js View on Github external
onDataReceived(fromDate, toDate, responseData, lastChannelIsCloudCoverage) {
    // merge newly received data with existing:
    const lastChannelId =
      Object.keys(responseData).length > 1 ? `C${Object.keys(responseData).length - 1}` : null;
    for (let channelId in responseData) {
      // exception: if there are 2 channels then channel 'C1' is really cloud coverage info:
      if (lastChannelIsCloudCoverage && channelId === lastChannelId) {
        this.availableData.cloudCoverageData.push(...responseData[channelId]);
      } else {
        this.availableData.data[channelId] = this.availableData.data[channelId] || [];
        this.availableData.data[channelId].push(...responseData[channelId]);
      }
    }

    this.availableData.fromDate = fromDate;
    this.availableData.toDate = moment.max(toDate, this.availableData.toDate);
    // update state to trigger chart rendering:
    this.updateStateWithData();
  }
github you-dont-need / You-Dont-Need-Momentjs / __tests__ / performance.js View on Github external
performanceTest('Moment', () => {
      moment.max(array.map(a => moment(a)));
    });
  },
github crotwell / seisplotjs / src / seismogram.js View on Github external
findStartEnd() {
    let allStart = this._segmentArray.map(seis => {
      return moment.utc(seis.startTime);
    });
    this._startTime = moment.min(allStart);
    let allEnd = this._segmentArray.map(seis => {
      return moment.utc(seis.endTime);
    });
    this._endTime = moment.max(allEnd);
  }
  findMinMax(minMaxAccumulator?: Array): Array {
github LearningLocker / learninglocker / ui / src / utils / visualisationResults / getFormattedResults.js View on Github external
entries.forEach((entry) => {
        const entryDate = moment(entry.get('_id'));
        minDate = minDate ? moment.min(minDate, entryDate) : entryDate;
        maxDate = maxDate ? moment.max(maxDate, entryDate) : entryDate;
      });
    });
github opf / openproject / frontend / src / app / components / wp-table / timeline / wp-timeline.ts View on Github external
export function getTimeSlicesForHeader(vp:TimelineViewParameters,
  unit:moment.unitOfTime.DurationConstructor,
  startView:Moment,
  endView:Moment) {

  const inViewport:[Moment, Moment][] = [];
  const rest:[Moment, Moment][] = [];

  const time = startView.clone().startOf(unit);
  const end = endView.clone().endOf(unit);

  while (time.isBefore(end)) {
    const sliceStart = moment.max(time, startView).clone();
    const sliceEnd = moment.min(time.clone().endOf(unit), endView).clone();
    time.add(1, unit);

    const viewport = vp.visibleViewportAtCalculationTime;
    if ((sliceStart.isSameOrAfter(viewport[0]) && sliceStart.isSameOrBefore(viewport[1]))
      || (sliceEnd.isSameOrAfter(viewport[0]) && sliceEnd.isSameOrBefore(viewport[1]))) {

      inViewport.push([sliceStart, sliceEnd]);
    } else {
      rest.push([sliceStart, sliceEnd]);
    }
  }

  const firstRest:[Moment, Moment] = rest.splice(0, 1)[0];
  const lastRest:[Moment, Moment] = rest.pop()!;
  const inViewportAndBoundaries = _.concat(
github ecomfe / esui-family / dep / ub-ria-ui / 1.0.0-beta.3 / src / Spinner.js View on Github external
paint: function (spinner, rawValue) {
                            var max = spinner.max;
                            var min = spinner.min;
                            var format = spinner.format;
                            if (spinner.format === 'number') {
                                rawValue = parseToNum(rawValue);
                                rawValue = Math.max(rawValue, min);
                                rawValue = Math.min(rawValue, max);
                            }
                            else {
                                rawValue = m(rawValue, format);
                                if (rawValue.isValid()) {
                                    rawValue = m.max(rawValue, min);
                                    rawValue = m.min(rawValue, max);
                                }
                                else {
                                    rawValue = min;
                                }
                                rawValue = m(rawValue, format).format(format);
                            }
                            setInputValue.call(spinner, rawValue);
                        }
                    },
github CSCfi / exam / app / frontend / src / calendar / calendar.service.ts View on Github external
getExceptionHours(room: Room) {
        const view = this.uiCalendarConfig.calendars.myCalendar.fullCalendar('getView');
        if (view.start === undefined || view.end === undefined) {
            return [];
        }
        const start = moment.max(moment(), view.start);
        const end = view.end;
        const events = room.calendarExceptionEvents.filter(function (e) {
            return (moment(e.startDate) > start && moment(e.endDate) < end);
        });
        return events.map(e => CalendarService.formatExceptionEvent(e, room.localTimezone));
    }
github machawk1 / wail / wail-core / managers / archiveManager.js View on Github external
async _colFromSeedsColDirExists (colPath, col, seeds) {
    const aColStats = await getFsStats(colPath)
    const colCreateTime = moment(aColStats.birthtime)
    let colLastUpdated
    if (seeds.length > 0) {
      colLastUpdated = moment.max(seeds.map(s => moment(s.lastUpdated)))
    } else {
      colLastUpdated = moment().format()
    }
    let colSize = '0 B', ensures = 'index'
    const colWarcP = path.join(colPath, 'archive')
    if (await checkPathExists(colWarcP)) {
      colSize = prettyBytes(await CollectionsUtils.getColSize(colWarcP))
    } else {
      ensures = 'both'
    }
    await CollectionsUtils.ensureColDirs(colPath, ensures)
    let backUpMdata = {description: `Recreated by WAIL after found to be not existing`, title: col}
    let metadata
    try {
      metadata = await getYamlOrWriteIfAbsent(path.join(colPath, 'metadata.yaml'), backUpMdata)
    } catch (getYamlError) {