@bemoje/date 0.0.10 → 0.1.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.
Files changed (142) hide show
  1. package/README.md +6 -34
  2. package/package.json +11 -10
  3. package/{dist/types → src}/index.d.ts +0 -1
  4. package/src/index.js +36 -0
  5. package/src/index.js.map +1 -0
  6. package/{dist/types → src}/lib/assertValidDate.d.ts +0 -1
  7. package/src/lib/assertValidDate.js +36 -0
  8. package/src/lib/assertValidDate.js.map +1 -0
  9. package/{dist/types → src}/lib/assertValidDateDay.d.ts +0 -1
  10. package/src/lib/assertValidDateDay.js +24 -0
  11. package/src/lib/assertValidDateDay.js.map +1 -0
  12. package/{dist/types → src}/lib/assertValidDateMonth.d.ts +0 -1
  13. package/src/lib/assertValidDateMonth.js +21 -0
  14. package/src/lib/assertValidDateMonth.js.map +1 -0
  15. package/{dist/types → src}/lib/assertValidDateYear.d.ts +0 -1
  16. package/src/lib/assertValidDateYear.js +22 -0
  17. package/src/lib/assertValidDateYear.js.map +1 -0
  18. package/{dist/types → src}/lib/constants/MS_IN_DAY.d.ts +0 -1
  19. package/src/lib/constants/MS_IN_DAY.js +8 -0
  20. package/src/lib/constants/MS_IN_DAY.js.map +1 -0
  21. package/{dist/types → src}/lib/constants/MS_IN_HOUR.d.ts +0 -1
  22. package/src/lib/constants/MS_IN_HOUR.js +8 -0
  23. package/src/lib/constants/MS_IN_HOUR.js.map +1 -0
  24. package/{dist/types → src}/lib/constants/MS_IN_MINUTE.d.ts +0 -1
  25. package/src/lib/constants/MS_IN_MINUTE.js +8 -0
  26. package/src/lib/constants/MS_IN_MINUTE.js.map +1 -0
  27. package/{dist/types → src}/lib/constants/MS_IN_MONTH.d.ts +0 -1
  28. package/src/lib/constants/MS_IN_MONTH.js +8 -0
  29. package/src/lib/constants/MS_IN_MONTH.js.map +1 -0
  30. package/{dist/types → src}/lib/constants/MS_IN_SECOND.d.ts +0 -1
  31. package/src/lib/constants/MS_IN_SECOND.js +8 -0
  32. package/src/lib/constants/MS_IN_SECOND.js.map +1 -0
  33. package/{dist/types → src}/lib/constants/MS_IN_WEEK.d.ts +0 -1
  34. package/src/lib/constants/MS_IN_WEEK.js +8 -0
  35. package/src/lib/constants/MS_IN_WEEK.js.map +1 -0
  36. package/{dist/types → src}/lib/constants/MS_IN_YEAR.d.ts +0 -1
  37. package/src/lib/constants/MS_IN_YEAR.js +8 -0
  38. package/src/lib/constants/MS_IN_YEAR.js.map +1 -0
  39. package/{dist/types → src}/lib/dateDaysAgo.d.ts +0 -1
  40. package/src/lib/dateDaysAgo.js +19 -0
  41. package/src/lib/dateDaysAgo.js.map +1 -0
  42. package/{dist/types → src}/lib/dateWeekDayName.d.ts +0 -1
  43. package/src/lib/dateWeekDayName.js +9 -0
  44. package/src/lib/dateWeekDayName.js.map +1 -0
  45. package/{dist/types → src}/lib/daysSinceDate.d.ts +0 -1
  46. package/src/lib/daysSinceDate.js +21 -0
  47. package/src/lib/daysSinceDate.js.map +1 -0
  48. package/{dist/types → src}/lib/getCentury.d.ts +0 -1
  49. package/src/lib/getCentury.js +22 -0
  50. package/src/lib/getCentury.js.map +1 -0
  51. package/{dist/types → src}/lib/getCurrentYear.d.ts +0 -1
  52. package/src/lib/getCurrentYear.js +17 -0
  53. package/src/lib/getCurrentYear.js.map +1 -0
  54. package/{dist/types → src}/lib/hoursSinceDate.d.ts +0 -1
  55. package/src/lib/hoursSinceDate.js +21 -0
  56. package/src/lib/hoursSinceDate.js.map +1 -0
  57. package/{dist/types → src}/lib/isLeapYear.d.ts +0 -1
  58. package/src/lib/isLeapYear.js +24 -0
  59. package/src/lib/isLeapYear.js.map +1 -0
  60. package/{dist/types → src}/lib/isValidDate.d.ts +0 -1
  61. package/src/lib/isValidDate.js +41 -0
  62. package/src/lib/isValidDate.js.map +1 -0
  63. package/{dist/types → src}/lib/isValidDateDay.d.ts +0 -1
  64. package/src/lib/isValidDateDay.js +34 -0
  65. package/src/lib/isValidDateDay.js.map +1 -0
  66. package/{dist/types → src}/lib/isValidDateMonth.d.ts +0 -1
  67. package/src/lib/isValidDateMonth.js +19 -0
  68. package/src/lib/isValidDateMonth.js.map +1 -0
  69. package/{dist/types → src}/lib/isValidDateYear.d.ts +0 -1
  70. package/src/lib/isValidDateYear.js +22 -0
  71. package/src/lib/isValidDateYear.js.map +1 -0
  72. package/{dist/types → src}/lib/isoDateTimestamp.d.ts +0 -1
  73. package/src/lib/isoDateTimestamp.js +22 -0
  74. package/src/lib/isoDateTimestamp.js.map +1 -0
  75. package/{dist/types → src}/lib/isoDateTimestampForFilename.d.ts +0 -1
  76. package/src/lib/isoDateTimestampForFilename.js +21 -0
  77. package/src/lib/isoDateTimestampForFilename.js.map +1 -0
  78. package/{dist/types → src}/lib/minutesSinceDate.d.ts +0 -1
  79. package/src/lib/minutesSinceDate.js +21 -0
  80. package/src/lib/minutesSinceDate.js.map +1 -0
  81. package/{dist/types → src}/lib/monthsSinceDate.d.ts +0 -1
  82. package/src/lib/monthsSinceDate.js +21 -0
  83. package/src/lib/monthsSinceDate.js.map +1 -0
  84. package/{dist/types → src}/lib/msSinceDate.d.ts +0 -1
  85. package/src/lib/msSinceDate.js +24 -0
  86. package/src/lib/msSinceDate.js.map +1 -0
  87. package/{dist/types → src}/lib/numDaysInMonth.d.ts +0 -1
  88. package/src/lib/numDaysInMonth.js +28 -0
  89. package/src/lib/numDaysInMonth.js.map +1 -0
  90. package/{dist/types → src}/lib/prettyIsoDateString.d.ts +0 -1
  91. package/src/lib/prettyIsoDateString.js +25 -0
  92. package/src/lib/prettyIsoDateString.js.map +1 -0
  93. package/{dist/types → src}/lib/secondsSinceDate.d.ts +0 -1
  94. package/src/lib/secondsSinceDate.js +19 -0
  95. package/src/lib/secondsSinceDate.js.map +1 -0
  96. package/{dist/types → src}/lib/weeksSinceDate.d.ts +0 -1
  97. package/src/lib/weeksSinceDate.js +19 -0
  98. package/src/lib/weeksSinceDate.js.map +1 -0
  99. package/{dist/types → src}/lib/yearsSinceDate.d.ts +0 -1
  100. package/src/lib/yearsSinceDate.js +19 -0
  101. package/src/lib/yearsSinceDate.js.map +1 -0
  102. package/LICENSE +0 -21
  103. package/dist/index.cjs.js +0 -6
  104. package/dist/index.cjs.js.map +0 -1
  105. package/dist/index.esm.js +0 -6
  106. package/dist/index.esm.js.map +0 -1
  107. package/dist/types/index.d.ts.map +0 -1
  108. package/dist/types/lib/assertValidDate.d.ts.map +0 -1
  109. package/dist/types/lib/assertValidDateDay.d.ts.map +0 -1
  110. package/dist/types/lib/assertValidDateMonth.d.ts.map +0 -1
  111. package/dist/types/lib/assertValidDateYear.d.ts.map +0 -1
  112. package/dist/types/lib/constants/MS_IN_DAY.d.ts.map +0 -1
  113. package/dist/types/lib/constants/MS_IN_HOUR.d.ts.map +0 -1
  114. package/dist/types/lib/constants/MS_IN_MINUTE.d.ts.map +0 -1
  115. package/dist/types/lib/constants/MS_IN_MONTH.d.ts.map +0 -1
  116. package/dist/types/lib/constants/MS_IN_SECOND.d.ts.map +0 -1
  117. package/dist/types/lib/constants/MS_IN_WEEK.d.ts.map +0 -1
  118. package/dist/types/lib/constants/MS_IN_YEAR.d.ts.map +0 -1
  119. package/dist/types/lib/dateDaysAgo.d.ts.map +0 -1
  120. package/dist/types/lib/dateWeekDayName.d.ts.map +0 -1
  121. package/dist/types/lib/daysSinceDate.d.ts.map +0 -1
  122. package/dist/types/lib/getCentury.d.ts.map +0 -1
  123. package/dist/types/lib/getCurrentYear.d.ts.map +0 -1
  124. package/dist/types/lib/hoursSinceDate.d.ts.map +0 -1
  125. package/dist/types/lib/isLeapYear.d.ts.map +0 -1
  126. package/dist/types/lib/isValidDate.d.ts.map +0 -1
  127. package/dist/types/lib/isValidDateDay.d.ts.map +0 -1
  128. package/dist/types/lib/isValidDateMonth.d.ts.map +0 -1
  129. package/dist/types/lib/isValidDateYear.d.ts.map +0 -1
  130. package/dist/types/lib/isoDateTimestamp.d.ts.map +0 -1
  131. package/dist/types/lib/isoDateTimestampForFilename.d.ts.map +0 -1
  132. package/dist/types/lib/minutesSinceDate.d.ts.map +0 -1
  133. package/dist/types/lib/monthsSinceDate.d.ts.map +0 -1
  134. package/dist/types/lib/msSinceDate.d.ts.map +0 -1
  135. package/dist/types/lib/numDaysInMonth.d.ts.map +0 -1
  136. package/dist/types/lib/prettyIsoDateString.d.ts.map +0 -1
  137. package/dist/types/lib/secondsSinceDate.d.ts.map +0 -1
  138. package/dist/types/lib/weeksSinceDate.d.ts.map +0 -1
  139. package/dist/types/lib/yearsSinceDate.d.ts.map +0 -1
  140. package/jest.config.ts +0 -13
  141. package/project.json +0 -30
  142. package/tsconfig.spec.json +0 -9
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isLeapYear = void 0;
4
+ const assertValidDateYear_1 = require("./assertValidDateYear");
5
+ /**
6
+ * Checks if a given year is a leap year.
7
+ * A leap year is exactly divisible by 4 except for century years (years ending with 00).
8
+ * The century year is a leap year only if it is perfectly divisible by 400.
9
+ * @param year The year to check. Must be a valid year number.
10
+ * @returns `true` if the year is a leap year, `false` otherwise.
11
+ * @throws Will throw an error if the year is not a valid number.
12
+ * @example ```ts
13
+ * isLeapYear(2000); ;
14
+ * //=> true
15
+ * isLeapYear(2001); ;
16
+ * //=> false
17
+ * ```
18
+ */
19
+ function isLeapYear(year) {
20
+ (0, assertValidDateYear_1.assertValidDateYear)(year);
21
+ return (0 == year % 4 && 0 != year % 100) || 0 == year % 400;
22
+ }
23
+ exports.isLeapYear = isLeapYear;
24
+ //# sourceMappingURL=isLeapYear.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isLeapYear.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/isLeapYear.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAE3D;;;;;;;;;;;;;GAaG;AACH,SAAgB,UAAU,CAAC,IAAY;IACrC,IAAA,yCAAmB,EAAC,IAAI,CAAC,CAAA;IACzB,OAAO,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,GAAG,CAAA;AAC9D,CAAC;AAHD,gCAGC"}
@@ -18,4 +18,3 @@
18
18
  * ```
19
19
  */
20
20
  export declare function isValidDate(year?: number | string, month?: number | string, day?: number | string, hour?: number | string, minute?: number | string, second?: number | string, millisecond?: number | string): boolean;
21
- //# sourceMappingURL=isValidDate.d.ts.map
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidDate = void 0;
4
+ /**
5
+ * Checks if the provided date and time values form a valid date.
6
+ * @param year The year of the date.
7
+ * @param month The month of the date.
8
+ * @param day The day of the date.
9
+ * @param hour The hour of the time.
10
+ * @param minute The minute of the time.
11
+ * @param second The second of the time.
12
+ * @param millisecond The millisecond of the time.
13
+ * @returns A boolean indicating whether the provided date and time values form a valid date.
14
+ * @example ```ts
15
+ * isValidDate(2021, 12, 31, 23, 59, 59, 999);;
16
+ * //=> true
17
+ * isValidDate('2021', '12', '31', '23', '59', '59', '999');;
18
+ * //=> true
19
+ * isValidDate(2021, 13, 31, 23, 59, 59, 999);;
20
+ * //=> false
21
+ * ```
22
+ */
23
+ function isValidDate(year, month, day, hour, minute, second, millisecond) {
24
+ year = year ? Number(year) : 0;
25
+ month = month ? Number(month) : 0;
26
+ day = day ? Number(day) : 0;
27
+ hour = hour ? Number(hour) : 0;
28
+ minute = minute ? Number(minute) : 0;
29
+ second = second ? Number(second) : 0;
30
+ millisecond = millisecond ? Number(millisecond) : 0;
31
+ const d = new Date(year, month - 1, day, hour, minute, second, millisecond);
32
+ return (d.getFullYear() === year &&
33
+ d.getMonth() + 1 === month &&
34
+ d.getDate() === day &&
35
+ d.getHours() === hour &&
36
+ d.getMinutes() === minute &&
37
+ d.getSeconds() === second &&
38
+ d.getMilliseconds() === millisecond);
39
+ }
40
+ exports.isValidDate = isValidDate;
41
+ //# sourceMappingURL=isValidDate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isValidDate.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/isValidDate.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,WAAW,CACzB,IAAsB,EACtB,KAAuB,EACvB,GAAqB,EACrB,IAAsB,EACtB,MAAwB,EACxB,MAAwB,EACxB,WAA6B;IAE7B,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC9B,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACjC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3B,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC9B,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACpC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACpC,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACnD,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,CAAA;IAC3E,OAAO,CACL,CAAC,CAAC,WAAW,EAAE,KAAK,IAAI;QACxB,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,KAAK,KAAK;QAC1B,CAAC,CAAC,OAAO,EAAE,KAAK,GAAG;QACnB,CAAC,CAAC,QAAQ,EAAE,KAAK,IAAI;QACrB,CAAC,CAAC,UAAU,EAAE,KAAK,MAAM;QACzB,CAAC,CAAC,UAAU,EAAE,KAAK,MAAM;QACzB,CAAC,CAAC,eAAe,EAAE,KAAK,WAAW,CACpC,CAAA;AACH,CAAC;AA1BD,kCA0BC"}
@@ -14,4 +14,3 @@
14
14
  * ```
