registration
This commit is contained in:
41
frontend/style/node_modules/date-fns/formatISO.js
generated
vendored
41
frontend/style/node_modules/date-fns/formatISO.js
generated
vendored
@@ -1,8 +1,5 @@
|
||||
"use strict";
|
||||
exports.formatISO = formatISO;
|
||||
var _index = require("./toDate.js");
|
||||
|
||||
var _index2 = require("./_lib/addLeadingZeros.js");
|
||||
import { addLeadingZeros } from "./_lib/addLeadingZeros.js";
|
||||
import { toDate } from "./toDate.js";
|
||||
|
||||
/**
|
||||
* The {@link formatISO} function options.
|
||||
@@ -16,12 +13,10 @@ var _index2 = require("./_lib/addLeadingZeros.js");
|
||||
* @description
|
||||
* Return the formatted date string in ISO 8601 format. Options may be passed to control the parts and notations of the date.
|
||||
*
|
||||
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
||||
*
|
||||
* @param date - The original date
|
||||
* @param options - An object with options.
|
||||
*
|
||||
* @returns The formatted date string (in loca.l time zone)
|
||||
* @returns The formatted date string (in local time zone)
|
||||
*
|
||||
* @throws `date` must not be Invalid Date
|
||||
*
|
||||
@@ -45,10 +40,10 @@ var _index2 = require("./_lib/addLeadingZeros.js");
|
||||
* const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' })
|
||||
* //=> '19:00:52Z'
|
||||
*/
|
||||
function formatISO(date, options) {
|
||||
const _date = (0, _index.toDate)(date);
|
||||
export function formatISO(date, options) {
|
||||
const date_ = toDate(date, options?.in);
|
||||
|
||||
if (isNaN(_date.getTime())) {
|
||||
if (isNaN(+date_)) {
|
||||
throw new RangeError("Invalid time value");
|
||||
}
|
||||
|
||||
@@ -63,9 +58,9 @@ function formatISO(date, options) {
|
||||
|
||||
// Representation is either 'date' or 'complete'
|
||||
if (representation !== "time") {
|
||||
const day = (0, _index2.addLeadingZeros)(_date.getDate(), 2);
|
||||
const month = (0, _index2.addLeadingZeros)(_date.getMonth() + 1, 2);
|
||||
const year = (0, _index2.addLeadingZeros)(_date.getFullYear(), 4);
|
||||
const day = addLeadingZeros(date_.getDate(), 2);
|
||||
const month = addLeadingZeros(date_.getMonth() + 1, 2);
|
||||
const year = addLeadingZeros(date_.getFullYear(), 4);
|
||||
|
||||
// yyyyMMdd or yyyy-MM-dd.
|
||||
result = `${year}${dateDelimiter}${month}${dateDelimiter}${day}`;
|
||||
@@ -74,15 +69,12 @@ function formatISO(date, options) {
|
||||
// Representation is either 'time' or 'complete'
|
||||
if (representation !== "date") {
|
||||
// Add the timezone.
|
||||
const offset = _date.getTimezoneOffset();
|
||||
const offset = date_.getTimezoneOffset();
|
||||
|
||||
if (offset !== 0) {
|
||||
const absoluteOffset = Math.abs(offset);
|
||||
const hourOffset = (0, _index2.addLeadingZeros)(
|
||||
Math.trunc(absoluteOffset / 60),
|
||||
2,
|
||||
);
|
||||
const minuteOffset = (0, _index2.addLeadingZeros)(absoluteOffset % 60, 2);
|
||||
const hourOffset = addLeadingZeros(Math.trunc(absoluteOffset / 60), 2);
|
||||
const minuteOffset = addLeadingZeros(absoluteOffset % 60, 2);
|
||||
// If less than 0, the sign is +, because it is ahead of time.
|
||||
const sign = offset < 0 ? "+" : "-";
|
||||
|
||||
@@ -91,9 +83,9 @@ function formatISO(date, options) {
|
||||
tzOffset = "Z";
|
||||
}
|
||||
|
||||
const hour = (0, _index2.addLeadingZeros)(_date.getHours(), 2);
|
||||
const minute = (0, _index2.addLeadingZeros)(_date.getMinutes(), 2);
|
||||
const second = (0, _index2.addLeadingZeros)(_date.getSeconds(), 2);
|
||||
const hour = addLeadingZeros(date_.getHours(), 2);
|
||||
const minute = addLeadingZeros(date_.getMinutes(), 2);
|
||||
const second = addLeadingZeros(date_.getSeconds(), 2);
|
||||
|
||||
// If there's also date, separate it with time with 'T'
|
||||
const separator = result === "" ? "" : "T";
|
||||
@@ -107,3 +99,6 @@ function formatISO(date, options) {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Fallback for modularized imports:
|
||||
export default formatISO;
|
||||
|
||||
Reference in New Issue
Block a user