How to use the dayjs.min function in dayjs

To help you get started, we’ve selected a few dayjs 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 replicatedhq / kots / web / src / components / snapshots / SnapshotDetails.jsx View on Github external
calculateTimeInterval = (data) => {
    const startedTimes = data.map((d) => dayjs(d.startedAt));
    const finishedTimes = data.map((d) => dayjs(d.finishedAt));
    const minStarted = startedTimes?.length ? dayjs.min(startedTimes) : "";
    const maxFinished = finishedTimes?.length ? dayjs.max(finishedTimes) : "";

    const duration = dayjs.duration(maxFinished.diff(minStarted));
    const diffHours = parseInt(duration.asHours());
    const diffMinutes = parseInt(duration.asMinutes()) % 60;
    const diffDays = parseInt(duration.asDays());

    const timeObj = {
      "minStarted": minStarted.format("MM/DD/YY @ hh:mm a z"),
      "maxFinished": maxFinished.format("MM/DD/YY @ hh:mm a z"),
      "maxHourDifference": diffHours,
      "maxMinDifference": diffMinutes,
      "maxDaysDifference": diffDays
    };

    return timeObj

dayjs

2KB immutable date time library alternative to Moment.js with the same modern API

MIT
Latest version published 2 months ago

Package Health Score

88 / 100
Full package analysis