15
15
  */
16
16
  export declare function isValidDateDay(day: number, month: number, year?: number): boolean;
17
- //# sourceMappingURL=isValidDateDay.d.ts.map
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidDateDay = void 0;
4
+ const numDaysInMonth_1 = require("./numDaysInMonth");
5
+ /**
6
+ * Checks if the given day is a valid day of the month.
7
+ * @param day The day of the month. Must be an integer.
8
+ * @param month The month of the year. Must be an integer.
9
+ * @param year The year. Optional parameter. If not provided, the function will not check for leap years.
10
+ * @returns A boolean indicating whether the day is valid for the given month and year.
11
+ * @example ```ts
12
+ * isValidDateDay(31, 1, 2000);
13
+ * //=> true
14
+ * isValidDateDay(31, 2, 2000);
15
+ * //=> false
16
+ * isValidDateDay(29, 2);
17
+ * //=> true
18
+ * ```
19
+ */
20
+ function isValidDateDay(day, month, year) {
21
+ if (!Number.isInteger(day))
22
+ return false;
23
+ if (!Number.isInteger(month))
24
+ return false;
25
+ if (year && !Number.isInteger(year))
26
+ return false;
27
+ if (day < 1)
28
+ return false;
29
+ if (day > (0, numDaysInMonth_1.numDaysInMonth)(month, year))
30
+ return false;
31
+ return true;
32
+ }
33
+ exports.isValidDateDay = isValidDateDay;
34
+ //# sourceMappingURL=isValidDateDay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isValidDateDay.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/isValidDateDay.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AAEjD;;;;;;;;;;;;;;GAcG;AACH,SAAgB,cAAc,CAAC,GAAW,EAAE,KAAa,EAAE,IAAa;IACtE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAA;IACxC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IAC1C,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAA;IACjD,IAAI,GAAG,GAAG,CAAC;QAAE,OAAO,KAAK,CAAA;IACzB,IAAI,GAAG,GAAG,IAAA,+BAAc,EAAC,KAAK,EAAE,IAAI,CAAC;QAAE,OAAO,KAAK,CAAA;IACnD,OAAO,IAAI,CAAA;AACb,CAAC;AAPD,wCAOC"}
@@ -10,4 +10,3 @@
10
10
  * ```
11
11
  */
12
12
  export declare function isValidDateMonth(month: number): boolean;
13
- //# sourceMappingURL=isValidDateMonth.d.ts.map
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidDateMonth = void 0;
4
+ /**
5
+ * Checks if the provided month is a valid month number (1-12).
6
+ * @param month The month number to validate.
7
+ * @returns A boolean indicating whether the month is valid.
8
+ * @example ```ts
9
+ * isValidDateMonth(5);;
10
+ * //=> true
11
+ * isValidDateMonth(13);;
12
+ * //=> false
13
+ * ```
14
+ */
15
+ function isValidDateMonth(month) {
16
+ return Number.isInteger(month) && month >= 1 && month <= 12;
17
+ }
18
+ exports.isValidDateMonth = isValidDateMonth;
19
+ //# sourceMappingURL=isValidDateMonth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isValidDateMonth.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/isValidDateMonth.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACH,SAAgB,gBAAgB,CAAC,KAAa;IAC5C,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE,CAAA;AAC7D,CAAC;AAFD,4CAEC"}
@@ -13,4 +13,3 @@
13
13
  * ```
