UNPKG

@storm-stack/date-time

Version:

This package includes a DateTime class, various utility functions for working with dates and times, and a number of formatting options.

22 lines (21 loc) 769 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.formatDateTimeISO = void 0; var _types = require("@storm-stack/types"); const formatDateTimeISO = (dateTime, options) => { const smallestUnit = options?.smallestUnit || "millisecond"; const roundingMode = options?.roundingMode || "ceil"; const calendarName = options?.calendarName || "never"; const timeZoneName = options?.timeZoneName || "never"; const offset = options?.offset || "never"; return dateTime ? `${dateTime.instant.toZonedDateTimeISO(dateTime.timeZoneId ?? process.env.TZ ?? "UTC").toString({ smallestUnit, roundingMode, calendarName, timeZoneName, offset })}` : _types.EMPTY_STRING; }; exports.formatDateTimeISO = formatDateTimeISO;