@bemoje/date 0.3.0 → 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.
Files changed (157) hide show
  1. package/index.d.ts +90 -0
  2. package/index.mjs +112 -0
  3. package/package.json +23 -16
  4. package/LICENSE +0 -21
  5. package/README.md +0 -34
  6. package/cjs/index.d.ts +0 -38
  7. package/cjs/index.d.ts.map +0 -1
  8. package/cjs/index.js +0 -41
  9. package/cjs/index.js.map +0 -1
  10. package/cjs/lib/assertValidDate.d.ts +0 -19
  11. package/cjs/lib/assertValidDate.d.ts.map +0 -1
  12. package/cjs/lib/assertValidDate.js +0 -36
  13. package/cjs/lib/assertValidDate.js.map +0 -1
  14. package/cjs/lib/assertValidDateDay.d.ts +0 -16
  15. package/cjs/lib/assertValidDateDay.d.ts.map +0 -1
  16. package/cjs/lib/assertValidDateDay.js +0 -24
  17. package/cjs/lib/assertValidDateDay.js.map +0 -1
  18. package/cjs/lib/assertValidDateMonth.d.ts +0 -13
  19. package/cjs/lib/assertValidDateMonth.d.ts.map +0 -1
  20. package/cjs/lib/assertValidDateMonth.js +0 -21
  21. package/cjs/lib/assertValidDateMonth.js.map +0 -1
  22. package/cjs/lib/assertValidDateYear.d.ts +0 -14
  23. package/cjs/lib/assertValidDateYear.d.ts.map +0 -1
  24. package/cjs/lib/assertValidDateYear.js +0 -22
  25. package/cjs/lib/assertValidDateYear.js.map +0 -1
  26. package/cjs/lib/constants/DAYS_IN_MONTH.d.ts +0 -5
  27. package/cjs/lib/constants/DAYS_IN_MONTH.d.ts.map +0 -1
  28. package/cjs/lib/constants/DAYS_IN_MONTH.js +0 -8
  29. package/cjs/lib/constants/DAYS_IN_MONTH.js.map +0 -1
  30. package/cjs/lib/constants/MS_IN_DAY.d.ts +0 -5
  31. package/cjs/lib/constants/MS_IN_DAY.d.ts.map +0 -1
  32. package/cjs/lib/constants/MS_IN_DAY.js +0 -8
  33. package/cjs/lib/constants/MS_IN_DAY.js.map +0 -1
  34. package/cjs/lib/constants/MS_IN_HOUR.d.ts +0 -5
  35. package/cjs/lib/constants/MS_IN_HOUR.d.ts.map +0 -1
  36. package/cjs/lib/constants/MS_IN_HOUR.js +0 -8
  37. package/cjs/lib/constants/MS_IN_HOUR.js.map +0 -1
  38. package/cjs/lib/constants/MS_IN_MINUTE.d.ts +0 -5
  39. package/cjs/lib/constants/MS_IN_MINUTE.d.ts.map +0 -1
  40. package/cjs/lib/constants/MS_IN_MINUTE.js +0 -8
  41. package/cjs/lib/constants/MS_IN_MINUTE.js.map +0 -1
  42. package/cjs/lib/constants/MS_IN_MONTH.d.ts +0 -5
  43. package/cjs/lib/constants/MS_IN_MONTH.d.ts.map +0 -1
  44. package/cjs/lib/constants/MS_IN_MONTH.js +0 -8
  45. package/cjs/lib/constants/MS_IN_MONTH.js.map +0 -1
  46. package/cjs/lib/constants/MS_IN_SECOND.d.ts +0 -5
  47. package/cjs/lib/constants/MS_IN_SECOND.d.ts.map +0 -1
  48. package/cjs/lib/constants/MS_IN_SECOND.js +0 -8
  49. package/cjs/lib/constants/MS_IN_SECOND.js.map +0 -1
  50. package/cjs/lib/constants/MS_IN_WEEK.d.ts +0 -5
  51. package/cjs/lib/constants/MS_IN_WEEK.d.ts.map +0 -1
  52. package/cjs/lib/constants/MS_IN_WEEK.js +0 -8
  53. package/cjs/lib/constants/MS_IN_WEEK.js.map +0 -1
  54. package/cjs/lib/constants/MS_IN_YEAR.d.ts +0 -5
  55. package/cjs/lib/constants/MS_IN_YEAR.d.ts.map +0 -1
  56. package/cjs/lib/constants/MS_IN_YEAR.js +0 -8
  57. package/cjs/lib/constants/MS_IN_YEAR.js.map +0 -1
  58. package/cjs/lib/dateAdjustHoursBy.d.ts +0 -8
  59. package/cjs/lib/dateAdjustHoursBy.d.ts.map +0 -1
  60. package/cjs/lib/dateAdjustHoursBy.js +0 -14
  61. package/cjs/lib/dateAdjustHoursBy.js.map +0 -1
  62. package/cjs/lib/dateCreateTimeZoneSetter.d.ts +0 -7
  63. package/cjs/lib/dateCreateTimeZoneSetter.d.ts.map +0 -1
  64. package/cjs/lib/dateCreateTimeZoneSetter.js +0 -16
  65. package/cjs/lib/dateCreateTimeZoneSetter.js.map +0 -1
  66. package/cjs/lib/dateDaysAgo.d.ts +0 -6
  67. package/cjs/lib/dateDaysAgo.d.ts.map +0 -1
  68. package/cjs/lib/dateDaysAgo.js +0 -14
  69. package/cjs/lib/dateDaysAgo.js.map +0 -1
  70. package/cjs/lib/dateWeekDayName.d.ts +0 -12
  71. package/cjs/lib/dateWeekDayName.d.ts.map +0 -1
  72. package/cjs/lib/dateWeekDayName.js +0 -19
  73. package/cjs/lib/dateWeekDayName.js.map +0 -1
  74. package/cjs/lib/daysSinceDate.d.ts +0 -13
  75. package/cjs/lib/daysSinceDate.d.ts.map +0 -1
  76. package/cjs/lib/daysSinceDate.js +0 -21
  77. package/cjs/lib/daysSinceDate.js.map +0 -1
  78. package/cjs/lib/getCentury.d.ts +0 -14
  79. package/cjs/lib/getCentury.d.ts.map +0 -1
  80. package/cjs/lib/getCentury.js +0 -22
  81. package/cjs/lib/getCentury.js.map +0 -1
  82. package/cjs/lib/getCurrentYear.d.ts +0 -33
  83. package/cjs/lib/getCurrentYear.d.ts.map +0 -1
  84. package/cjs/lib/getCurrentYear.js +0 -47
  85. package/cjs/lib/getCurrentYear.js.map +0 -1
  86. package/cjs/lib/hoursSinceDate.d.ts +0 -13
  87. package/cjs/lib/hoursSinceDate.d.ts.map +0 -1
  88. package/cjs/lib/hoursSinceDate.js +0 -21
  89. package/cjs/lib/hoursSinceDate.js.map +0 -1
  90. package/cjs/lib/isLeapYear.d.ts +0 -16
  91. package/cjs/lib/isLeapYear.d.ts.map +0 -1
  92. package/cjs/lib/isLeapYear.js +0 -24
  93. package/cjs/lib/isLeapYear.js.map +0 -1
  94. package/cjs/lib/isValidDate.d.ts +0 -21
  95. package/cjs/lib/isValidDate.d.ts.map +0 -1
  96. package/cjs/lib/isValidDate.js +0 -41
  97. package/cjs/lib/isValidDate.js.map +0 -1
  98. package/cjs/lib/isValidDateDay.d.ts +0 -17
  99. package/cjs/lib/isValidDateDay.d.ts.map +0 -1
  100. package/cjs/lib/isValidDateDay.js +0 -34
  101. package/cjs/lib/isValidDateDay.js.map +0 -1
  102. package/cjs/lib/isValidDateMonth.d.ts +0 -13
  103. package/cjs/lib/isValidDateMonth.d.ts.map +0 -1
  104. package/cjs/lib/isValidDateMonth.js +0 -19
  105. package/cjs/lib/isValidDateMonth.js.map +0 -1
  106. package/cjs/lib/isValidDateYear.d.ts +0 -16
  107. package/cjs/lib/isValidDateYear.d.ts.map +0 -1
  108. package/cjs/lib/isValidDateYear.js +0 -22
  109. package/cjs/lib/isValidDateYear.js.map +0 -1
  110. package/cjs/lib/isoDateTimestamp.d.ts +0 -16
  111. package/cjs/lib/isoDateTimestamp.d.ts.map +0 -1
  112. package/cjs/lib/isoDateTimestamp.js +0 -22
  113. package/cjs/lib/isoDateTimestamp.js.map +0 -1
  114. package/cjs/lib/isoDateTimestampForFilename.d.ts +0 -12
  115. package/cjs/lib/isoDateTimestampForFilename.d.ts.map +0 -1
  116. package/cjs/lib/isoDateTimestampForFilename.js +0 -21
  117. package/cjs/lib/isoDateTimestampForFilename.js.map +0 -1
  118. package/cjs/lib/minutesSinceDate.d.ts +0 -13
  119. package/cjs/lib/minutesSinceDate.d.ts.map +0 -1
  120. package/cjs/lib/minutesSinceDate.js +0 -21
  121. package/cjs/lib/minutesSinceDate.js.map +0 -1
  122. package/cjs/lib/monthNameDa.d.ts +0 -17
  123. package/cjs/lib/monthNameDa.d.ts.map +0 -1
  124. package/cjs/lib/monthNameDa.js +0 -43
  125. package/cjs/lib/monthNameDa.js.map +0 -1
  126. package/cjs/lib/monthNameEn.d.ts +0 -17
  127. package/cjs/lib/monthNameEn.d.ts.map +0 -1
  128. package/cjs/lib/monthNameEn.js +0 -43
  129. package/cjs/lib/monthNameEn.js.map +0 -1
  130. package/cjs/lib/monthsSinceDate.d.ts +0 -13
  131. package/cjs/lib/monthsSinceDate.d.ts.map +0 -1
  132. package/cjs/lib/monthsSinceDate.js +0 -21
  133. package/cjs/lib/monthsSinceDate.js.map +0 -1
  134. package/cjs/lib/msSinceDate.d.ts +0 -12
  135. package/cjs/lib/msSinceDate.d.ts.map +0 -1
  136. package/cjs/lib/msSinceDate.js +0 -24
  137. package/cjs/lib/msSinceDate.js.map +0 -1
  138. package/cjs/lib/numDaysInMonth.d.ts +0 -18
  139. package/cjs/lib/numDaysInMonth.d.ts.map +0 -1
  140. package/cjs/lib/numDaysInMonth.js +0 -28
  141. package/cjs/lib/numDaysInMonth.js.map +0 -1
  142. package/cjs/lib/prettyIsoDateString.d.ts +0 -14
  143. package/cjs/lib/prettyIsoDateString.d.ts.map +0 -1
  144. package/cjs/lib/prettyIsoDateString.js +0 -29
  145. package/cjs/lib/prettyIsoDateString.js.map +0 -1
  146. package/cjs/lib/secondsSinceDate.d.ts +0 -11
  147. package/cjs/lib/secondsSinceDate.d.ts.map +0 -1
  148. package/cjs/lib/secondsSinceDate.js +0 -19
  149. package/cjs/lib/secondsSinceDate.js.map +0 -1
  150. package/cjs/lib/weeksSinceDate.d.ts +0 -11
  151. package/cjs/lib/weeksSinceDate.d.ts.map +0 -1
  152. package/cjs/lib/weeksSinceDate.js +0 -19
  153. package/cjs/lib/weeksSinceDate.js.map +0 -1
  154. package/cjs/lib/yearsSinceDate.d.ts +0 -11
  155. package/cjs/lib/yearsSinceDate.d.ts.map +0 -1
  156. package/cjs/lib/yearsSinceDate.js +0 -19
  157. package/cjs/lib/yearsSinceDate.js.map +0 -1