14
14
  */
15
15
  export declare function isValidDateYear(year: number): boolean;
16
- //# sourceMappingURL=isValidDateYear.d.ts.map
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidDateYear = void 0;
4
+ /**
5
+ * Checks if the provided year is a valid date year.
6
+ * @remarks This function will return true if the year is a positive integer, false otherwise.
7
+ * @param year The year to be checked.
8
+ * @returns A boolean indicating whether the year is valid or not.
9
+ * @example ```ts
10
+ * isValidDateYear(2020); ;
11
+ * //=> true
12
+ * isValidDateYear(-2020);;
13
+ * //=> false
14
+ * isValidDateYear(2020.5);;
15
+ * //=> false
16
+ * ```
17
+ */
18
+ function isValidDateYear(year) {
19
+ return Number.isInteger(year) && year >= 0;
20
+ }
21
+ exports.isValidDateYear = isValidDateYear;
22
+ //# sourceMappingURL=isValidDateYear.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isValidDateYear.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/isValidDateYear.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;GAaG;AACH,SAAgB,eAAe,CAAC,IAAY;IAC1C,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,CAAA;AAC5C,CAAC;AAFD,0CAEC"}
@@ -13,4 +13,3 @@
13
13
  * ```
14
14
  */
15
15
  export declare function isoDateTimestamp(date?: Date): string;
16
- //# sourceMappingURL=isoDateTimestamp.d.ts.map
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isoDateTimestamp = void 0;
4
+ /**
5
+ * Converts a given date to an ISO date timestamp string.
6
+ * If no date is provided, the current date and time will be used.
7
+ * @param - The date to convert. Defaults to the current date and time.
8
+ * @returns The ISO date timestamp string.
9
+ * @example ```ts
10
+ * isoDateTimestamp(new Date('2020-01-01T00:00:00Z'));;
11
+ * //=> "20200101T000000Z"
12
+ * ```
13
+ * @example ```ts
14
+ * const timestamp = isoDateTimestamp();
15
+ * console.log(timestamp); // Outputs the current date and time in ISO format, e.g. "20210520T102030Z"
16
+ * ```
17
+ */
18
+ function isoDateTimestamp(date = new Date()) {
19
+ return date.toISOString().replace(/\D/g, '');
20
+ }
21
+ exports.isoDateTimestamp = isoDateTimestamp;
22
+ //# sourceMappingURL=isoDateTimestamp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isoDateTimestamp.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/isoDateTimestamp.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;GAaG;AACH,SAAgB,gBAAgB,CAAC,IAAI,GAAG,IAAI,IAAI,EAAE;IAChD,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;AAC9C,CAAC;AAFD,4CAEC"}
@@ -9,4 +9,3 @@
9
9
  * ```
