@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
package/README.md CHANGED
@@ -1,39 +1,11 @@
1
- # @bemoje/date
2
- Date related tools/util.
1
+ # date
3
2
 
4
- ![GitHub Top Language](https://img.shields.io/github/languages/top/bemoje/https://github.com/bemoje/tsmono)
3
+ This library was generated with [Nx](https://nx.dev).
5
4
 
6
- ##### Github
7
- ![GitHub Last Commit](https://img.shields.io/github/last-commit/bemoje/https://github.com/bemoje/tsmono?color=red)
8
- ![GitHub Stars](https://img.shields.io/github/stars/bemoje/https://github.com/bemoje/tsmono)
9
- ![GitHub Forks](https://img.shields.io/github/forks/bemoje/https://github.com/bemoje/tsmono)
10
- ![GitHub Watchers](https://img.shields.io/github/watchers/bemoje/https://github.com/bemoje/tsmono)
11
- ![GitHub Repo Size](https://img.shields.io/github/repo-size/bemoje/https://github.com/bemoje/tsmono)
5
+ ## Building
12
6
 
13
- ##### NPM
14
- <span><a href="https://npmjs.org/@bemoje/date" title="View this project on NPM"><img src="https://img.shields.io/npm/v/@bemoje/date" alt="NPM Version" /></a></span>
15
- <span><a href="https://npmjs.org/@bemoje/date" title="NPM Downloads"><img src="https://img.shields.io/npm/dt/@bemoje/date" alt="NPM Downloads" /></a></span>
7
+ Run `nx build date` to build the library.
16
8
 
17
- ## Documentation
18
- [date docs](https://bemoje.github.io/tsmono/modules/date.html)
9
+ ## Running unit tests
19
10
 
20
- ##### Donate
21
- <span><a href="https://www.patreon.com/user?u=40752770" title="Donate using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon Donation" /></a></span>
22
-
23
- ## Installation
24
- This library is published in the NPM registry and can be installed using any compatible package manager.
25
-
26
- #### NPM
27
- ```sh
28
- npm install @bemoje/date
29
- ```
30
-
31
-
32
- ## Issues
33
- Please let me know of any bugs or [issues](https://github.com/bemoje/https://github.com/bemoje/tsmono/issues).
34
-
35
- ## Contribute
36
- Contributors are welcome to open a [pull request](https://github.com/bemoje/https://github.com/bemoje/tsmono/pulls).
37
-
38
- ## License
39
- Released under the [MIT License](./LICENSE).
11
+ Run `nx test date` to execute the unit tests via [Jest](https://jestjs.io).
package/package.json CHANGED
@@ -1,13 +1,9 @@
1
1
  {
2
2
  "name": "@bemoje/date",
3
- "version": "0.0.10",
3
+ "version": "0.1.0",
4
4
  "description": "Date related tools/util.",
5
- "main": "dist/index.cjs.js",
6
- "module": "dist/index.esm.js",
7
- "types": "dist/types/index.d.ts",
8
- "scripts": {
9
- "build": "rimraf dist && rollup --config ./rollup.config.js --bundleConfigAsCjs"
10
- },
5
+ "main": "./src/index.js",
6
+ "scripts": {},
11
7
  "author": {
12
8
  "name": "Benjamin Møller Jensen",
13
9
  "email": "bemoje@bemoje.net",
@@ -15,7 +11,9 @@
15
11
  },
16
12
  "license": "MIT",
17
13
  "keywords": [],
18
- "dependencies": {},
14
+ "dependencies": {
15
+ "tslib": "^2.3.0"
16
+ },
19
17
  "repository": {
20
18
  "type": "git",
21
19
  "url": "git+https://github.com/bemoje/tsmono.git"
@@ -27,5 +25,8 @@
27
25
  "bugs": {
28
26
  "url": "https://github.com/bemoje/tsmono/issues"
29
27
  },
30
- "homepage": "https://github.com/bemoje/tsmono"
31
- }
28
+ "homepage": "https://github.com/bemoje/tsmono",
29
+ "type": "commonjs",
30
+ "typings": "./src/index.d.ts",
31
+ "types": "./src/index.d.ts"
32
+ }
@@ -30,4 +30,3 @@ export * from './lib/prettyIsoDateString';
30
30
  export * from './lib/secondsSinceDate';
31
31
  export * from './lib/weeksSinceDate';
32
32
  export * from './lib/yearsSinceDate';
33
- //# sourceMappingURL=index.d.ts.map
package/src/index.js ADDED
@@ -0,0 +1,36 @@
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/MS_IN_DAY"), exports);
9
+ tslib_1.__exportStar(require("./lib/constants/MS_IN_HOUR"), exports);
10
+ tslib_1.__exportStar(require("./lib/constants/MS_IN_MINUTE"), exports);
11
+ tslib_1.__exportStar(require("./lib/constants/MS_IN_MONTH"), exports);
12
+ tslib_1.__exportStar(require("./lib/constants/MS_IN_SECOND"), exports);
13
+ tslib_1.__exportStar(require("./lib/constants/MS_IN_WEEK"), exports);
14
+ tslib_1.__exportStar(require("./lib/constants/MS_IN_YEAR"), exports);
15
+ tslib_1.__exportStar(require("./lib/dateDaysAgo"), exports);
16
+ tslib_1.__exportStar(require("./lib/dateWeekDayName"), exports);
17
+ tslib_1.__exportStar(require("./lib/daysSinceDate"), exports);
18
+ tslib_1.__exportStar(require("./lib/getCentury"), exports);
19
+ tslib_1.__exportStar(require("./lib/getCurrentYear"), exports);
20
+ tslib_1.__exportStar(require("./lib/hoursSinceDate"), exports);
21
+ tslib_1.__exportStar(require("./lib/isLeapYear"), exports);
22
+ tslib_1.__exportStar(require("./lib/isoDateTimestamp"), exports);
23
+ tslib_1.__exportStar(require("./lib/isoDateTimestampForFilename"), exports);
24
+ tslib_1.__exportStar(require("./lib/isValidDate"), exports);
25
+ tslib_1.__exportStar(require("./lib/isValidDateDay"), exports);
26
+ tslib_1.__exportStar(require("./lib/isValidDateMonth"), exports);
27
+ tslib_1.__exportStar(require("./lib/isValidDateYear"), exports);
28
+ tslib_1.__exportStar(require("./lib/minutesSinceDate"), exports);
29
+ tslib_1.__exportStar(require("./lib/monthsSinceDate"), exports);
30
+ tslib_1.__exportStar(require("./lib/msSinceDate"), exports);
31
+ tslib_1.__exportStar(require("./lib/numDaysInMonth"), exports);
32
+ tslib_1.__exportStar(require("./lib/prettyIsoDateString"), exports);
33
+ tslib_1.__exportStar(require("./lib/secondsSinceDate"), exports);
34
+ tslib_1.__exportStar(require("./lib/weeksSinceDate"), exports);
35
+ tslib_1.__exportStar(require("./lib/yearsSinceDate"), exports);
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/date/src/index.ts"],"names":[],"mappings":";;;AAAA,gEAAqC;AACrC,mEAAwC;AACxC,qEAA0C;AAC1C,oEAAyC;AACzC,oEAAyC;AACzC,qEAA0C;AAC1C,uEAA4C;AAC5C,sEAA2C;AAC3C,uEAA4C;AAC5C,qEAA0C;AAC1C,qEAA0C;AAC1C,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,gEAAqC;AACrC,4DAAiC;AACjC,+DAAoC;AACpC,oEAAyC;AACzC,iEAAsC;AACtC,+DAAoC;AACpC,+DAAoC"}
@@ -16,4 +16,3 @@
16
16
  * ```
17
17
  */
18
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
@@ -0,0 +1,36 @@
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
@@ -0,0 +1 @@
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"}
@@ -13,4 +13,3 @@
13
13
  * ```
14
14
  */
15
15
  export declare function assertValidDateDay(day: number, month: number, year?: number): void;
16
- //# sourceMappingURL=assertValidDateDay.d.ts.map
@@ -0,0 +1,24 @@
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
@@ -0,0 +1 @@
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"}
@@ -10,4 +10,3 @@
10
10
  * ```
11
11
  */
12
12
  export declare function assertValidDateMonth(month: number): void;
13
- //# sourceMappingURL=assertValidDateMonth.d.ts.map
@@ -0,0 +1,21 @@
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
@@ -0,0 +1 @@
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"}
@@ -11,4 +11,3 @@
11
11
  * @returns void
12
12
  */
13
13
  export declare function assertValidDateYear(year: number): void;
14
- //# sourceMappingURL=assertValidDateYear.d.ts.map
@@ -0,0 +1,22 @@
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
@@ -0,0 +1 @@
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"}
@@ -2,4 +2,3 @@
2
2
  * The number of milliseconds in a day.
3
3
  */
4
4
  export declare const MS_IN_DAY: number;
5
- //# sourceMappingURL=MS_IN_DAY.d.ts.map
@@ -0,0 +1,8 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MS_IN_DAY.js","sourceRoot":"","sources":["../../../../../../packages/date/src/lib/constants/MS_IN_DAY.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,SAAS,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAA"}
@@ -2,4 +2,3 @@
2
2
  * The number of milliseconds in an hour.
3
3
  */
4
4
  export declare const MS_IN_HOUR: number;
5
- //# sourceMappingURL=MS_IN_HOUR.d.ts.map
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MS_IN_HOUR = void 0;
4
+ /**
5
+ * The number of milliseconds in an hour.
6
+ */
7
+ exports.MS_IN_HOUR = 1000 * 60 * 60;
8
+ //# sourceMappingURL=MS_IN_HOUR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MS_IN_HOUR.js","sourceRoot":"","sources":["../../../../../../packages/date/src/lib/constants/MS_IN_HOUR.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,UAAU,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAA"}
@@ -2,4 +2,3 @@
2
2
  * The number of milliseconds in a minute.
3
3
  */
4
4
  export declare const MS_IN_MINUTE: number;
5
- //# sourceMappingURL=MS_IN_MINUTE.d.ts.map
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MS_IN_MINUTE = void 0;
4
+ /**
5
+ * The number of milliseconds in a minute.
6
+ */
7
+ exports.MS_IN_MINUTE = 1000 * 60;
8
+ //# sourceMappingURL=MS_IN_MINUTE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MS_IN_MINUTE.js","sourceRoot":"","sources":["../../../../../../packages/date/src/lib/constants/MS_IN_MINUTE.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,YAAY,GAAG,IAAI,GAAG,EAAE,CAAA"}
@@ -2,4 +2,3 @@
2
2
  * The number of milliseconds in a month.
3
3
  */
4
4
  export declare const MS_IN_MONTH: number;
5
- //# sourceMappingURL=MS_IN_MONTH.d.ts.map
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MS_IN_MONTH = void 0;
4
+ /**
5
+ * The number of milliseconds in a month.
6
+ */
7
+ exports.MS_IN_MONTH = (1000 * 60 * 60 * 24 * 365) / 12;
8
+ //# sourceMappingURL=MS_IN_MONTH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MS_IN_MONTH.js","sourceRoot":"","sources":["../../../../../../packages/date/src/lib/constants/MS_IN_MONTH.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,WAAW,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,GAAG,EAAE,CAAA"}
@@ -2,4 +2,3 @@
2
2
  * The number of milliseconds in a second.
3
3
  */
4
4
  export declare const MS_IN_SECOND = 1000;
5
- //# sourceMappingURL=MS_IN_SECOND.d.ts.map
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MS_IN_SECOND = void 0;
4
+ /**
5
+ * The number of milliseconds in a second.
6
+ */
7
+ exports.MS_IN_SECOND = 1000;
8
+ //# sourceMappingURL=MS_IN_SECOND.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MS_IN_SECOND.js","sourceRoot":"","sources":["../../../../../../packages/date/src/lib/constants/MS_IN_SECOND.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,YAAY,GAAG,IAAI,CAAA"}
@@ -2,4 +2,3 @@
2
2
  * The number of milliseconds in a week.
3
3
  */
4
4
  export declare const MS_IN_WEEK: number;
5
- //# sourceMappingURL=MS_IN_WEEK.d.ts.map
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MS_IN_WEEK = void 0;
4
+ /**
5
+ * The number of milliseconds in a week.
6
+ */
7
+ exports.MS_IN_WEEK = 1000 * 60 * 60 * 24 * 7;
8
+ //# sourceMappingURL=MS_IN_WEEK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MS_IN_WEEK.js","sourceRoot":"","sources":["../../../../../../packages/date/src/lib/constants/MS_IN_WEEK.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,UAAU,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA"}
@@ -2,4 +2,3 @@
2
2
  * The number of milliseconds in a year.
3
3
  */
4
4
  export declare const MS_IN_YEAR: number;
5
- //# sourceMappingURL=MS_IN_YEAR.d.ts.map
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MS_IN_YEAR = void 0;
4
+ /**
5
+ * The number of milliseconds in a year.
6
+ */
7
+ exports.MS_IN_YEAR = 1000 * 60 * 60 * 24 * 365;
8
+ //# sourceMappingURL=MS_IN_YEAR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MS_IN_YEAR.js","sourceRoot":"","sources":["../../../../../../packages/date/src/lib/constants/MS_IN_YEAR.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,UAAU,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA"}
@@ -8,4 +8,3 @@
8
8
  * ```
9
9
  */
10
10
  export declare function dateDaysAgo(days: number): Date;
11
- //# sourceMappingURL=dateDaysAgo.d.ts.map
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dateDaysAgo = void 0;
4
+ /**
5
+ * Returns a Date object representing a date that is a certain number of days in the past.
6
+ * @param days The number of days ago for the date to represent.
7
+ * @returns A Date object representing the date that is the specified number of days in the past.
8
+ * @example ```ts
9
+ * dateDaysAgo(5);;
10
+ * //=> result
11
+ * ```
12
+ */
13
+ function dateDaysAgo(days) {
14
+ const date = new Date();
15
+ date.setDate(date.getDate() - days);
16
+ return date;
17
+ }
18
+ exports.dateDaysAgo = dateDaysAgo;
19
+ //# sourceMappingURL=dateDaysAgo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dateDaysAgo.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/dateDaysAgo.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;GAQG;AACH,SAAgB,WAAW,CAAC,IAAY;IACtC,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAA;IACvB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAA;IACnC,OAAO,IAAI,CAAA;AACb,CAAC;AAJD,kCAIC"}
@@ -1,2 +1 @@
1
1
  export declare function dateWeekDayName(date: Date): string;
2
- //# sourceMappingURL=dateWeekDayName.d.ts.map
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dateWeekDayName = void 0;
4
+ function dateWeekDayName(date) {
5
+ return names[date.getDay()];
6
+ }
7
+ exports.dateWeekDayName = dateWeekDayName;
8
+ const names = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
9
+ //# sourceMappingURL=dateWeekDayName.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dateWeekDayName.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/dateWeekDayName.ts"],"names":[],"mappings":";;;AAAA,SAAgB,eAAe,CAAC,IAAU;IACxC,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;AAC7B,CAAC;AAFD,0CAEC;AAED,MAAM,KAAK,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAA"}
@@ -10,4 +10,3 @@
10
10
  * ```
11
11
  */
12
12
  export declare function daysSinceDate(date: Date | number): number;
13
- //# sourceMappingURL=daysSinceDate.d.ts.map
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.daysSinceDate = void 0;
4
+ const MS_IN_DAY_1 = require("./constants/MS_IN_DAY");
5
+ const msSinceDate_1 = require("./msSinceDate");
6
+ /**
7
+ * Calculates the number of days that have passed since the given date.
8
+ * @param date The date from which to calculate the number of days passed.
9
+ * @returns The number of days since the given date.
10
+ * @example ```ts
11
+ * new Date('2020-01-01');;
12
+ * //=> <date object>
13
+ * daysSinceDate(new Date('2020-01-01'));;
14
+ * //=> <number of days since 2020-01-01>
15
+ * ```
16
+ */
17
+ function daysSinceDate(date) {
18
+ return (0, msSinceDate_1.msSinceDate)(date) / MS_IN_DAY_1.MS_IN_DAY;
19
+ }
20
+ exports.daysSinceDate = daysSinceDate;
21
+ //# sourceMappingURL=daysSinceDate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daysSinceDate.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/daysSinceDate.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AACjD,+CAA2C;AAE3C;;;;;;;;;;GAUG;AACH,SAAgB,aAAa,CAAC,IAAmB;IAC/C,OAAO,IAAA,yBAAW,EAAC,IAAI,CAAC,GAAG,qBAAS,CAAA;AACtC,CAAC;AAFD,sCAEC"}
@@ -11,4 +11,3 @@
11
11
  * ```
12
12
  */
13
13
  export declare function getCentury(year: number): number;
14
- //# sourceMappingURL=getCentury.d.ts.map
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCentury = void 0;
4
+ const assertValidDateYear_1 = require("./assertValidDateYear");
5
+ /**
6
+ * This function takes a year as a parameter and returns the century it belongs to.
7
+ * @param year The year to determine the century for. Must be a valid year number.
8
+ * @returns The century the year belongs to.
9
+ * @throws Will throw an error if the year is not a valid number.
10
+ * @example ```ts
11
+ * getCentury(2000);;
12
+ * //=> 20
13
+ * getCentury(1899);;
14
+ * //=> 19
15
+ * ```
16
+ */
17
+ function getCentury(year) {
18
+ (0, assertValidDateYear_1.assertValidDateYear)(year);
19
+ return Math.floor(year / 100) + 1;
20
+ }
21
+ exports.getCentury = getCentury;
22
+ //# sourceMappingURL=getCentury.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCentury.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/getCentury.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAE3D;;;;;;;;;;;GAWG;AACH,SAAgB,UAAU,CAAC,IAAY;IACrC,IAAA,yCAAmB,EAAC,IAAI,CAAC,CAAA;IACzB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,CAAA;AACnC,CAAC;AAHD,gCAGC"}
@@ -8,4 +8,3 @@
8
8
  * ```
9
9
  */
10
10
  export declare function getCurrentYear(): number;
11
- //# sourceMappingURL=getCurrentYear.d.ts.map
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCurrentYear = void 0;
4
+ /**
5
+ * Returns the current year as a number.
6
+ * @remarks This function uses the `getUTCFullYear` method of the `Date` object to get the current year.
7
+ * @returns The current year as a number.
8
+ * @example ```ts
9
+ * getCurrentYear();;
10
+ * //=> 2022
11
+ * ```
12
+ */
13
+ function getCurrentYear() {
14
+ return new Date().getUTCFullYear();
15
+ }
16
+ exports.getCurrentYear = getCurrentYear;
17
+ //# sourceMappingURL=getCurrentYear.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCurrentYear.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/getCurrentYear.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;GAQG;AACH,SAAgB,cAAc;IAC5B,OAAO,IAAI,IAAI,EAAE,CAAC,cAAc,EAAE,CAAA;AACpC,CAAC;AAFD,wCAEC"}
@@ -10,4 +10,3 @@
10
10
  * ```
11
11
  */
12
12
  export declare function hoursSinceDate(date: Date | number): number;
13
- //# sourceMappingURL=hoursSinceDate.d.ts.map
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hoursSinceDate = void 0;
4
+ const MS_IN_HOUR_1 = require("./constants/MS_IN_HOUR");
5
+ const msSinceDate_1 = require("./msSinceDate");
6
+ /**
7
+ * Calculates the number of hours that have passed since the given date.
8
+ * @param date The date from which to calculate the number of hours passed.
9
+ * @returns The number of hours that have passed since the given date.
10
+ * @example ```ts
11
+ * new Date('2020-01-01T00:00:00Z');;
12
+ * //=> {date object}
13
+ * hoursSinceDate(new Date('2020-01-01T00:00:00Z'));;
14
+ * //=> {number of hours since January 1, 2020}
15
+ * ```
16
+ */
17
+ function hoursSinceDate(date) {
18
+ return (0, msSinceDate_1.msSinceDate)(date) / MS_IN_HOUR_1.MS_IN_HOUR;
19
+ }
20
+ exports.hoursSinceDate = hoursSinceDate;
21
+ //# sourceMappingURL=hoursSinceDate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hoursSinceDate.js","sourceRoot":"","sources":["../../../../../packages/date/src/lib/hoursSinceDate.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,+CAA2C;AAE3C;;;;;;;;;;GAUG;AACH,SAAgB,cAAc,CAAC,IAAmB;IAChD,OAAO,IAAA,yBAAW,EAAC,IAAI,CAAC,GAAG,uBAAU,CAAA;AACvC,CAAC;AAFD,wCAEC"}
@@ -13,4 +13,3 @@
13
13
  * ```
14
14
  */
15
15
  export declare function isLeapYear(year: number): boolean;
16
- //# sourceMappingURL=isLeapYear.d.ts.map