package/index.d.ts ADDED
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Returns a function that returns the elapsed time since invokation.
3
+ */
4
+ declare function Timer(startTime?: number): (endTime?: number) => string;
5
+
6
+ /**
7
+ * Reutnrs the date formatted as: yyyy-MM-dd
8
+ */
9
+ declare function dateString(date?: Date | number | string): string;
10
+
11
+ /**
12
+ * Converts days to milliseconds.
13
+ */
14
+ declare function daysToMs(days: number): number;
15
+
16
+ /**
17
+ * Get the week number of the year for a given date using Danish locale.
18
+ */
19
+ declare function getWeek(date: Date): number;
20
+
21
+ /**
22
+ * Determines if a specified cooldown period has elapsed since a given date.
23
+ *
24
+ * @param startDate - The starting date to calculate elapsed time from.
25
+ * @param cooldownMs - The cooldown duration in milliseconds.
26
+ * @returns `true` if the cooldown period has elapsed, otherwise `false`.
27
+ */
28
+ declare function hasCooldownElapsed(startDate: Date, cooldownMs: number): boolean;
29
+
30
+ /**
31
+ * Converts hours to milliseconds.
32
+ */
33
+ declare function hoursToMs(hours: number): number;
34
+
35
+ /**
36
+ * Converts minutes to milliseconds.
37
+ */
38
+ declare function minutesToMs(minutes: number): number;
39
+
40
+ /**
41
+ * Returns the name, in Danish language, of the month corresponding to the provided month number.
42
+ *
43
+ * @param month - A month number between 1 and 12.
44
+ *
45
+ * @throws if the provided month number is not a valid month.
46
+ *
47
+ * @example ```ts
48
+ * monthNameDA(9) //=> 'September'
49
+ * ```
50
+ */
51
+ declare function monthNameDa(month: number): string;
52
+
53
+ /**
54
+ * Get the (Danish) name of the month relative to the current month.
55
+ *
56
+ * @example ```ts
57
+ * // assuming current month is August
58
+ * monthNameDaRelative(-1) //=> 'Juli'
59
+ * monthNameDaRelative(0) //=> 'August'
60
+ * monthNameDaRelative(1) //=> 'September'
61
+ * ```
62
+ */
63
+ declare function monthNameDaRelative(n: number): string;
64
+
65
+ /**
66
+ * Calculates the number of milliseconds that have elapsed since the given date.
67
+ */
68
+ declare function msSinceDate(date: Date | string | number): number;
69
+
70
+ /**
71
+ * Converts seconds to milliseconds.
72
+ */
73
+ declare function secondsToMs(seconds: number): number;
74
+
75
+ /**
76
+ * Remove the time component from a date, returning only the date part.
77
+ */
78
+ declare function stripTime(date: Date): Date;
79
+
80
+ /**
81
+ * Get the UTC date today, time stripped
82
+ */
83
+ declare function today(): Date;
84
+
85
+ /**
86
+ * Get the UTC date yesterday, time stripped
87
+ */
88
+ declare function yesterday(): Date;
89
+
90
+ export { Timer, dateString, daysToMs, getWeek, hasCooldownElapsed, hoursToMs, minutesToMs, monthNameDa, monthNameDaRelative, msSinceDate, secondsToMs, stripTime, today, yesterday };
package/index.mjs ADDED
@@ -0,0 +1,112 @@
1
+ import { ms } from 'enhanced-ms';
2
+ import { format, getWeek as getWeek$1, addMonths, subDays } from 'date-fns';
3
+ import { da } from 'date-fns/locale';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ function Timer(startTime = Date.now()) {
8
+ return function(endTime = Date.now()) {
9
+ const duration = endTime - startTime;
10
+ if (duration === 0) {
11
+ return "0ms";
12
+ }
13
+ const string = ms(duration, {
14
+ useAbbreviations: true
15
+ });
16
+ return string ?? `${duration}ms`;
17
+ };
18
+ }
19
+ __name(Timer, "Timer");
20
+ function dateString(date) {
21
+ return format(date ? new Date(date) : /* @__PURE__ */ new Date(), "yyyy-MM-dd");
22
+ }
23
+ __name(dateString, "dateString");
24
+
25
+ // src/daysToMs.ts
26
+ function daysToMs(days) {
27
+ return 1e3 * 60 * 60 * 24 * days;
28
+ }
29
+ __name(daysToMs, "daysToMs");
30
+ function getWeek(date) {
31
+ return getWeek$1(date, {
32
+ locale: da
33
+ });
34
+ }
35
+ __name(getWeek, "getWeek");
36
+
37
+ // src/hasCooldownElapsed.ts
38
+ function hasCooldownElapsed(startDate, cooldownMs) {
39
+ const elapsedMs = Date.now() - startDate.getTime();
40
+ return elapsedMs > cooldownMs;
41
+ }
42
+ __name(hasCooldownElapsed, "hasCooldownElapsed");
43
+
44
+ // src/hoursToMs.ts
45
+ function hoursToMs(hours) {
46
+ return 1e3 * 60 * 60 * hours;
47
+ }
48
+ __name(hoursToMs, "hoursToMs");
49
+
50
+ // src/minutesToMs.ts
51
+ function minutesToMs(minutes) {
52
+ return 1e3 * 60 * minutes;
53
+ }
54
+ __name(minutesToMs, "minutesToMs");
55
+
56
+ // src/monthNameDa.ts
57
+ function monthNameDa(month) {
58
+ if (month < 1 || month > 12) {
59
+ throw new Error(`Invalid month number. Got: ${month}`);
60
+ }
61
+ return MONTH_NAMES_DA[month];
62
+ }
63
+ __name(monthNameDa, "monthNameDa");
64
+ var MONTH_NAMES_DA = [
65
+ "",
66
+ "Januar",
67
+ "Februar",
68
+ "Marts",
69
+ "April",
70
+ "Maj",
71
+ "Juni",
72
+ "Juli",
73
+ "August",
74
+ "September",
75
+ "Oktober",
76
+ "November",
77
+ "December"
78
+ ];
79
+ function monthNameDaRelative(n) {
80
+ return monthNameDa(addMonths(/* @__PURE__ */ new Date(), n).getUTCMonth() + 1);
81
+ }
82
+ __name(monthNameDaRelative, "monthNameDaRelative");
83
+
84
+ // src/msSinceDate.ts
85
+ function msSinceDate(date) {
86
+ return Date.now() - new Date(date).getTime();
87
+ }
88
+ __name(msSinceDate, "msSinceDate");
89
+
90
+ // src/secondsToMs.ts
91
+ function secondsToMs(seconds) {
92
+ return 1e3 * seconds;
93
+ }
94
+ __name(secondsToMs, "secondsToMs");
95
+
96
+ // src/stripTime.ts
97
+ function stripTime(date) {
98
+ return new Date(date.toISOString().slice(0, 10));
99
+ }
100
+ __name(stripTime, "stripTime");
101
+
102
+ // src/today.ts
103
+ function today() {
104
+ return stripTime(new Date(Date.now()));
105
+ }
106
+ __name(today, "today");
107
+ function yesterday() {
108
+ return stripTime(subDays(today(), 1));
109
+ }
110
+ __name(yesterday, "yesterday");
111
+
112
+ export { Timer, dateString, daysToMs, getWeek, hasCooldownElapsed, hoursToMs, minutesToMs, monthNameDa, monthNameDaRelative, msSinceDate, secondsToMs, stripTime, today, yesterday };
package/package.json CHANGED
@@ -1,14 +1,28 @@
1
1
  {
2
2
  "name": "@bemoje/date",
3
- "version": "0.3.0",
4
- "type": "commonjs",
5
- "main": "cjs/index.js",
6
- "types": "cjs/index.d.ts",
3
+ "version": "1.0.0",
4
+ "description": "date",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "keywords": [
8
+ "date"
9
+ ],
10
+ "exports": {
11
+ ".": {
12
+ "types": "./index.d.ts",
13
+ "import": "./index.mjs",
14
+ "default": "./index.mjs"
15
+ }
16
+ },
7
17
  "dependencies": {
8
- "tslib": "^2.6.2"
18
+ "date-fns": "^4.1.0",
19
+ "enhanced-ms": "^4.1.0",
20
+ "@types/date-fns": "^2.6.3"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
9
24
  },
10
25
  "license": "MIT",
11
- "keywords": [],
12
26
  "author": {
13
27
  "name": "Benjamin Møller Jensen",
14
28
  "email": "bemoje@bemoje.net",
@@ -16,14 +30,7 @@
16
30
  },
17
31
  "repository": {
18
32
  "type": "git",
19
- "url": "git+https://github.com/bemoje/tsmono.git"
20
- },
21
- "funding": {
22
- "type": "patreon",
23
- "url": "https://www.patreon.com/user?u=40752770"
24
- },
25
- "bugs": {
26
- "url": "https://github.com/bemoje/tsmono/issues"
27
- },
28
- "homepage": "https://github.com/bemoje/tsmono"
33
+ "url": "git+https://github.com/bemoje/mono.git",
34
+ "directory": "libs/date"
35
+ }
29
36
  }
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/README.md DELETED
@@ -1,34 +0,0 @@
1
- # @bemoje/date
2
-
3
-
4
-
5
- ![npm (scoped)](https://img.shields.io/npm/v/%40bemoje/trie-map)
6
- ![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/%40bemoje/date)
7
- ![npm](https://img.shields.io/npm/dt/%40bemoje/date)
8
- ![NPM](https://img.shields.io/npm/l/%40bemoje%2Fdate)
9
-
10
- ![GitHub last commit (by committer)](https://img.shields.io/github/last-commit/bemoje/tsmono)
11
- ![GitHub closed pull requests](https://img.shields.io/github/issues-pr-closed/bemoje/tsmono)
12
- ![GitHub top language](https://img.shields.io/github/languages/top/bemoje/tsmono)
13
-
14
-
15
- ## Documentation
16
- [Documentation Website](https://bemoje.github.io/tsmono/modules/date.html)
17
-
18
- ## Installation
19
- This library is published in the NPM registry and can be installed using any compatible package manager.
20
-
21
- #### NPM
22
- ```sh
23
- npm install @bemoje/date
24
- ```
25
-
26
-
27
- ## Issues
28
- Please let me know of any bugs or [issues](https://github.com/bemoje/tsmono/issues).
29
-
30
- ## Contribute
31
- Contributors are welcome to open a [pull request](https://github.com/bemoje/tsmono/pulls).
32
-
33
- ## License
34
- Released under the [undefined License](./LICENSE).
package/cjs/index.d.ts DELETED
@@ -1,38 +0,0 @@
1
- export * from './lib/assertValidDate';
2
- export * from './lib/assertValidDateDay';
3
- export * from './lib/assertValidDateMonth';
4
- export * from './lib/assertValidDateYear';
5
- export * from './lib/constants/DAYS_IN_MONTH';
6
- export * from './lib/constants/MS_IN_DAY';
7
- export * from './lib/constants/MS_IN_HOUR';
8
- export * from './lib/constants/MS_IN_MINUTE';
9
- export * from './lib/constants/MS_IN_MONTH';
10
- export * from './lib/constants/MS_IN_SECOND';
11
- export * from './lib/constants/MS_IN_WEEK';
12
- export * from './lib/constants/MS_IN_YEAR';
13
- export * from './lib/dateAdjustHoursBy';
14
- export * from './lib/dateCreateTimeZoneSetter';
15
- export * from './lib/dateDaysAgo';
16
- export * from './lib/dateWeekDayName';
17
- export * from './lib/daysSinceDate';
18
- export * from './lib/getCentury';
19
- export * from './lib/getCurrentYear';
20
- export * from './lib/hoursSinceDate';
21
- export * from './lib/isLeapYear';
22
- export * from './lib/isoDateTimestamp';
23
- export * from './lib/isoDateTimestampForFilename';
24
- export * from './lib/isValidDate';
25
- export * from './lib/isValidDateDay';
26
- export * from './lib/isValidDateMonth';
27
- export * from './lib/isValidDateYear';
28
- export * from './lib/minutesSinceDate';
29
- export * from './lib/monthNameDa';
30
- export * from './lib/monthNameEn';
31
- export * from './lib/monthsSinceDate';
32
- export * from './lib/msSinceDate';
33
- export * from './lib/numDaysInMonth';
34
- export * from './lib/prettyIsoDateString';
35
- export * from './lib/secondsSinceDate';
36
- export * from './lib/weeksSinceDate';
37
- export * from './lib/yearsSinceDate';
38
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/date/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA;AACxC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,2BAA2B,CAAA;AACzC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,2BAA2B,CAAA;AACzC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,mBAAmB,CAAA;AACjC,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA;AACtC,cAAc,mCAAmC,CAAA;AACjD,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA"}
package/cjs/index.js DELETED
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./lib/assertValidDate"), exports);
5
- tslib_1.__exportStar(require("./lib/assertValidDateDay"), exports);
6
- tslib_1.__exportStar(require("./lib/assertValidDateMonth"), exports);
7
- tslib_1.__exportStar(require("./lib/assertValidDateYear"), exports);
8
- tslib_1.__exportStar(require("./lib/constants/DAYS_IN_MONTH"), exports);
9
- tslib_1.__exportStar(require("./lib/constants/MS_IN_DAY"), exports);
10
- tslib_1.__exportStar(require("./lib/constants/MS_IN_HOUR"), exports);
11
- tslib_1.__exportStar(require("./lib/constants/MS_IN_MINUTE"), exports);
12
- tslib_1.__exportStar(require("./lib/constants/MS_IN_MONTH"), exports);
13
- tslib_1.__exportStar(require("./lib/constants/MS_IN_SECOND"), exports);
14
- tslib_1.__exportStar(require("./lib/constants/MS_IN_WEEK"), exports);
15
- tslib_1.__exportStar(require("./lib/constants/MS_IN_YEAR"), exports);
16
- tslib_1.__exportStar(require("./lib/dateAdjustHoursBy"), exports);
17
- tslib_1.__exportStar(require("./lib/dateCreateTimeZoneSetter"), exports);
18
- tslib_1.__exportStar(require("./lib/dateDaysAgo"), exports);
19
- tslib_1.__exportStar(require("./lib/dateWeekDayName"), exports);
20
- tslib_1.__exportStar(require("./lib/daysSinceDate"), exports);
21
- tslib_1.__exportStar(require("./lib/getCentury"), exports);
22
- tslib_1.__exportStar(require("./lib/getCurrentYear"), exports);
23
- tslib_1.__exportStar(require("./lib/hoursSinceDate"), exports);
24
- tslib_1.__exportStar(require("./lib/isLeapYear"), exports);
25
- tslib_1.__exportStar(require("./lib/isoDateTimestamp"), exports);
26
- tslib_1.__exportStar(require("./lib/isoDateTimestampForFilename"), exports);
27
- tslib_1.__exportStar(require("./lib/isValidDate"), exports);
28
- tslib_1.__exportStar(require("./lib/isValidDateDay"), exports);
29
- tslib_1.__exportStar(require("./lib/isValidDateMonth"), exports);
30
- tslib_1.__exportStar(require("./lib/isValidDateYear"), exports);
31
- tslib_1.__exportStar(require("./lib/minutesSinceDate"), exports);
32
- tslib_1.__exportStar(require("./lib/monthNameDa"), exports);
33
- tslib_1.__exportStar(require("./lib/monthNameEn"), exports);
34
- tslib_1.__exportStar(require("./lib/monthsSinceDate"), exports);
35
- tslib_1.__exportStar(require("./lib/msSinceDate"), exports);
36
- tslib_1.__exportStar(require("./lib/numDaysInMonth"), exports);
37
- tslib_1.__exportStar(require("./lib/prettyIsoDateString"), exports);
38
- tslib_1.__exportStar(require("./lib/secondsSinceDate"), exports);
39
- tslib_1.__exportStar(require("./lib/weeksSinceDate"), exports);
40
- tslib_1.__exportStar(require("./lib/yearsSinceDate"), exports);
41
- //# sourceMappingURL=index.js.map
package/cjs/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/date/src/index.ts"],"names":[],"mappings":";;;AAAA,gEAAqC;AACrC,mEAAwC;AACxC,qEAA0C;AAC1C,oEAAyC;AACzC,wEAA6C;AAC7C,oEAAyC;AACzC,qEAA0C;AAC1C,uEAA4C;AAC5C,sEAA2C;AAC3C,uEAA4C;AAC5C,qEAA0C;AAC1C,qEAA0C;AAC1C,kEAAuC;AACvC,yEAA8C;AAC9C,4DAAiC;AACjC,gEAAqC;AACrC,8DAAmC;AACnC,2DAAgC;AAChC,+DAAoC;AACpC,+DAAoC;AACpC,2DAAgC;AAChC,iEAAsC;AACtC,4EAAiD;AACjD,4DAAiC;AACjC,+DAAoC;AACpC,iEAAsC;AACtC,gEAAqC;AACrC,iEAAsC;AACtC,4DAAiC;AACjC,4DAAiC;AACjC,gEAAqC;AACrC,4DAAiC;AACjC,+DAAoC;AACpC,oEAAyC;AACzC,iEAAsC;AACtC,+DAAoC;AACpC,+DAAoC"}
@@ -1,19 +0,0 @@
1
- /**
2
- * Asserts that the provided date parameters form a valid date.
3
- * @param year The year of the date.
4
- * @param month The month of the date.
5
- * @param day The day of the date.
6
- * @param hour The hour of the date.
7
- * @param minute The minute of the date.
8
- * @param second The second of the date.
9
- * @param millisecond The millisecond of the date.
10
- * @throws Will throw an error if the date is not valid.
11
- * @example ```ts
12
- * assertValidDate(2021, 12, 31, 23, 59, 59, 999);;
13
- * //=> true
14
- * assertValidDate(2021, 13, 31, 23, 59, 59, 999);;
15
- * //=> throws an error
16
- * ```
17
- */
18
- export declare function assertValidDate(year?: number | string, month?: number | string, day?: number | string, hour?: number | string, minute?: number | string, second?: number | string, millisecond?: number | string): void;
19
- //# sourceMappingURL=assertValidDate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"assertValidDate.d.ts","sourceRoot":"","sources":["../../../../../packages/date/src/lib/assertValidDate.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAC7B,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EACtB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EACvB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EACrB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EACtB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EACxB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAC5B,IAAI,CAcN"}
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assertValidDate = void 0;
4
- const isValidDate_1 = require("./isValidDate");
5
- /**
6
- * Asserts that the provided date parameters form a valid date.
7
- * @param year The year of the date.
8
- * @param month The month of the date.
9
- * @param day The day of the date.
10
- * @param hour The hour of the date.
11
- * @param minute The minute of the date.
12
- * @param second The second of the date.
13
- * @param millisecond The millisecond of the date.
14
- * @throws Will throw an error if the date is not valid.
15
- * @example ```ts
16
- * assertValidDate(2021, 12, 31, 23, 59, 59, 999);;
17
- * //=> true
18
- * assertValidDate(2021, 13, 31, 23, 59, 59, 999);;
19
- * //=> throws an error
20
- * ```
21
- */
22
- function assertValidDate(year, month, day, hour, minute, second, millisecond) {
23
- if (!(0, isValidDate_1.isValidDate)(year, month, day, hour, minute, second, millisecond)) {
24
- throw new Error(`Expected valid date. Got: ${JSON.stringify({
25
- year,
26
- month,
27
- day,
28
- hour,
29
- minute,
30
- second,
31
- millisecond,
32
- })}.`);
33
- }
34
- }
35
- exports.assertValidDate = assertValidDate;
36
- //# sourceMappingURL=assertValidDate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"assertValidDate.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/assertValidDate.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAE3C;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,eAAe,CAC7B,IAAsB,EACtB,KAAuB,EACvB,GAAqB,EACrB,IAAsB,EACtB,MAAwB,EACxB,MAAwB,EACxB,WAA6B;IAE7B,IAAI,CAAC,IAAA,yBAAW,EAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE;QACrE,MAAM,IAAI,KAAK,CACb,6BAA6B,IAAI,CAAC,SAAS,CAAC;YAC1C,IAAI;YACJ,KAAK;YACL,GAAG;YACH,IAAI;YACJ,MAAM;YACN,MAAM;YACN,WAAW;SACZ,CAAC,GAAG,CACN,CAAA;KACF;AACH,CAAC;AAtBD,0CAsBC"}
@@ -1,16 +0,0 @@
1
- /**
2
- * Asserts that the provided day, month, and optional year form a valid date.
3
- * If the date is not valid, it throws an error.
4
- * @param day The day of the month. Should be an integer between 1 and 31.
5
- * @param month The month of the year. Should be an integer between 1 and 12.
6
- * @param year The year of the date. Optional parameter. If provided, should be a positive integer.
7
- * @throws Will throw an error if the provided day, month, and optional year do not form a valid date.
8
- * @example ```ts
9
- * assertValidDateDay(31, 2, 2020);;
10
- * //=> Error: Invalid day of the month: 31.
11
- * assertValidDateDay(29, 2, 2020);;
12
- * //=> no error
13
- * ```
14
- */
15
- export declare function assertValidDateDay(day: number, month: number, year?: number): void;
16
- //# sourceMappingURL=assertValidDateDay.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"assertValidDateDay.d.ts","sourceRoot":"","sources":["../../../../../packages/date/src/lib/assertValidDateDay.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAElF"}
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assertValidDateDay = void 0;
4
- const isValidDateDay_1 = require("./isValidDateDay");
5
- /**
6
- * Asserts that the provided day, month, and optional year form a valid date.
7
- * If the date is not valid, it throws an error.
8
- * @param day The day of the month. Should be an integer between 1 and 31.
9
- * @param month The month of the year. Should be an integer between 1 and 12.
10
- * @param year The year of the date. Optional parameter. If provided, should be a positive integer.
11
- * @throws Will throw an error if the provided day, month, and optional year do not form a valid date.
12
- * @example ```ts
13
- * assertValidDateDay(31, 2, 2020);;
14
- * //=> Error: Invalid day of the month: 31.
15
- * assertValidDateDay(29, 2, 2020);;
16
- * //=> no error
17
- * ```
18
- */
19
- function assertValidDateDay(day, month, year) {
20
- if (!(0, isValidDateDay_1.isValidDateDay)(day, month, year))
21
- throw new Error(`Invalid day of the month: ${day}.`);
22
- }
23
- exports.assertValidDateDay = assertValidDateDay;
24
- //# sourceMappingURL=assertValidDateDay.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"assertValidDateDay.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/assertValidDateDay.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AAEjD;;;;;;;;;;;;;GAaG;AACH,SAAgB,kBAAkB,CAAC,GAAW,EAAE,KAAa,EAAE,IAAa;IAC1E,IAAI,CAAC,IAAA,+BAAc,EAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,GAAG,GAAG,CAAC,CAAA;AAC7F,CAAC;AAFD,gDAEC"}
@@ -1,13 +0,0 @@
1
- /**
2
- * Asserts if the provided month is a valid date month.
3
- * @param month The month to be validated. Should be a number between 1 and 12.
4
- * @throws Will throw an error if the month is not a valid date month.
5
- * @example ```ts
6
- * assertValidDateMonth(13);;
7
- * //=> Error: Invalid month: 13.
8
- * assertValidDateMonth(1);;
9
- * //=> undefined
10
- * ```
11
- */
12
- export declare function assertValidDateMonth(month: number): void;
13
- //# sourceMappingURL=assertValidDateMonth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"assertValidDateMonth.d.ts","sourceRoot":"","sources":["../../../../../packages/date/src/lib/assertValidDateMonth.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAExD"}
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assertValidDateMonth = void 0;
4
- const isValidDateMonth_1 = require("./isValidDateMonth");
5
- /**
6
- * Asserts if the provided month is a valid date month.
7
- * @param month The month to be validated. Should be a number between 1 and 12.
8
- * @throws Will throw an error if the month is not a valid date month.
9
- * @example ```ts
10
- * assertValidDateMonth(13);;
11
- * //=> Error: Invalid month: 13.
12
- * assertValidDateMonth(1);;
13
- * //=> undefined
14
- * ```
15
- */
16
- function assertValidDateMonth(month) {
17
- if (!(0, isValidDateMonth_1.isValidDateMonth)(month))
18
- throw new Error(`Invalid month: ${month}.`);
19
- }
20
- exports.assertValidDateMonth = assertValidDateMonth;
21
- //# sourceMappingURL=assertValidDateMonth.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"assertValidDateMonth.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/assertValidDateMonth.ts"],"names":[],"mappings":";;;AAAA,yDAAqD;AAErD;;;;;;;;;;GAUG;AACH,SAAgB,oBAAoB,CAAC,KAAa;IAChD,IAAI,CAAC,IAAA,mCAAgB,EAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,KAAK,GAAG,CAAC,CAAA;AAC3E,CAAC;AAFD,oDAEC"}
@@ -1,14 +0,0 @@
1
- /**
2
- * Asserts that the provided year is a valid date year.
3
- * @param year The year to be validated
4
- * @throws Will throw an error if the year is not valid.
5
- * @example ```ts
6
- * assertValidDateYear(2020);;
7
- * //=> undefined
8
- * assertValidDateYear(10000);;
9
- * //=> Error: Invalid year: 10000.
10
- * ```
11
- * @returns void
12
- */
13
- export declare function assertValidDateYear(year: number): void;
14
- //# sourceMappingURL=assertValidDateYear.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"assertValidDateYear.d.ts","sourceRoot":"","sources":["../../../../../packages/date/src/lib/assertValidDateYear.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAEtD"}
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assertValidDateYear = void 0;
4
- const isValidDateYear_1 = require("./isValidDateYear");
5
- /**
6
- * Asserts that the provided year is a valid date year.
7
- * @param year The year to be validated
8
- * @throws Will throw an error if the year is not valid.
9
- * @example ```ts
10
- * assertValidDateYear(2020);;
11
- * //=> undefined
12
- * assertValidDateYear(10000);;
13
- * //=> Error: Invalid year: 10000.
14
- * ```
15
- * @returns void
16
- */
17
- function assertValidDateYear(year) {
18
- if (!(0, isValidDateYear_1.isValidDateYear)(year))
19
- throw new Error(`Invalid year: ${year}.`);
20
- }
21
- exports.assertValidDateYear = assertValidDateYear;
22
- //# sourceMappingURL=assertValidDateYear.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"assertValidDateYear.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/assertValidDateYear.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AAEnD;;;;;;;;;;;GAWG;AACH,SAAgB,mBAAmB,CAAC,IAAY;IAC9C,IAAI,CAAC,IAAA,iCAAe,EAAC,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,GAAG,CAAC,CAAA;AACvE,CAAC;AAFD,kDAEC"}
@@ -1,5 +0,0 @@
1
- /**
2
- * The number of days there are in each month (except leap year).
3
- */
4
- export declare const DAYS_IN_MONTH: number[];
5
- //# sourceMappingURL=DAYS_IN_MONTH.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DAYS_IN_MONTH.d.ts","sourceRoot":"","sources":["../../../../../../packages/date/src/lib/constants/DAYS_IN_MONTH.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,aAAa,UAAsD,CAAA"}
@@ -1,8 +0,0 @@
1
- "use strict";
2
- /**
3
- * The number of days there are in each month (except leap year).
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DAYS_IN_MONTH = void 0;
7
- exports.DAYS_IN_MONTH = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
8
- //# sourceMappingURL=DAYS_IN_MONTH.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DAYS_IN_MONTH.js","sourceRoot":"","sources":["../../../../../../packages/date/src/lib/constants/DAYS_IN_MONTH.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEU,QAAA,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"}
@@ -1,5 +0,0 @@
1
- /**
2
- * The number of milliseconds in a day.
3
- */
4
- export declare const MS_IN_DAY: number;
5
- //# sourceMappingURL=MS_IN_DAY.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MS_IN_DAY.d.ts","sourceRoot":"","sources":["../../../../../../packages/date/src/lib/constants/MS_IN_DAY.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,SAAS,QAAsB,CAAA"}
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MS_IN_DAY = void 0;
4
- /**
5
- * The number of milliseconds in a day.
6
- */
7
- exports.MS_IN_DAY = 1000 * 60 * 60 * 24;
8
- //# sourceMappingURL=MS_IN_DAY.js.map