10
10
  */
11
11
  export declare function isoDateTimestampForFilename(date?: Date): string;
12
- //# sourceMappingURL=isoDateTimestampForFilename.d.ts.map
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isoDateTimestampForFilename = void 0;
4
+ /**
5
+ * This function takes a date object and returns a string in ISO format suitable for filenames.
6
+ * If no date is provided, it uses the current date and time.
7
+ * @param date The date object to be converted. Defaults to the current date and time.
8
+ * @returns A string in the format "YYYY-MM-DD-HH-MM-SS-SSS".
9
+ * @example ```ts
10
+ * isoDateTimestampForFilename(new Date('2022-01-01T00:00:00Z'));;
11
+ * //=> "2022-01-01-00-00-00-000"
12
+ * ```
13
+ */
14
+ function isoDateTimestampForFilename(date = new Date()) {
15
+ return date
16
+ .toISOString()
17
+ .replace(/[-:T.]/g, '-')
18
+ .replace('Z', '');
19
+ }
20
+ exports.isoDateTimestampForFilename = isoDateTimestampForFilename;
21
+ //# sourceMappingURL=isoDateTimestampForFilename.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isoDateTimestampForFilename.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/isoDateTimestampForFilename.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,SAAgB,2BAA2B,CAAC,IAAI,GAAG,IAAI,IAAI,EAAE;IAC3D,OAAO,IAAI;SACR,WAAW,EAAE;SACb,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;AACrB,CAAC;AALD,kEAKC"}
@@ -10,4 +10,3 @@
10
10
  * ```
11
11
  */
12
12
  export declare function minutesSinceDate(date: Date | number): number;
13
- //# sourceMappingURL=minutesSinceDate.d.ts.map
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.minutesSinceDate = void 0;
4
+ const MS_IN_MINUTE_1 = require("./constants/MS_IN_MINUTE");
5
+ const msSinceDate_1 = require("./msSinceDate");
6
+ /**
7
+ * Calculates the number of minutes that have passed since the given date.
8
+ * @param date The date from which to calculate the number of minutes that have passed.
9
+ * @returns The number of minutes that have passed since the given date.
10
+ * @example ```ts
11
+ * new Date('2020-01-01T00:00:00Z');;
12
+ * //=> {date}
13
+ * minutesSinceDate(new Date('2020-01-01T00:00:00Z'));;
14
+ * //=> {number of minutes since 2020-01-01T00:00:00Z}
15
+ * ```
16
+ */
17
+ function minutesSinceDate(date) {
18
+ return (0, msSinceDate_1.msSinceDate)(date) / MS_IN_MINUTE_1.MS_IN_MINUTE;
19
+ }
20
+ exports.minutesSinceDate = minutesSinceDate;
21
+ //# sourceMappingURL=minutesSinceDate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"minutesSinceDate.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/minutesSinceDate.ts"],"names":[],"mappings":";;;AAAA,2DAAuD;AACvD,+CAA2C;AAE3C;;;;;;;;;;GAUG;AACH,SAAgB,gBAAgB,CAAC,IAAmB;IAClD,OAAO,IAAA,yBAAW,EAAC,IAAI,CAAC,GAAG,2BAAY,CAAA;AACzC,CAAC;AAFD,4CAEC"}
@@ -10,4 +10,3 @@
10
10
  * ```
