registration

This commit is contained in:
User
2025-02-02 16:08:03 +03:00
parent 7f6495eb4d
commit 78afbaed71
6334 changed files with 196774 additions and 165754 deletions

View File

@@ -1,9 +1,6 @@
"use strict";
exports.formatISO9075 = formatISO9075;
var _index = require("./isValid.js");
var _index2 = require("./toDate.js");
var _index3 = require("./_lib/addLeadingZeros.js");
import { addLeadingZeros } from "./_lib/addLeadingZeros.js";
import { isValid } from "./isValid.js";
import { toDate } from "./toDate.js";
/**
* The {@link formatISO9075} function options.
@@ -17,8 +14,6 @@ var _index3 = require("./_lib/addLeadingZeros.js");
* @description
* Return the formatted date string in ISO 9075 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.
*
@@ -46,10 +41,10 @@ var _index3 = require("./_lib/addLeadingZeros.js");
* const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' })
* //=> '19:00:52'
*/
function formatISO9075(date, options) {
const _date = (0, _index2.toDate)(date);
export function formatISO9075(date, options) {
const date_ = toDate(date, options?.in);
if (!(0, _index.isValid)(_date)) {
if (!isValid(date_)) {
throw new RangeError("Invalid time value");
}
@@ -63,9 +58,9 @@ function formatISO9075(date, options) {
// Representation is either 'date' or 'complete'
if (representation !== "time") {
const day = (0, _index3.addLeadingZeros)(_date.getDate(), 2);
const month = (0, _index3.addLeadingZeros)(_date.getMonth() + 1, 2);
const year = (0, _index3.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}`;
@@ -73,9 +68,9 @@ function formatISO9075(date, options) {
// Representation is either 'time' or 'complete'
if (representation !== "date") {
const hour = (0, _index3.addLeadingZeros)(_date.getHours(), 2);
const minute = (0, _index3.addLeadingZeros)(_date.getMinutes(), 2);
const second = (0, _index3.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 a space
const separator = result === "" ? "" : " ";
@@ -86,3 +81,6 @@ function formatISO9075(date, options) {
return result;
}
// Fallback for modularized imports:
export default formatISO9075;