datetime-lube 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../src/diff.js"],"names":[],"mappings":"AAkDA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,WAAU,IAAI,EAhBjB,IAgBiB,EAAE,EAAE,EAfrB,IAeqB,EAAE,IAAI,EAd3B,OAAO,cAAc,EAAE,IAcI,EAAE,IAAI,AAVzC,CACA,EADQ,OAAO,cAAc,EAAE,QAAQ,YAUE,GAT/B,MAAM,CAiFlB"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Returns a new Date at the last millisecond of the given unit, such as 23:59:59.999 of the day.
3
+ * A week ends on Sunday, as in ISO 8601.
4
+ * @param {Date} date
5
+ * @param {Exclude<import("../public.js").Unit, "sss">} unit
6
+ * ```
7
+ * "Y" | "M" | "W" | "D" | "H" | "m" | "s"
8
+ * ```
9
+ * @param {import("../public.js").TimeZone=} zone
10
+ * @returns {Date}
11
+ * @throws
12
+ * ```
13
+ * RangeError(`endOf: Invalid unit "${unit}"`) // The unit is not one of the listed ones
14
+ * RangeError(`endOf: Invalid time zone "${zone}"`) // Intl.DateTimeFormat rejects the zone
15
+ * TypeError(`endOf: Expected a Date, got ${typeof date}`)
16
+ * ```
17
+ * @example endOf(new Date, "M") //=> Date { last millisecond of this month }
18
+ */
19
+ export default function (date: Date, unit: Exclude<import("../public.js").Unit, "sss">, zone?: import("../public.js").TimeZone | undefined): Date;
20
+ //# sourceMappingURL=end_of.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"end_of.d.ts","sourceRoot":"","sources":["../src/end_of.js"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,OAAO,WAAU,IAAI,EAfjB,IAeiB,EAAE,IAAI,EAdvB,OAAO,CAAC,OAAO,cAAc,EAAE,IAAI,EAAE,KAAK,CAcnB,EAAE,IAAI,AAVrC,CACA,EADQ,OAAO,cAAc,EAAE,QAAQ,YAUF,GAT3B,IAAI,CAsFhB"}
@@ -0,0 +1,10 @@
1
+ export { default as add } from "./add.js";
2
+ export { default as dateToString } from "./date_to_string.js";
3
+ export { default as diff } from "./diff.js";
4
+ export { default as endOf } from "./end_of.js";
5
+ export { default as startOf } from "./start_of.js";
6
+ export { default as stringToDate } from "./string_to_date.js";
7
+ export { default as timeUnit } from "./time_unit.js";
8
+ export { default as timeZoneOffset } from "./time_zone_offset.js";
9
+ export * from "../public.js"
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,uBAAuB,CAAA"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Returns a new Date at the start of the given unit, such as midnight of the same day.
3
+ * A week starts on Monday, as in ISO 8601.
4
+ * @param {Date} date
5
+ * @param {Exclude<import("../public.js").Unit, "sss">} unit
6
+ * ```
7
+ * "Y" | "M" | "W" | "D" | "H" | "m" | "s"
8
+ * ```
9
+ * @param {import("../public.js").TimeZone=} zone
10
+ * @returns {Date}
11
+ * @throws
12
+ * ```
13
+ * RangeError(`startOf: Invalid unit "${unit}"`) // The unit is not one of the listed ones
14
+ * RangeError(`startOf: Invalid time zone "${zone}"`) // Intl.DateTimeFormat rejects the zone
15
+ * TypeError(`startOf: Expected a Date, got ${typeof date}`)
16
+ * ```
17
+ * @example startOf(new Date, "D", "Asia/Seoul") //=> Date { midnight in Seoul }
18
+ */
19
+ export default function (date: Date, unit: Exclude<import("../public.js").Unit, "sss">, zone?: import("../public.js").TimeZone | undefined): Date;
20
+ //# sourceMappingURL=start_of.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start_of.d.ts","sourceRoot":"","sources":["../src/start_of.js"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,OAAO,WAAU,IAAI,EAfjB,IAeiB,EAAE,IAAI,EAdvB,OAAO,CAAC,OAAO,cAAc,EAAE,IAAI,EAAE,KAAK,CAcnB,EAAE,IAAI,AAVrC,CACA,EADQ,OAAO,cAAc,EAAE,QAAQ,YAUF,GAT3B,IAAI,CAqFhB"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Converts a date string to a Date object based on the provided format.
3
+ * Without a format the platform parser reads the string, so an offset such as `"Z"` is applied,
4
+ * while a date without a time is read as midnight. Out-of-range values give an invalid Date only in an
5
+ * ECMAScript date string: V8 rolls `"2025/02/30"` over to March 2, so check user input with a format.
6
+ * With a format, letters that are not a time unit only reserve their place, and a unit reads up to its own length of digits (`"sss"` reads them as a fraction, so `".5"` is 500 ms).
7
+ * `"YYYY"` also reads an expanded year such as `"+012345"`, and text left after the format gives an invalid Date.
8
+ * Missing units default to 0000-01-01T00:00:00.000, where a time zone is at its local mean time, so
9
+ * read a time alone in `"UTC"`. An invalid value returns an invalid Date.
10
+ * A wall clock inside a daylight saving gap moves forward, and one that occurs twice takes the
11
+ * first occurrence, as `new Date(year, month, day, hour)` does.
12
+ * @param {string} date
13
+ * @param {string=} format
14
+ * ```js
15
+ * e.g. "YYYY-MM-DDTHH:mm:ss.sss"
16
+ * ```
17
+ *
18
+ * Supported time units:
19
+ * - "YYYY": Years
20
+ * - "MM": Months
21
+ * - "DD": Days
22
+ * - "HH": Hours
23
+ * - "mm": Minutes
24
+ * - "ss": Seconds
25
+ * - "sss": Milliseconds
26
+ * @param {import("../public.js").TimeZone=} zone
27
+ * @returns {Date}
28
+ * @throws
29
+ * ```
30
+ * RangeError(`stringToDate: Invalid time zone "${zone}"`) // Intl.DateTimeFormat rejects the zone
31
+ * TypeError(`stringToDate: Expected a string, got ${typeof date}`)
32
+ * ```
33
+ * @example stringToDate("2024-07-15 09:00", "YYYY-MM-DD HH:mm", "Asia/Seoul")
34
+ */
35
+ export default function (date: string, format?: string | undefined, zone?: import("../public.js").TimeZone | undefined): Date;
36
+ //# sourceMappingURL=string_to_date.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string_to_date.d.ts","sourceRoot":"","sources":["../src/string_to_date.js"],"names":[],"mappings":"AAuDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,CAAC,OAAO,WAAU,IAAI,EAvBjB,MAuBiB,EAAE,MAAM,AAtBjC,CAaA,EAbQ,MAAM,YAsBmB,EAAE,IAAI,AATvC,CACA,EADQ,OAAO,cAAc,EAAE,QAAQ,YASA,GAR7B,IAAI,CAgGhB"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @param {string} name
3
+ * @param {Date} date
4
+ * @returns {number}
5
+ */
6
+ export default function (name: string, date: Date): number;
7
+ //# sourceMappingURL=time_of.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time_of.d.ts","sourceRoot":"","sources":["../src/time_of.js"],"names":[],"mappings":"AACA;;;;GAIG;AACH,MAAM,CAAC,OAAO,WAAU,IAAI,EAJjB,MAIiB,EAAE,IAAI,EAHvB,IAGuB,GAFrB,MAAM,CAUlB"}
@@ -0,0 +1,8 @@
1
+ declare const _default: {
2
+ readonly DD: 86400000;
3
+ readonly HH: 3600000;
4
+ readonly mm: 60000;
5
+ readonly ss: 1000;
6
+ };
7
+ export default _default;
8
+ //# sourceMappingURL=time_unit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time_unit.d.ts","sourceRoot":"","sources":["../src/time_unit.js"],"names":[],"mappings":";aACC,EAAE,EAAE,QAAQ;aACZ,EAAE,EAAE,OAAO;aACX,EAAE,EAAE,KAAK;aACT,EAAE,EAAE,IAAI"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Returns the offset of the time zone at the given date in milliseconds, east of UTC positive.
3
+ * Daylight saving time is taken from the given date, so a summer date gives the summer offset.
4
+ * @param {Date} date
5
+ * @param {import("../public.js").TimeZone} zone
6
+ * @returns {number}
7
+ * @throws
8
+ * ```
9
+ * RangeError(`timeZoneOffset: Invalid time zone "${zone}"`) // Intl.DateTimeFormat rejects the zone
10
+ * TypeError(`timeZoneOffset: Expected a Date, got ${typeof date}`)
11
+ * ```
12
+ * @example timeZoneOffset(new Date, "Asia/Seoul") //=> 32400000
13
+ */
14
+ export default function (date: Date, zone: import("../public.js").TimeZone): number;
15
+ //# sourceMappingURL=time_zone_offset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time_zone_offset.d.ts","sourceRoot":"","sources":["../src/time_zone_offset.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,WAAU,IAAI,EAVjB,IAUiB,EAAE,IAAI,EATvB,OAAO,cAAc,EAAE,QASA,GARrB,MAAM,CAclB"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @param {string} name
3
+ * @param {string=} zone
4
+ */
5
+ declare function check_zone(name: string, zone?: string | undefined): void;
6
+ /**
7
+ * @param {number[]} fields
8
+ * @param {string=} zone
9
+ * @returns {Date}
10
+ */
11
+ declare function date_of(fields: number[], zone?: string | undefined): Date;
12
+ /**
13
+ * @param {number} wall
14
+ * @param {number} end
15
+ * @param {number} time
16
+ * @param {string=} zone
17
+ * @returns {number}
18
+ */
19
+ declare function end_at(wall: number, end: number, time: number, zone?: string | undefined): number;
20
+ /**
21
+ * @param {Date} date
22
+ * @param {string=} zone
23
+ * @returns {number[]}
24
+ */
25
+ declare function fields_of(date: Date, zone?: string | undefined): number[];
26
+ /**
27
+ * @param {number} wall
28
+ * @param {string} zone
29
+ * @param {boolean=} exact
30
+ * @returns {number}
31
+ */
32
+ declare function instant_of(wall: number, zone: string, exact?: boolean | undefined): number;
33
+ /**
34
+ * @param {number} time
35
+ * @param {string=} zone
36
+ * @returns {number}
37
+ */
38
+ declare function offset_in(time: number, zone?: string | undefined): number;
39
+ /**
40
+ * @param {number} time
41
+ * @param {string} zone
42
+ * @returns {number}
43
+ */
44
+ declare function offset_of(time: number, zone: string): number;
45
+ /**
46
+ * @param {number} from
47
+ * @param {number} to
48
+ * @param {string=} zone
49
+ * @returns {number}
50
+ */
51
+ declare function transition_of(from: number, to: number, zone?: string | undefined): number;
52
+ /**
53
+ * @param {number} time
54
+ * @param {number} ms
55
+ * @param {string=} zone
56
+ * @returns {number}
57
+ */
58
+ declare function unit_end(time: number, ms: number, zone?: string | undefined): number;
59
+ /**
60
+ * @param {number} time
61
+ * @param {number} ms
62
+ * @param {string=} zone
63
+ * @returns {number}
64
+ */
65
+ declare function unit_start(time: number, ms: number, zone?: string | undefined): number;
66
+ export { check_zone, date_of, end_at, fields_of, instant_of, offset_in, offset_of, transition_of, unit_end, unit_start };
67
+ //# sourceMappingURL=zone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zone.d.ts","sourceRoot":"","sources":["../src/zone.js"],"names":[],"mappings":"AAMA;;;GAGG;AACH,iBAAS,UAAU,CAAC,IAAI,EAHb,MAGa,EAAE,IAAI,AAF3B,CACF,EADU,MAAM,YAEa,QAU7B;AACD;;;;GAIG;AACH,iBAAS,OAAO,CAAC,MAAM,EAJZ,MAAM,EAIM,EAAE,IAAI,AAH1B,CACA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