11
11
  */
12
12
  export declare function monthsSinceDate(date: Date | number): number;
13
- //# sourceMappingURL=monthsSinceDate.d.ts.map
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.monthsSinceDate = void 0;
4
+ const MS_IN_MONTH_1 = require("./constants/MS_IN_MONTH");
5
+ const msSinceDate_1 = require("./msSinceDate");
6
+ /**
7
+ * Calculates the number of months that have passed since the provided date.
8
+ * @param date The date from which to calculate the number of passed months.
9
+ * @returns The number of months that have passed since the provided date.
10
+ * @example ```ts
11
+ * new Date(2020, 0, 1);;
12
+ * //=> {date}
13
+ * monthsSinceDate(new Date(2020, 0, 1));;
14
+ * //=> {number of months since January 1, 2020}
15
+ * ```
16
+ */
17
+ function monthsSinceDate(date) {
18
+ return (0, msSinceDate_1.msSinceDate)(date) / MS_IN_MONTH_1.MS_IN_MONTH;
19
+ }
20
+ exports.monthsSinceDate = monthsSinceDate;
21
+ //# sourceMappingURL=monthsSinceDate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monthsSinceDate.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/monthsSinceDate.ts"],"names":[],"mappings":";;;AAAA,yDAAqD;AACrD,+CAA2C;AAE3C;;;;;;;;;;GAUG;AACH,SAAgB,eAAe,CAAC,IAAmB;IACjD,OAAO,IAAA,yBAAW,EAAC,IAAI,CAAC,GAAG,yBAAW,CAAA;AACxC,CAAC;AAFD,0CAEC"}
@@ -9,4 +9,3 @@
9
9
  * ```
10
10
  */
11
11
  export declare function msSinceDate(date: Date | number): number;
12
- //# sourceMappingURL=msSinceDate.d.ts.map
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.msSinceDate = void 0;
4
+ /**
5
+ * Calculates the number of milliseconds that have passed since the provided date.
6
+ * @param date The date from which to calculate the elapsed time.
7
+ * @throws If the provided date is not a Date object or an integer.
8
+ * @returns The number of milliseconds that have passed since the provided date.
9
+ * @example ```ts
10
+ * msSinceDate(new Date('2020-01-01'));;
11
+ * //=> {number of milliseconds since 2020-01-01}
12
+ * ```
13
+ */
14
+ function msSinceDate(date) {
15
+ if (typeof date === 'number') {
16
+ if (!Number.isInteger(date)) {
17
+ throw new Error('Expected date to be a Date or an integer. Got: ' + date);
18
+ }
19
+ date = new Date(date);
20
+ }
21
+ return Date.now() - date.getTime();
22
+ }
23
+ exports.msSinceDate = msSinceDate;
24
+ //# sourceMappingURL=msSinceDate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"msSinceDate.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/msSinceDate.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,SAAgB,WAAW,CAAC,IAAmB;IAC7C,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,iDAAiD,GAAG,IAAI,CAAC,CAAA;SAC1E;QACD,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAA;KACtB;IACD,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAA;AACpC,CAAC;AARD,kCAQC"}
@@ -15,4 +15,3 @@
15
15
  * ```
16
16
  */
17
17
  export declare function numDaysInMonth(month: number, year?: number): number;
18
- //# sourceMappingURL=numDaysInMonth.d.ts.map
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.numDaysInMonth = void 0;
4
+ const assertValidDateMonth_1 = require("./assertValidDateMonth");
5
+ const isLeapYear_1 = require("./isLeapYear");
6
+ /**
7
+ * Get number of days that there are in a given month of a given year.
8
+ * Note: The number of days in february depends on whether it is leap year. If no year is given, it is assumed that it is not leap year.
9
+ * @param month The month for which the number of days is to be calculated. Should be a number between 1 and 12.
10
+ * @param year The year for which the number of days in the month is to be calculated. Optional.
11
+ * @returns The number of days in the given month for the specified year.
12
+ * @throws Will throw an error if the month is not a valid number between 1 and 12.
13
+ * @example ```ts
14
+ * numDaysInMonth(2, 2020);;
15
+ * //=> 29
16
+ * numDaysInMonth(2);;
17
+ * //=> 28
18
+ * numDaysInMonth(1);;
19
+ * //=> 31
20
+ * ```
21
+ */
22
+ function numDaysInMonth(month, year) {
23
+ (0, assertValidDateMonth_1.assertValidDateMonth)(month);
24
+ const DAYS_IN_MONTH = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
25
+ return month === 2 && year !== undefined && (0, isLeapYear_1.isLeapYear)(year) ? 29 : DAYS_IN_MONTH[month];
26
+ }
27
+ exports.numDaysInMonth = numDaysInMonth;
28
+ //# sourceMappingURL=numDaysInMonth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"numDaysInMonth.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/numDaysInMonth.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAC7D,6CAAyC;AAEzC;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,cAAc,CAAC,KAAa,EAAE,IAAa;IACzD,IAAA,2CAAoB,EAAC,KAAK,CAAC,CAAA;IAC3B,MAAM,aAAa,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;IACzE,OAAO,KAAK,KAAK,CAAC,IAAI,IAAI,KAAK,SAAS,IAAI,IAAA,uBAAU,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;AAC1F,CAAC;AAJD,wCAIC"}
@@ -1,2 +1 @@
1
1
  export declare function prettyIsoDateString(iso: string, dateTimeSeparator?: string, precision?: 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond'): string;
2
- //# sourceMappingURL=prettyIsoDateString.d.ts.map
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prettyIsoDateString = void 0;
4
+ function prettyIsoDateString(iso, dateTimeSeparator = '_', precision = 'millisecond') {
5
+ return iso.substring(0, map[precision]).replace(/T/, dateTimeSeparator).replace(/-|:/g, '.');
6
+ }
7
+ exports.prettyIsoDateString = prettyIsoDateString;
8
+ const map = {
9
+ year: 4,
10
+ month: 7,
11
+ day: 10,
12
+ hour: 13,
13
+ minute: 16,
14
+ second: 19,
15
+ millisecond: 23,
16
+ };
17
+ // const s = '2020-02-03T14:01:04.437Z'
18
+ // console.log(prettyIsoDateString(s, '_', 'year'))
19
+ // console.log(prettyIsoDateString(s, '_', 'month'))
20
+ // console.log(prettyIsoDateString(s, '_', 'day'))
21
+ // console.log(prettyIsoDateString(s, '_', 'hour'))
22
+ // console.log(prettyIsoDateString(s, '_', 'minute'))
23
+ // console.log(prettyIsoDateString(s, '_', 'second'))
24
+ // console.log(prettyIsoDateString(s, '_', 'millisecond'))
25
+ //# sourceMappingURL=prettyIsoDateString.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prettyIsoDateString.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/prettyIsoDateString.ts"],"names":[],"mappings":";;;AAAA,SAAgB,mBAAmB,CACjC,GAAW,EACX,iBAAiB,GAAG,GAAG,EACvB,YAAqF,aAAa;IAElG,OAAO,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAC9F,CAAC;AAND,kDAMC;AAED,MAAM,GAAG,GAAG;IACV,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;IACR,GAAG,EAAE,EAAE;IACP,IAAI,EAAE,EAAE;IACR,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;IACV,WAAW,EAAE,EAAE;CAChB,CAAA;AAED,uCAAuC;AACvC,mDAAmD;AACnD,oDAAoD;AACpD,kDAAkD;AAClD,mDAAmD;AACnD,qDAAqD;AACrD,qDAAqD;AACrD,0DAA0D"}
@@ -8,4 +8,3 @@
8
8
  * ```
9
9
  */
10
10
  export declare function secondsSinceDate(date: Date | number): number;
11
- //# sourceMappingURL=secondsSinceDate.d.ts.map
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.secondsSinceDate = void 0;
4
+ const MS_IN_SECOND_1 = require("./constants/MS_IN_SECOND");
5
+ const msSinceDate_1 = require("./msSinceDate");
6
+ /**
7
+ * Returns the number of seconds that have passed since the given date.
8
+ * @param date The date from which to calculate the number of seconds.
9
+ * @returns The number of seconds since the given date.
10
+ * @example ```ts
11
+ * secondsSinceDate(new Date('2020-01-01'));;
12
+ * //=> {number of seconds since 2020-01-01}
13
+ * ```
14
+ */
15
+ function secondsSinceDate(date) {
16
+ return (0, msSinceDate_1.msSinceDate)(date) / MS_IN_SECOND_1.MS_IN_SECOND;
17
+ }
18
+ exports.secondsSinceDate = secondsSinceDate;
19
+ //# sourceMappingURL=secondsSinceDate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secondsSinceDate.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/secondsSinceDate.ts"],"names":[],"mappings":";;;AAAA,2DAAuD;AACvD,+CAA2C;AAE3C;;;;;;;;GAQG;AACH,SAAgB,gBAAgB,CAAC,IAAmB;IAClD,OAAO,IAAA,yBAAW,EAAC,IAAI,CAAC,GAAG,2BAAY,CAAA;AACzC,CAAC;AAFD,4CAEC"}
@@ -8,4 +8,3 @@
8
8
  * ```
9
9
  */
10
10
  export declare function weeksSinceDate(date: Date | number): number;
11
- //# sourceMappingURL=weeksSinceDate.d.ts.map
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.weeksSinceDate = void 0;
4
+ const MS_IN_WEEK_1 = require("./constants/MS_IN_WEEK");
5
+ const msSinceDate_1 = require("./msSinceDate");
6
+ /**
7
+ * Calculates the number of weeks that have passed since the provided date.
8
+ * @param date The date from which to calculate the number of weeks passed.
9
+ * @returns The number of weeks since the provided date.
10
+ * @example ```ts
11
+ * weeksSinceDate(new Date('2020-01-01'));;
12
+ * //=> {number of weeks since '2020-01-01'}
13
+ * ```
14
+ */
15
+ function weeksSinceDate(date) {
16
+ return (0, msSinceDate_1.msSinceDate)(date) / MS_IN_WEEK_1.MS_IN_WEEK;
17
+ }
18
+ exports.weeksSinceDate = weeksSinceDate;
19
+ //# sourceMappingURL=weeksSinceDate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"weeksSinceDate.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/weeksSinceDate.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,+CAA2C;AAE3C;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAAC,IAAmB;IAChD,OAAO,IAAA,yBAAW,EAAC,IAAI,CAAC,GAAG,uBAAU,CAAA;AACvC,CAAC;AAFD,wCAEC"}
@@ -8,4 +8,3 @@
8
8
  * ```
9
9
  */
10
10
  export declare function yearsSinceDate(date: Date | number): number;
11
- //# sourceMappingURL=yearsSinceDate.d.ts.map
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.yearsSinceDate = void 0;
4
+ const MS_IN_YEAR_1 = require("./constants/MS_IN_YEAR");
5
+ const msSinceDate_1 = require("./msSinceDate");
6
+ /**
7
+ * Calculates the number of years that have passed since the provided date.
8
+ * @param date The date from which to calculate the number of years passed.
9
+ * @returns The number of years that have passed since the provided date.
10
+ * @example ```ts
11
+ * yearsSinceDate(new Date('2000-01-01'));;
12
+ * //=> {number of years since '2000-01-01'}
13
+ * ```
14
+ */
15
+ function yearsSinceDate(date) {
16
+ return (0, msSinceDate_1.msSinceDate)(date) / MS_IN_YEAR_1.MS_IN_YEAR;
17
+ }
18
+ exports.yearsSinceDate = yearsSinceDate;
19
+ //# sourceMappingURL=yearsSinceDate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yearsSinceDate.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/yearsSinceDate.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,+CAA2C;AAE3C;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAAC,IAAmB;IAChD,OAAO,IAAA,yBAAW,EAAC,IAAI,CAAC,GAAG,uBAAU,CAAA;AACvC,CAAC;AAFD,wCAEC"}
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Benjamin Møller Jensen
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/dist/index.cjs.js DELETED
@@ -1,6 +0,0 @@
1
- /*!
2
- * @bemoje/date v0.0.9
3
- * (c) Benjamin Møller Jensen
4
- * Released under the MIT License.
5
- */"use strict";function isValidDate(year,month,day,hour,minute,second,millisecond){year=year?+year:0,month=month?+month:0,day=day?+day:0,hour=hour?+hour:0,minute=minute?+minute:0,second=second?+second:0,millisecond=millisecond?+millisecond:0;const d=new Date(year,month-1,day,hour,minute,second,millisecond);return d.getFullYear()===year&&d.getMonth()+1===month&&d.getDate()===day&&d.getHours()===hour&&d.getMinutes()===minute&&d.getSeconds()===second&&d.getMilliseconds()===millisecond}function assertValidDate(year,month,day,hour,minute,second,millisecond){if(!isValidDate(year,month,day,hour,minute,second,millisecond))throw new Error(`Expected valid date. Got: ${JSON.stringify({year,month,day,hour,minute,second,millisecond})}.`)}function isValidDateMonth(month){return Number.isInteger(month)&&1<=month&&12>=month}function assertValidDateMonth(month){if(!isValidDateMonth(month))throw new Error(`Invalid month: ${month}.`)}function isValidDateYear(year){return Number.isInteger(year)&&0<=year}function assertValidDateYear(year){if(!isValidDateYear(year))throw new Error(`Invalid year: ${year}.`)}function isLeapYear(year){return assertValidDateYear(year),0==year%4&&0!=year%100||0==year%400}function numDaysInMonth(month,year){assertValidDateMonth(month);return 2===month&&year!==void 0&&isLeapYear(year)?29:[0,31,28,31,30,31,30,31,31,30,31,30,31][month]}function isValidDateDay(day,month,year){return!!Number.isInteger(day)&&!!Number.isInteger(month)&&(!year||Number.isInteger(year))&&!(1>day)&&!(day>numDaysInMonth(month,year))}function assertValidDateDay(day,month,year){if(!isValidDateDay(day,month,year))throw new Error(`Invalid day of the month: ${day}.`)}const MS_IN_DAY=86400000,MS_IN_HOUR=3600000,MS_IN_MINUTE=60000,MS_IN_MONTH=2628000000,MS_IN_SECOND=1e3,MS_IN_WEEK=604800000,MS_IN_YEAR=31536000000;function dateDaysAgo(days){const date=new Date;return date.setDate(date.getDate()-days),date}function dateWeekDayName(date){return names[date.getDay()]}const names=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function msSinceDate(date){if("number"==typeof date){if(!Number.isInteger(date))throw new Error("Expected date to be a Date or an integer. Got: "+date);date=new Date(date)}return Date.now()-date.getTime()}function daysSinceDate(date){return msSinceDate(date)/MS_IN_DAY}function getCentury(year){return assertValidDateYear(year),Math.floor(year/100)+1}function getCurrentYear(){return new Date().getUTCFullYear()}function hoursSinceDate(date){return msSinceDate(date)/MS_IN_HOUR}function isoDateTimestamp(date=new Date){return date.toISOString().replace(/\D/g,"")}function isoDateTimestampForFilename(date=new Date){return date.toISOString().replace(/[-:T.]/g,"-").replace("Z","")}function minutesSinceDate(date){return msSinceDate(date)/MS_IN_MINUTE}function monthsSinceDate(date){return msSinceDate(date)/MS_IN_MONTH}function prettyIsoDateString(iso,dateTimeSeparator="_",precision="millisecond"){return iso.substring(0,map[precision]).replace(/T/,dateTimeSeparator).replace(/-|:/g,".")}const map={year:4,month:7,day:10,hour:13,minute:16,second:19,millisecond:23};function secondsSinceDate(date){return msSinceDate(date)/MS_IN_SECOND}function weeksSinceDate(date){return msSinceDate(date)/MS_IN_WEEK}function yearsSinceDate(date){return msSinceDate(date)/MS_IN_YEAR}exports.MS_IN_DAY=86400000,exports.MS_IN_HOUR=MS_IN_HOUR,exports.MS_IN_MINUTE=MS_IN_MINUTE,exports.MS_IN_MONTH=MS_IN_MONTH,exports.MS_IN_SECOND=MS_IN_SECOND,exports.MS_IN_WEEK=MS_IN_WEEK,exports.MS_IN_YEAR=MS_IN_YEAR,exports.assertValidDate=assertValidDate,exports.assertValidDateDay=assertValidDateDay,exports.assertValidDateMonth=assertValidDateMonth,exports.assertValidDateYear=assertValidDateYear,exports.dateDaysAgo=dateDaysAgo,exports.dateWeekDayName=dateWeekDayName,exports.daysSinceDate=daysSinceDate,exports.getCentury=getCentury,exports.getCurrentYear=getCurrentYear,exports.hoursSinceDate=hoursSinceDate,exports.isLeapYear=isLeapYear,exports.isValidDate=isValidDate,exports.isValidDateDay=isValidDateDay,exports.isValidDateMonth=isValidDateMonth,exports.isValidDateYear=isValidDateYear,exports.isoDateTimestamp=isoDateTimestamp,exports.isoDateTimestampForFilename=isoDateTimestampForFilename,exports.minutesSinceDate=minutesSinceDate,exports.monthsSinceDate=monthsSinceDate,exports.msSinceDate=msSinceDate,exports.numDaysInMonth=numDaysInMonth,exports.prettyIsoDateString=prettyIsoDateString,exports.secondsSinceDate=secondsSinceDate,exports.weeksSinceDate=weeksSinceDate,exports.yearsSinceDate=yearsSinceDate;
6
- //# sourceMappingURL=index.cjs.js.map