@thisisagile/easy 18.10.0 → 18.11.1

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 (177) hide show
  1. package/README.md +1 -1
  2. package/dist/{chunk-WM6VMJHW.mjs → chunk-3VDUMU5P.mjs} +2 -2
  3. package/dist/{chunk-TCJCHCJV.mjs → chunk-4AEHKWWI.mjs} +2 -2
  4. package/dist/{chunk-RVRWRUR4.mjs → chunk-4FXDIYQT.mjs} +3 -3
  5. package/dist/{chunk-HFGH75UW.mjs → chunk-4NRVIWNE.mjs} +3 -3
  6. package/dist/{chunk-LQYQISSV.mjs → chunk-4UKOKM72.mjs} +3 -3
  7. package/dist/{chunk-26QCRW4Q.mjs → chunk-52VT3UEM.mjs} +3 -3
  8. package/dist/{chunk-T32HGK7R.mjs → chunk-5VP4WNID.mjs} +5 -5
  9. package/dist/{chunk-QMXVI6ZP.mjs → chunk-5WGOB7QF.mjs} +2 -2
  10. package/dist/{chunk-VFHSP7MK.mjs → chunk-6FUVIZYN.mjs} +2 -2
  11. package/dist/{chunk-RO74JHB7.mjs → chunk-BODG3KPC.mjs} +3 -3
  12. package/dist/{chunk-AU2A23B4.mjs → chunk-BSN5WGZ6.mjs} +3 -3
  13. package/dist/{chunk-HCXQZYTR.mjs → chunk-DODBPVV5.mjs} +7 -7
  14. package/dist/{chunk-SMM62THT.mjs → chunk-EFFUHXDK.mjs} +4 -4
  15. package/dist/{chunk-OWAUGSJI.mjs → chunk-EGGEJRWA.mjs} +4 -4
  16. package/dist/{chunk-RDA6XPHT.mjs → chunk-EHVMIXKR.mjs} +4 -4
  17. package/dist/chunk-GRDUTNMZ.mjs +272 -0
  18. package/dist/chunk-GRDUTNMZ.mjs.map +1 -0
  19. package/dist/{chunk-2EXRHTUE.mjs → chunk-HAGNDCSR.mjs} +3 -3
  20. package/dist/{chunk-IAHI5LT3.mjs → chunk-HN3HW22I.mjs} +2 -2
  21. package/dist/{chunk-6Q7FX3KI.mjs → chunk-I2VWZJ2K.mjs} +3 -3
  22. package/dist/{chunk-VAQAXKX2.mjs → chunk-IMJHOYU3.mjs} +2 -2
  23. package/dist/{chunk-YJ7BQOWU.mjs → chunk-J2RU23YZ.mjs} +3 -3
  24. package/dist/{chunk-XRLLGVKR.mjs → chunk-KMEBQTNE.mjs} +2 -2
  25. package/dist/{chunk-ACTQARWL.mjs → chunk-KXYGCS7S.mjs} +2 -2
  26. package/dist/{chunk-CCQJX6G6.mjs → chunk-M7MW5CXO.mjs} +2 -2
  27. package/dist/{chunk-4DUWX4YU.mjs → chunk-M7OD5QSB.mjs} +3 -3
  28. package/dist/{chunk-37QC66CS.mjs → chunk-MJAB7NZV.mjs} +2 -2
  29. package/dist/{chunk-VAJ64J43.mjs → chunk-NNA77YYC.mjs} +1 -1
  30. package/dist/{chunk-VAJ64J43.mjs.map → chunk-NNA77YYC.mjs.map} +1 -1
  31. package/dist/{chunk-GDLSJ5P4.mjs → chunk-NQYUWVJT.mjs} +3 -3
  32. package/dist/{chunk-BZLVW3TO.mjs → chunk-P4XVLBXB.mjs} +3 -3
  33. package/dist/{chunk-GMSPATXC.mjs → chunk-PNSMLGOA.mjs} +2 -2
  34. package/dist/{chunk-ZQXTKDWH.mjs → chunk-RF23BV6J.mjs} +2 -2
  35. package/dist/{chunk-YW4JACEA.mjs → chunk-S3NSPQ7M.mjs} +2 -2
  36. package/dist/{chunk-4SM5CZ36.mjs → chunk-TNLJ45P5.mjs} +2 -2
  37. package/dist/{chunk-ZTQEZ5BV.mjs → chunk-UG3NG43J.mjs} +4 -4
  38. package/dist/{chunk-UCDGCXSA.mjs → chunk-V5TW476J.mjs} +4 -4
  39. package/dist/{chunk-R3YY4LWL.mjs → chunk-WLTKHBFQ.mjs} +4 -4
  40. package/dist/{chunk-T7LION5W.mjs → chunk-XMTKVPNV.mjs} +2 -2
  41. package/dist/{chunk-2TAWQZJG.mjs → chunk-XVZYKKLD.mjs} +2 -2
  42. package/dist/{chunk-DXM52QBL.mjs → chunk-YDYQTX4H.mjs} +5 -5
  43. package/dist/{chunk-4S6TVJDY.mjs → chunk-YRVCY3KC.mjs} +4 -4
  44. package/dist/{chunk-ULVLP74J.mjs → chunk-YYXHD3PC.mjs} +2 -2
  45. package/dist/{chunk-D5C4U6JT.mjs → chunk-ZO6LH5HU.mjs} +2 -2
  46. package/dist/data/Condition.mjs +6 -6
  47. package/dist/data/Database.mjs +4 -4
  48. package/dist/data/Field.mjs +7 -7
  49. package/dist/data/InMemoryGateway.mjs +5 -5
  50. package/dist/domain/Audit.mjs +9 -9
  51. package/dist/domain/Child.mjs +8 -8
  52. package/dist/domain/DateTime.d.ts +7 -5
  53. package/dist/domain/DateTime.mjs +5 -5
  54. package/dist/domain/Entity.mjs +11 -11
  55. package/dist/domain/Repo.mjs +5 -5
  56. package/dist/domain/Struct.mjs +5 -5
  57. package/dist/domain/Typo.mjs +5 -5
  58. package/dist/http/CacheControl.mjs +5 -5
  59. package/dist/http/ContentType.mjs +4 -4
  60. package/dist/http/HttpStatus.mjs +4 -4
  61. package/dist/http/HttpVerb.mjs +4 -4
  62. package/dist/http/LocalRequestStore.mjs +3 -3
  63. package/dist/http/RequestOptions.mjs +6 -6
  64. package/dist/http/RestResult.mjs +5 -5
  65. package/dist/http/toResponse.mjs +6 -6
  66. package/dist/index.js +165 -33
  67. package/dist/index.js.map +1 -1
  68. package/dist/process/App.mjs +4 -4
  69. package/dist/process/Manage.mjs +5 -5
  70. package/dist/process/Scope.mjs +4 -4
  71. package/dist/process/Search.mjs +5 -5
  72. package/dist/process/UseCase.mjs +3 -3
  73. package/dist/resources/Req.mjs +4 -4
  74. package/dist/security/Jwt.mjs +2 -2
  75. package/dist/services/Api.mjs +14 -14
  76. package/dist/services/ApiGateway.mjs +17 -17
  77. package/dist/services/AxiosProvider.mjs +12 -12
  78. package/dist/services/MappedRouteGateway.mjs +22 -22
  79. package/dist/services/RouteGateway.mjs +18 -18
  80. package/dist/services/ViewRouteGateway.mjs +20 -20
  81. package/dist/sql/Clause.mjs +3 -3
  82. package/dist/sql/Column.mjs +7 -7
  83. package/dist/sql/Count.mjs +6 -6
  84. package/dist/sql/Delete.mjs +5 -5
  85. package/dist/sql/Insert.mjs +7 -7
  86. package/dist/sql/Select.mjs +5 -5
  87. package/dist/sql/SqlQuery.mjs +4 -4
  88. package/dist/sql/Table.mjs +17 -17
  89. package/dist/sql/TableGateway.mjs +5 -5
  90. package/dist/sql/Update.mjs +7 -7
  91. package/dist/types/Builder.mjs +1 -1
  92. package/dist/types/Cache.mjs +3 -3
  93. package/dist/types/CacheAge.mjs +5 -5
  94. package/dist/types/Case.mjs +3 -3
  95. package/dist/types/Context.mjs +3 -3
  96. package/dist/types/Enum.mjs +3 -3
  97. package/dist/types/Environment.mjs +3 -3
  98. package/dist/types/Exception.mjs +3 -3
  99. package/dist/types/Gateway.mjs +4 -4
  100. package/dist/types/Id.mjs +3 -3
  101. package/dist/types/IsEqual.mjs +3 -3
  102. package/dist/types/Json.mjs +4 -4
  103. package/dist/types/List.mjs +3 -3
  104. package/dist/types/Meta.mjs +3 -3
  105. package/dist/types/Number.mjs +4 -4
  106. package/dist/types/Object.mjs +3 -3
  107. package/dist/types/PageList.mjs +4 -4
  108. package/dist/types/Parser.mjs +3 -3
  109. package/dist/types/Repository.mjs +4 -4
  110. package/dist/types/Result.mjs +3 -3
  111. package/dist/types/Results.mjs +3 -3
  112. package/dist/types/Tag.mjs +3 -3
  113. package/dist/types/Template.mjs +3 -3
  114. package/dist/types/Text.d.ts +1 -0
  115. package/dist/types/Text.mjs +1 -1
  116. package/dist/types/ToText.mjs +3 -3
  117. package/dist/types/Try.mjs +3 -3
  118. package/dist/types/Uri.mjs +3 -3
  119. package/dist/types/Uuid.mjs +2 -2
  120. package/dist/types/Value.mjs +2 -2
  121. package/dist/utils/Convert.mjs +2 -2
  122. package/dist/utils/If.mjs +3 -3
  123. package/dist/utils/Mapper.mjs +7 -7
  124. package/dist/utils/Period.mjs +5 -5
  125. package/dist/utils/Promise.mjs +3 -3
  126. package/dist/utils/Property.mjs +3 -3
  127. package/dist/utils/Seconds.mjs +4 -4
  128. package/dist/utils/Sentence.mjs +3 -3
  129. package/dist/utils/View.mjs +6 -6
  130. package/dist/validation/Contraints.mjs +4 -4
  131. package/dist/validation/Validate.mjs +3 -3
  132. package/dist/validation/When.mjs +3 -3
  133. package/package.json +9 -4
  134. package/src/domain/DateTime.ts +206 -40
  135. package/src/types/Text.ts +2 -0
  136. package/dist/chunk-XKRR6345.mjs +0 -140
  137. package/dist/chunk-XKRR6345.mjs.map +0 -1
  138. /package/dist/{chunk-WM6VMJHW.mjs.map → chunk-3VDUMU5P.mjs.map} +0 -0
  139. /package/dist/{chunk-TCJCHCJV.mjs.map → chunk-4AEHKWWI.mjs.map} +0 -0
  140. /package/dist/{chunk-RVRWRUR4.mjs.map → chunk-4FXDIYQT.mjs.map} +0 -0
  141. /package/dist/{chunk-HFGH75UW.mjs.map → chunk-4NRVIWNE.mjs.map} +0 -0
  142. /package/dist/{chunk-LQYQISSV.mjs.map → chunk-4UKOKM72.mjs.map} +0 -0
  143. /package/dist/{chunk-26QCRW4Q.mjs.map → chunk-52VT3UEM.mjs.map} +0 -0
  144. /package/dist/{chunk-T32HGK7R.mjs.map → chunk-5VP4WNID.mjs.map} +0 -0
  145. /package/dist/{chunk-QMXVI6ZP.mjs.map → chunk-5WGOB7QF.mjs.map} +0 -0
  146. /package/dist/{chunk-VFHSP7MK.mjs.map → chunk-6FUVIZYN.mjs.map} +0 -0
  147. /package/dist/{chunk-RO74JHB7.mjs.map → chunk-BODG3KPC.mjs.map} +0 -0
  148. /package/dist/{chunk-AU2A23B4.mjs.map → chunk-BSN5WGZ6.mjs.map} +0 -0
  149. /package/dist/{chunk-HCXQZYTR.mjs.map → chunk-DODBPVV5.mjs.map} +0 -0
  150. /package/dist/{chunk-SMM62THT.mjs.map → chunk-EFFUHXDK.mjs.map} +0 -0
  151. /package/dist/{chunk-OWAUGSJI.mjs.map → chunk-EGGEJRWA.mjs.map} +0 -0
  152. /package/dist/{chunk-RDA6XPHT.mjs.map → chunk-EHVMIXKR.mjs.map} +0 -0
  153. /package/dist/{chunk-2EXRHTUE.mjs.map → chunk-HAGNDCSR.mjs.map} +0 -0
  154. /package/dist/{chunk-IAHI5LT3.mjs.map → chunk-HN3HW22I.mjs.map} +0 -0
  155. /package/dist/{chunk-6Q7FX3KI.mjs.map → chunk-I2VWZJ2K.mjs.map} +0 -0
  156. /package/dist/{chunk-VAQAXKX2.mjs.map → chunk-IMJHOYU3.mjs.map} +0 -0
  157. /package/dist/{chunk-YJ7BQOWU.mjs.map → chunk-J2RU23YZ.mjs.map} +0 -0
  158. /package/dist/{chunk-XRLLGVKR.mjs.map → chunk-KMEBQTNE.mjs.map} +0 -0
  159. /package/dist/{chunk-ACTQARWL.mjs.map → chunk-KXYGCS7S.mjs.map} +0 -0
  160. /package/dist/{chunk-CCQJX6G6.mjs.map → chunk-M7MW5CXO.mjs.map} +0 -0
  161. /package/dist/{chunk-4DUWX4YU.mjs.map → chunk-M7OD5QSB.mjs.map} +0 -0
  162. /package/dist/{chunk-37QC66CS.mjs.map → chunk-MJAB7NZV.mjs.map} +0 -0
  163. /package/dist/{chunk-GDLSJ5P4.mjs.map → chunk-NQYUWVJT.mjs.map} +0 -0
  164. /package/dist/{chunk-BZLVW3TO.mjs.map → chunk-P4XVLBXB.mjs.map} +0 -0
  165. /package/dist/{chunk-GMSPATXC.mjs.map → chunk-PNSMLGOA.mjs.map} +0 -0
  166. /package/dist/{chunk-ZQXTKDWH.mjs.map → chunk-RF23BV6J.mjs.map} +0 -0
  167. /package/dist/{chunk-YW4JACEA.mjs.map → chunk-S3NSPQ7M.mjs.map} +0 -0
  168. /package/dist/{chunk-4SM5CZ36.mjs.map → chunk-TNLJ45P5.mjs.map} +0 -0
  169. /package/dist/{chunk-ZTQEZ5BV.mjs.map → chunk-UG3NG43J.mjs.map} +0 -0
  170. /package/dist/{chunk-UCDGCXSA.mjs.map → chunk-V5TW476J.mjs.map} +0 -0
  171. /package/dist/{chunk-R3YY4LWL.mjs.map → chunk-WLTKHBFQ.mjs.map} +0 -0
  172. /package/dist/{chunk-T7LION5W.mjs.map → chunk-XMTKVPNV.mjs.map} +0 -0
  173. /package/dist/{chunk-2TAWQZJG.mjs.map → chunk-XVZYKKLD.mjs.map} +0 -0
  174. /package/dist/{chunk-DXM52QBL.mjs.map → chunk-YDYQTX4H.mjs.map} +0 -0
  175. /package/dist/{chunk-4S6TVJDY.mjs.map → chunk-YRVCY3KC.mjs.map} +0 -0
  176. /package/dist/{chunk-ULVLP74J.mjs.map → chunk-YYXHD3PC.mjs.map} +0 -0
  177. /package/dist/{chunk-D5C4U6JT.mjs.map → chunk-ZO6LH5HU.mjs.map} +0 -0
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  text
3
- } from "../chunk-6Q7FX3KI.mjs";
3
+ } from "../chunk-I2VWZJ2K.mjs";
4
4
  import "../chunk-SSROJBD5.mjs";
5
5
  import "../chunk-EBIF6AMC.mjs";
6
6
  import "../chunk-KCY4RPFR.mjs";
7
- import "../chunk-YW4JACEA.mjs";
8
- import "../chunk-VAJ64J43.mjs";
7
+ import "../chunk-S3NSPQ7M.mjs";
8
+ import "../chunk-NNA77YYC.mjs";
9
9
  import "../chunk-SJGQU3OG.mjs";
10
10
  import "../chunk-D5IYAIMK.mjs";
11
11
  import "../chunk-PF7HDF6B.mjs";
@@ -4,15 +4,15 @@ import {
4
4
  toViewer,
5
5
  view,
6
6
  views
7
- } from "../chunk-RDA6XPHT.mjs";
8
- import "../chunk-WM6VMJHW.mjs";
9
- import "../chunk-GMSPATXC.mjs";
10
- import "../chunk-6Q7FX3KI.mjs";
7
+ } from "../chunk-EHVMIXKR.mjs";
8
+ import "../chunk-3VDUMU5P.mjs";
9
+ import "../chunk-PNSMLGOA.mjs";
10
+ import "../chunk-I2VWZJ2K.mjs";
11
11
  import "../chunk-SSROJBD5.mjs";
12
12
  import "../chunk-EBIF6AMC.mjs";
13
13
  import "../chunk-KCY4RPFR.mjs";
14
- import "../chunk-YW4JACEA.mjs";
15
- import "../chunk-VAJ64J43.mjs";
14
+ import "../chunk-S3NSPQ7M.mjs";
15
+ import "../chunk-NNA77YYC.mjs";
16
16
  import "../chunk-SJGQU3OG.mjs";
17
17
  import "../chunk-D5IYAIMK.mjs";
18
18
  import "../chunk-PF7HDF6B.mjs";
@@ -18,14 +18,14 @@ import {
18
18
  required,
19
19
  rule,
20
20
  valid
21
- } from "../chunk-4SM5CZ36.mjs";
21
+ } from "../chunk-TNLJ45P5.mjs";
22
22
  import "../chunk-ADJAEGCT.mjs";
23
- import "../chunk-6Q7FX3KI.mjs";
23
+ import "../chunk-I2VWZJ2K.mjs";
24
24
  import "../chunk-SSROJBD5.mjs";
25
25
  import "../chunk-EBIF6AMC.mjs";
26
26
  import "../chunk-KCY4RPFR.mjs";
27
- import "../chunk-YW4JACEA.mjs";
28
- import "../chunk-VAJ64J43.mjs";
27
+ import "../chunk-S3NSPQ7M.mjs";
28
+ import "../chunk-NNA77YYC.mjs";
29
29
  import "../chunk-SJGQU3OG.mjs";
30
30
  import "../chunk-D5IYAIMK.mjs";
31
31
  import "../chunk-PF7HDF6B.mjs";
@@ -3,12 +3,12 @@ import {
3
3
  isValid,
4
4
  validate,
5
5
  validateReject
6
- } from "../chunk-6Q7FX3KI.mjs";
6
+ } from "../chunk-I2VWZJ2K.mjs";
7
7
  import "../chunk-SSROJBD5.mjs";
8
8
  import "../chunk-EBIF6AMC.mjs";
9
9
  import "../chunk-KCY4RPFR.mjs";
10
- import "../chunk-YW4JACEA.mjs";
11
- import "../chunk-VAJ64J43.mjs";
10
+ import "../chunk-S3NSPQ7M.mjs";
11
+ import "../chunk-NNA77YYC.mjs";
12
12
  import "../chunk-SJGQU3OG.mjs";
13
13
  import "../chunk-D5IYAIMK.mjs";
14
14
  import "../chunk-PF7HDF6B.mjs";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  When,
3
3
  when
4
- } from "../chunk-6Q7FX3KI.mjs";
4
+ } from "../chunk-I2VWZJ2K.mjs";
5
5
  import "../chunk-SSROJBD5.mjs";
6
6
  import "../chunk-EBIF6AMC.mjs";
7
7
  import "../chunk-KCY4RPFR.mjs";
8
- import "../chunk-YW4JACEA.mjs";
9
- import "../chunk-VAJ64J43.mjs";
8
+ import "../chunk-S3NSPQ7M.mjs";
9
+ import "../chunk-NNA77YYC.mjs";
10
10
  import "../chunk-SJGQU3OG.mjs";
11
11
  import "../chunk-D5IYAIMK.mjs";
12
12
  import "../chunk-PF7HDF6B.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thisisagile/easy",
3
- "version": "18.10.0",
3
+ "version": "18.11.1",
4
4
  "description": "Straightforward library for building domain-driven microservice architectures",
5
5
  "author": "Sander Hoogendoorn",
6
6
  "license": "MIT",
@@ -25,7 +25,13 @@
25
25
  "test": "yarn g:jest --coverage",
26
26
  "prepack": "yarn g:copy-readme"
27
27
  },
28
- "sideEffects": false,
28
+ "sideEffects": [
29
+ "./src/domain/DateTime.ts",
30
+ "./src/types/Meta.ts",
31
+ "./dist/domain/DateTime.*",
32
+ "./dist/types/Meta.*",
33
+ "./dist/index.js"
34
+ ],
29
35
  "files": [
30
36
  "dist",
31
37
  "src"
@@ -36,15 +42,14 @@
36
42
  "devDependencies": {
37
43
  "@thisisagile/easy-test": "*",
38
44
  "@types/form-urlencoded": "^4.4.2",
39
- "@types/luxon": "3.4.2",
40
45
  "@types/validator": "^13.12.2"
41
46
  },
42
47
  "dependencies": {
43
48
  "@types/uuid": "^9.0.8",
44
49
  "axios": "^1.7.9",
50
+ "dayjs": "^1.11.21",
45
51
  "form-urlencoded": "^6.1.5",
46
52
  "jwt-decode": "^4.0.0",
47
- "luxon": "^3.5.0",
48
53
  "reflect-metadata": "^0.2.2",
49
54
  "uuid": "^9.0.1",
50
55
  "validator": "^13.12.0"
@@ -1,7 +1,16 @@
1
- import { DateTime as LuxonDateTime, DateTimeUnit as LuxonDateTimeUnit, DurationUnit as LuxonDurationUnit, Settings } from 'luxon';
1
+ import dayjs, { Dayjs, ManipulateType, OpUnitType, QUnitType } from 'dayjs';
2
+ import advancedFormat from 'dayjs/plugin/advancedFormat';
3
+ import customParseFormat from 'dayjs/plugin/customParseFormat';
4
+ import isoWeek from 'dayjs/plugin/isoWeek';
5
+ import localizedFormat from 'dayjs/plugin/localizedFormat';
6
+ import quarterOfYear from 'dayjs/plugin/quarterOfYear';
7
+ import relativeTime from 'dayjs/plugin/relativeTime';
8
+ import timezone from 'dayjs/plugin/timezone';
9
+ import utc from 'dayjs/plugin/utc';
10
+ import 'dayjs/locale/de';
11
+ import 'dayjs/locale/nl';
2
12
  import { Value } from '../types/Value';
3
13
  import { Optional } from '../types/Types';
4
- import { choose } from '../types/Case';
5
14
  import { isDefined, isNumber, isString } from '../types/Is';
6
15
  import { isDate } from '../types/IsDate';
7
16
  import { isA } from '../types/IsA';
@@ -10,11 +19,30 @@ import { JsonValue } from '../types/Json';
10
19
  import { seconds } from '../utils/Seconds';
11
20
  import { tryTo } from '../types/Try';
12
21
  import { use } from '../types/Constructor';
22
+ import { choose } from '../types/Case';
13
23
 
14
- Settings.defaultZone = 'utc';
15
-
16
- export type DateTimeUnit = LuxonDateTimeUnit;
17
- export type DurationUnit = LuxonDurationUnit;
24
+ dayjs.extend(utc);
25
+ dayjs.extend(timezone);
26
+ dayjs.extend(customParseFormat);
27
+ dayjs.extend(localizedFormat);
28
+ dayjs.extend(relativeTime);
29
+ dayjs.extend(isoWeek);
30
+ dayjs.extend(advancedFormat);
31
+ dayjs.extend(quarterOfYear);
32
+ dayjs.tz.setDefault('UTC');
33
+
34
+ export type DateTimeUnit = 'year' | 'quarter' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond';
35
+ export type DurationUnit =
36
+ | DateTimeUnit
37
+ | 'years'
38
+ | 'quarters'
39
+ | 'months'
40
+ | 'weeks'
41
+ | 'days'
42
+ | 'hours'
43
+ | 'minutes'
44
+ | 'seconds'
45
+ | 'milliseconds';
18
46
  export type Duration = Partial<Record<DurationUnit, number>>;
19
47
 
20
48
  export type DiffOptions = {
@@ -23,30 +51,65 @@ export type DiffOptions = {
23
51
 
24
52
  export type DatetimeInput = string | number | Date | DateTime | null;
25
53
 
54
+ type DateTimeConstructorInput = DatetimeInput | Dayjs;
55
+ type ZonedDayjs = Dayjs & { $x?: { $timezone?: string } };
56
+
57
+ const invalidDate = dayjs.utc(Number.NaN);
58
+ const isDayjs = (value: unknown): value is Dayjs => dayjs.isDayjs(value);
59
+ const isoFormats = [
60
+ 'YYYY-MM-DD',
61
+ 'YYYY-MM-DDTHH:mm',
62
+ 'YYYY-MM-DDTHH:mm:ss',
63
+ 'YYYY-MM-DDTHH:mm:ss.SSS',
64
+ 'YYYY-MM-DDTHH:mm[Z]',
65
+ 'YYYY-MM-DDTHH:mm:ss[Z]',
66
+ 'YYYY-MM-DDTHH:mm:ss.SSS[Z]',
67
+ 'YYYY-MM-DDTHH:mmZ',
68
+ 'YYYY-MM-DDTHH:mmZZ',
69
+ 'YYYY-MM-DDTHH:mm:ssZ',
70
+ 'YYYY-MM-DDTHH:mm:ssZZ',
71
+ 'YYYY-MM-DDTHH:mm:ss.SSSZ',
72
+ 'YYYY-MM-DDTHH:mm:ss.SSSZZ',
73
+ ];
74
+ const fixedUnitMilliseconds: Partial<Record<DurationUnit, number>> = {
75
+ day: 86400000,
76
+ days: 86400000,
77
+ week: 604800000,
78
+ weeks: 604800000,
79
+ };
80
+ const calendarUnitMonths: Partial<Record<DurationUnit, number>> = {
81
+ month: 1,
82
+ months: 1,
83
+ quarter: 3,
84
+ quarters: 3,
85
+ year: 12,
86
+ years: 12,
87
+ };
88
+
26
89
  export class DateTime extends Value<Optional<string>> {
27
- protected readonly luxon: LuxonDateTime;
90
+ protected readonly date: Dayjs;
28
91
 
29
92
  constructor(value?: DatetimeInput);
30
93
  constructor(value?: string, format?: string);
31
- constructor(value?: DatetimeInput, format?: string) {
32
- const luxon = choose(value)
33
- .type(isString, v => (format ? LuxonDateTime.fromFormat(v, format, { setZone: true }) : LuxonDateTime.fromISO(v, { setZone: true })))
34
- .type(isNumber, v => LuxonDateTime.fromMillis(v))
35
- .type(isDate, v => LuxonDateTime.fromJSDate(v))
36
- .type(isDateTime, v => v.luxon)
37
- // Allow constructing with LuxonDateTime without exposing types
38
- .else(value instanceof LuxonDateTime ? value : LuxonDateTime.fromISO(undefined as any));
39
-
40
- super(luxon.toISO() ?? undefined);
41
- this.luxon = luxon;
94
+ constructor(value?: DateTimeConstructorInput, format?: string) {
95
+ const date = choose<DateTimeConstructorInput | undefined>(value)
96
+ .type(isDayjs, date => date)
97
+ .type(isDateTime, dateTime => dateTime.date)
98
+ .type(isNumber, timestamp => dayjs.utc(timestamp))
99
+ .type(isDate, date => dayjs.utc(date))
100
+ .type(isString, string => (string === '' ? invalidDate : format ? parseFormatted(string, format) : parseIso(string)))
101
+ .else(invalidDate);
102
+
103
+ super(date.isValid() ? formatDateTime(date) : undefined);
104
+ this.date = date;
42
105
  }
43
106
 
44
107
  static get now(): DateTime {
45
- return new DateTime(LuxonDateTime.utc() as any);
108
+ return fromDayjs(dayjs.utc(Date.now()));
46
109
  }
47
110
 
48
111
  get isValid(): boolean {
49
- return isDefined(this.value) && this.utc.isValid;
112
+ return isDefined(this.value) && this.date.isValid();
50
113
  }
51
114
 
52
115
  /**
@@ -72,8 +135,8 @@ export class DateTime extends Value<Optional<string>> {
72
135
  return this.withZone('Europe/Warsaw');
73
136
  }
74
137
 
75
- protected get utc(): LuxonDateTime {
76
- return this.luxon.setZone('utc');
138
+ protected get utc(): Dayjs {
139
+ return this.date.utc();
77
140
  }
78
141
 
79
142
  from(locale?: string): string;
@@ -85,23 +148,23 @@ export class DateTime extends Value<Optional<string>> {
85
148
  use((isString(dateOrLocale) ? dateOrLocale : maybeLocale) ?? 'en', locale =>
86
149
  ifDefined(
87
150
  isA<DateTime>(dateOrLocale) ? dateOrLocale : undefined,
88
- d => this.utc.setLocale(locale).toRelative({ base: d.utc }),
89
- () => this.utc.setLocale(locale).toRelative()
151
+ d => this.utc.locale(toDayjsLocale(locale)).from(d.utc),
152
+ () => this.utc.locale(toDayjsLocale(locale)).from(dayjs.utc(Date.now()))
90
153
  )
91
154
  ) ?? ''
92
155
  );
93
156
  }
94
157
 
95
158
  isAfter(dt: DateTime): boolean {
96
- return this.utc > dt.utc;
159
+ return this.utc.valueOf() > dt.utc.valueOf();
97
160
  }
98
161
 
99
162
  isBefore(dt: DateTime): boolean {
100
- return this.utc < dt.utc;
163
+ return this.utc.valueOf() < dt.utc.valueOf();
101
164
  }
102
165
 
103
166
  equals(dt: DateTime): boolean {
104
- return this.utc.hasSame(dt.utc, 'millisecond');
167
+ return this.utc.valueOf() === dt.utc.valueOf();
105
168
  }
106
169
 
107
170
  add(n: number, unit?: DurationUnit): DateTime;
@@ -109,7 +172,7 @@ export class DateTime extends Value<Optional<string>> {
109
172
  add(duration: Duration): DateTime;
110
173
 
111
174
  add(n: number | Duration, unit: DurationUnit = 'day'): DateTime {
112
- return new DateTime(this.luxon.plus(isNumber(n) ? { [unit]: n } : n) as any);
175
+ return fromDayjs(change(this.date, n, unit, 'add'));
113
176
  }
114
177
 
115
178
  subtract(n: number, unit?: DurationUnit): DateTime;
@@ -117,27 +180,28 @@ export class DateTime extends Value<Optional<string>> {
117
180
  subtract(duration: Duration): DateTime;
118
181
 
119
182
  subtract(n: number | Duration, unit: DurationUnit = 'day'): DateTime {
120
- return new DateTime(this.luxon.minus(isNumber(n) ? { [unit]: n } : n) as any);
183
+ return fromDayjs(change(this.date, n, unit, 'subtract'));
121
184
  }
122
185
 
123
186
  diff(other: DateTime, unit: DateTimeUnit = 'day', opts?: DiffOptions): number {
124
- return Math[opts?.rounding ?? 'floor'](this.utc.diff(other.utc).as(unit));
187
+ return Math[opts?.rounding ?? 'floor'](this.utc.diff(other.utc, toDayjsUnit(unit) as QUnitType | OpUnitType, true));
125
188
  }
126
189
 
127
190
  startOf(unit: DateTimeUnit = 'day'): DateTime {
128
- return new DateTime(this.luxon.startOf(unit) as any);
191
+ return fromDayjs(this.date.startOf(toDayjsBoundaryUnit(unit)));
129
192
  }
130
193
 
131
194
  endOf(unit: DateTimeUnit = 'day'): DateTime {
132
- return new DateTime(this.luxon.endOf(unit) as any);
195
+ return fromDayjs(this.date.endOf(toDayjsBoundaryUnit(unit)));
133
196
  }
134
197
 
135
198
  isWeekend(): boolean {
136
- return this.luxon.isWeekend;
199
+ const day = this.date.day();
200
+ return day === 0 || day === 6;
137
201
  }
138
202
 
139
203
  withZone(zone: string): DateTime {
140
- return new DateTime(this.luxon.setZone(zone) as any);
204
+ return fromDayjs(this.date.tz(zone));
141
205
  }
142
206
 
143
207
  toString(): string {
@@ -145,15 +209,30 @@ export class DateTime extends Value<Optional<string>> {
145
209
  }
146
210
 
147
211
  toJSON(): JsonValue {
148
- return this.utc.toISO();
212
+ return this.isValid ? this.utc.format('YYYY-MM-DDTHH:mm:ss.SSS[Z]') : null;
149
213
  }
150
214
 
151
215
  toFormat(format: string): string {
152
- return this.luxon.toFormat(format);
216
+ return this.isValid ? this.date.format(toDayjsFormat(format)) : '';
153
217
  }
154
218
 
155
219
  toLocale(locale = 'nl-NL', format = 'D'): string {
156
- return this.luxon.setLocale(locale).toFormat(format);
220
+ if (!this.isValid) return '';
221
+
222
+ if (format === 'D') return formatWithIntl(this.date, locale, { year: 'numeric', month: 'numeric', day: 'numeric' });
223
+ if (format === 'DDD') return formatWithIntl(this.date, locale, { dateStyle: 'long' });
224
+ if (format === 'ffff') {
225
+ return formatWithIntl(this.date, locale, {
226
+ weekday: 'long',
227
+ year: 'numeric',
228
+ month: 'long',
229
+ day: 'numeric',
230
+ hour: 'numeric',
231
+ minute: '2-digit',
232
+ timeZoneName: timezoneOf(this.date) ? 'long' : 'short',
233
+ });
234
+ }
235
+ return this.date.locale(toDayjsLocale(locale)).format(toDayjsFormat(format));
157
236
  }
158
237
 
159
238
  toFull(locale?: string): string {
@@ -161,11 +240,11 @@ export class DateTime extends Value<Optional<string>> {
161
240
  }
162
241
 
163
242
  toDate(): Optional<Date> {
164
- return this.isValid ? this.utc.toJSDate() : undefined;
243
+ return this.isValid ? this.utc.toDate() : undefined;
165
244
  }
166
245
 
167
246
  toEpoch(): number {
168
- return this.luxon.toMillis();
247
+ return this.date.valueOf();
169
248
  }
170
249
 
171
250
  ago(end: DateTime = DateTime.now): string {
@@ -174,7 +253,7 @@ export class DateTime extends Value<Optional<string>> {
174
253
 
175
254
  withClock(clock: DateTime): DateTime {
176
255
  return tryTo(() => [this.toDate() as Date, clock.toDate() as Date])
177
- .map(([td, cd]) => new Date(td.getFullYear(), td.getMonth(), td.getDate(), cd.getHours(), cd.getMinutes(), cd.getSeconds()))
256
+ .map(([td, cd]) => new Date(Date.UTC(td.getUTCFullYear(), td.getUTCMonth(), td.getUTCDate(), cd.getUTCHours(), cd.getUTCMinutes(), cd.getUTCSeconds())))
178
257
  .map(d => new DateTime(d)).value;
179
258
  }
180
259
  }
@@ -182,3 +261,90 @@ export class DateTime extends Value<Optional<string>> {
182
261
  export const isDateTime = (dt?: unknown): dt is DateTime => isDefined(dt) && dt instanceof DateTime;
183
262
 
184
263
  export const dt = (dt?: DatetimeInput): DateTime => new DateTime(dt);
264
+
265
+ const parseIso = (value: string): Dayjs => {
266
+ const offset = offsetOf(value);
267
+ if (offset) {
268
+ const date = dayjs.utc(value);
269
+ return date.isValid() ? inOffsetZone(date, offset) : invalidDate;
270
+ }
271
+ return dayjs(value, isoFormats, true).isValid() ? dayjs.utc(value) : invalidDate;
272
+ };
273
+
274
+ const parseFormatted = (value: string, format: string): Dayjs => {
275
+ const dayjsFormat = toDayjsFormat(format);
276
+ const offset = offsetOf(value);
277
+ if (format.includes('ZZZ') && offset) {
278
+ const iso = dayjs.utc(value);
279
+ return iso.isValid() ? inOffsetZone(iso, offset) : invalidDate;
280
+ }
281
+ return dayjs.utc(value, dayjsFormat, true);
282
+ };
283
+
284
+ const offsetOf = (value: string): string | undefined => value.match(/([+-]\d{2}:?\d{2})$/)?.[1];
285
+
286
+ const fromDayjs = (date: Dayjs): DateTime => new DateTime(date as unknown as DatetimeInput);
287
+
288
+ const formatDateTime = (date: Dayjs): string => {
289
+ const formatted = date.format('YYYY-MM-DDTHH:mm:ss.SSSZ');
290
+ return timezoneOf(date) ? formatted : formatted.replace('+00:00', 'Z');
291
+ };
292
+
293
+ const change = (date: Dayjs, value: number | Duration, unit: DurationUnit, direction: 'add' | 'subtract'): Dayjs => {
294
+ if (isNumber(value)) return changeUnit(date, value, unit, direction);
295
+ return Object.entries(value).reduce((result, [durationUnit, durationValue]) => changeUnit(result, durationValue ?? 0, durationUnit as DurationUnit, direction), date);
296
+ };
297
+
298
+ const changeUnit = (date: Dayjs, value: number, unit: DurationUnit, direction: 'add' | 'subtract'): Dayjs => {
299
+ const amount = direction === 'add' ? value : -value;
300
+ const milliseconds = fixedUnitMilliseconds[unit];
301
+ const months = calendarUnitMonths[unit];
302
+
303
+ if (months && !Number.isInteger(value)) return addMonths(date, amount * months);
304
+ if (milliseconds && !Number.isInteger(value)) return date.add(amount * milliseconds, 'millisecond');
305
+ return date.add(amount, toDayjsUnit(unit));
306
+ };
307
+
308
+ const addMonths = (date: Dayjs, months: number): Dayjs => {
309
+ const wholeMonths = Math.trunc(months);
310
+ const fraction = months - wholeMonths;
311
+ const shifted = date.add(wholeMonths, 'month');
312
+ if (fraction === 0) return shifted;
313
+
314
+ const next = shifted.add(months > 0 ? 1 : -1, 'month');
315
+ return shifted.add((next.valueOf() - shifted.valueOf()) * Math.abs(fraction), 'millisecond');
316
+ };
317
+
318
+ const inOffsetZone = (date: Dayjs, offset: string): Dayjs => offsetToTimeZone(offset).map(zone => date.tz(zone)).or(date.utcOffset(offset));
319
+
320
+ const offsetToTimeZone = (offset: string) =>
321
+ tryTo(() => {
322
+ const [, sign, hours, minutes] = offset.match(/^([+-])(\d{2}):?(\d{2})$/) ?? [];
323
+ if (minutes !== '00') throw new Error();
324
+ if (hours === '00') return 'UTC';
325
+ return `Etc/GMT${sign === '+' ? '-' : '+'}${Number(hours)}`;
326
+ });
327
+
328
+ const toDayjsUnit = (unit: DurationUnit): ManipulateType => unit.replace(/s$/, '') as ManipulateType;
329
+
330
+ const toDayjsBoundaryUnit = (unit: DateTimeUnit): OpUnitType => {
331
+ const dayjsUnit = toDayjsUnit(unit);
332
+ return (dayjsUnit === 'week' ? 'isoWeek' : dayjsUnit) as OpUnitType;
333
+ };
334
+
335
+ const toDayjsFormat = (format: string): string =>
336
+ format
337
+ .replace(/'([^']+)'/g, '[$1]')
338
+ .replace(/EEE/g, 'ddd')
339
+ .replace(/yyyy/g, 'YYYY')
340
+ .replace(/dd/g, 'DD')
341
+ .replace(/LLL/g, 'MMM')
342
+ .replace(/ZZZ/g, 'ZZ')
343
+ .replace(/hh/g, 'HH');
344
+
345
+ const toDayjsLocale = (locale: string): string => locale.toLowerCase().split('-')[0];
346
+
347
+ const formatWithIntl = (date: Dayjs, locale: string, options: Intl.DateTimeFormatOptions): string =>
348
+ new Intl.DateTimeFormat(locale, { ...options, timeZone: timezoneOf(date) ?? 'UTC' }).format(date.toDate());
349
+
350
+ const timezoneOf = (date: Dayjs): string | undefined => (date as ZonedDayjs).$x?.$timezone;
package/src/types/Text.ts CHANGED
@@ -22,4 +22,6 @@ export const toWords = (input: unknown): string[] => {
22
22
 
23
23
  export const kebab = (s = ''): string => toWords(s).join('-').toLowerCase();
24
24
 
25
+ export type KebabToCamel<S extends string> = S extends `${infer Head}-${infer Tail}` ? `${Head}${Capitalize<KebabToCamel<Tail>>}` : S;
26
+
25
27
  export const capitalize = (s = ''): string => s.charAt(0).toUpperCase() + s.slice(1);
@@ -1,140 +0,0 @@
1
- import {
2
- seconds
3
- } from "./chunk-ZQXTKDWH.mjs";
4
- import {
5
- isDate
6
- } from "./chunk-ADJAEGCT.mjs";
7
- import {
8
- choose,
9
- ifDefined,
10
- tryTo
11
- } from "./chunk-6Q7FX3KI.mjs";
12
- import {
13
- Value
14
- } from "./chunk-YW4JACEA.mjs";
15
- import {
16
- isA
17
- } from "./chunk-D5IYAIMK.mjs";
18
- import {
19
- use
20
- } from "./chunk-PF7HDF6B.mjs";
21
- import {
22
- isDefined,
23
- isNumber,
24
- isString
25
- } from "./chunk-AAND4MKF.mjs";
26
-
27
- // src/domain/DateTime.ts
28
- import { DateTime as LuxonDateTime, Settings } from "luxon";
29
- Settings.defaultZone = "utc";
30
- var DateTime = class _DateTime extends Value {
31
- luxon;
32
- constructor(value, format) {
33
- const luxon = choose(value).type(isString, (v) => format ? LuxonDateTime.fromFormat(v, format, { setZone: true }) : LuxonDateTime.fromISO(v, { setZone: true })).type(isNumber, (v) => LuxonDateTime.fromMillis(v)).type(isDate, (v) => LuxonDateTime.fromJSDate(v)).type(isDateTime, (v) => v.luxon).else(value instanceof LuxonDateTime ? value : LuxonDateTime.fromISO(void 0));
34
- super(luxon.toISO() ?? void 0);
35
- this.luxon = luxon;
36
- }
37
- static get now() {
38
- return new _DateTime(LuxonDateTime.utc());
39
- }
40
- get isValid() {
41
- return isDefined(this.value) && this.utc.isValid;
42
- }
43
- /**
44
- * @deprecated Deprecated in favor for DateTime.from as that also accepts locales and another DateTime
45
- */
46
- get fromNow() {
47
- return this.from();
48
- }
49
- get inAmsterdam() {
50
- return this.withZone("Europe/Amsterdam");
51
- }
52
- get inNewYork() {
53
- return this.withZone("America/New_York");
54
- }
55
- get inLondon() {
56
- return this.withZone("Europe/London");
57
- }
58
- get inWarsaw() {
59
- return this.withZone("Europe/Warsaw");
60
- }
61
- get utc() {
62
- return this.luxon.setZone("utc");
63
- }
64
- from(dateOrLocale, maybeLocale) {
65
- return use(
66
- (isString(dateOrLocale) ? dateOrLocale : maybeLocale) ?? "en",
67
- (locale) => ifDefined(
68
- isA(dateOrLocale) ? dateOrLocale : void 0,
69
- (d) => this.utc.setLocale(locale).toRelative({ base: d.utc }),
70
- () => this.utc.setLocale(locale).toRelative()
71
- )
72
- ) ?? "";
73
- }
74
- isAfter(dt2) {
75
- return this.utc > dt2.utc;
76
- }
77
- isBefore(dt2) {
78
- return this.utc < dt2.utc;
79
- }
80
- equals(dt2) {
81
- return this.utc.hasSame(dt2.utc, "millisecond");
82
- }
83
- add(n, unit = "day") {
84
- return new _DateTime(this.luxon.plus(isNumber(n) ? { [unit]: n } : n));
85
- }
86
- subtract(n, unit = "day") {
87
- return new _DateTime(this.luxon.minus(isNumber(n) ? { [unit]: n } : n));
88
- }
89
- diff(other, unit = "day", opts) {
90
- return Math[opts?.rounding ?? "floor"](this.utc.diff(other.utc).as(unit));
91
- }
92
- startOf(unit = "day") {
93
- return new _DateTime(this.luxon.startOf(unit));
94
- }
95
- endOf(unit = "day") {
96
- return new _DateTime(this.luxon.endOf(unit));
97
- }
98
- isWeekend() {
99
- return this.luxon.isWeekend;
100
- }
101
- withZone(zone) {
102
- return new _DateTime(this.luxon.setZone(zone));
103
- }
104
- toString() {
105
- return this.value ?? "";
106
- }
107
- toJSON() {
108
- return this.utc.toISO();
109
- }
110
- toFormat(format) {
111
- return this.luxon.toFormat(format);
112
- }
113
- toLocale(locale = "nl-NL", format = "D") {
114
- return this.luxon.setLocale(locale).toFormat(format);
115
- }
116
- toFull(locale) {
117
- return this.toLocale(locale, "DDD");
118
- }
119
- toDate() {
120
- return this.isValid ? this.utc.toJSDate() : void 0;
121
- }
122
- toEpoch() {
123
- return this.luxon.toMillis();
124
- }
125
- ago(end = _DateTime.now) {
126
- return seconds.toText(end.diff(this, "second"));
127
- }
128
- withClock(clock) {
129
- return tryTo(() => [this.toDate(), clock.toDate()]).map(([td, cd]) => new Date(td.getFullYear(), td.getMonth(), td.getDate(), cd.getHours(), cd.getMinutes(), cd.getSeconds())).map((d) => new _DateTime(d)).value;
130
- }
131
- };
132
- var isDateTime = (dt2) => isDefined(dt2) && dt2 instanceof DateTime;
133
- var dt = (dt2) => new DateTime(dt2);
134
-
135
- export {
136
- DateTime,
137
- isDateTime,
138
- dt
139
- };
140
- //# sourceMappingURL=chunk-XKRR6345.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/domain/DateTime.ts"],"sourcesContent":["import { DateTime as LuxonDateTime, DateTimeUnit as LuxonDateTimeUnit, DurationUnit as LuxonDurationUnit, Settings } from 'luxon';\nimport { Value } from '../types/Value';\nimport { Optional } from '../types/Types';\nimport { choose } from '../types/Case';\nimport { isDefined, isNumber, isString } from '../types/Is';\nimport { isDate } from '../types/IsDate';\nimport { isA } from '../types/IsA';\nimport { ifDefined } from '../utils/If';\nimport { JsonValue } from '../types/Json';\nimport { seconds } from '../utils/Seconds';\nimport { tryTo } from '../types/Try';\nimport { use } from '../types/Constructor';\n\nSettings.defaultZone = 'utc';\n\nexport type DateTimeUnit = LuxonDateTimeUnit;\nexport type DurationUnit = LuxonDurationUnit;\nexport type Duration = Partial<Record<DurationUnit, number>>;\n\nexport type DiffOptions = {\n rounding: 'floor' | 'ceil' | 'round';\n};\n\nexport type DatetimeInput = string | number | Date | DateTime | null;\n\nexport class DateTime extends Value<Optional<string>> {\n protected readonly luxon: LuxonDateTime;\n\n constructor(value?: DatetimeInput);\n constructor(value?: string, format?: string);\n constructor(value?: DatetimeInput, format?: string) {\n const luxon = choose(value)\n .type(isString, v => (format ? LuxonDateTime.fromFormat(v, format, { setZone: true }) : LuxonDateTime.fromISO(v, { setZone: true })))\n .type(isNumber, v => LuxonDateTime.fromMillis(v))\n .type(isDate, v => LuxonDateTime.fromJSDate(v))\n .type(isDateTime, v => v.luxon)\n // Allow constructing with LuxonDateTime without exposing types\n .else(value instanceof LuxonDateTime ? value : LuxonDateTime.fromISO(undefined as any));\n\n super(luxon.toISO() ?? undefined);\n this.luxon = luxon;\n }\n\n static get now(): DateTime {\n return new DateTime(LuxonDateTime.utc() as any);\n }\n\n get isValid(): boolean {\n return isDefined(this.value) && this.utc.isValid;\n }\n\n /**\n * @deprecated Deprecated in favor for DateTime.from as that also accepts locales and another DateTime\n */\n get fromNow(): string {\n return this.from();\n }\n\n get inAmsterdam(): DateTime {\n return this.withZone('Europe/Amsterdam');\n }\n\n get inNewYork(): DateTime {\n return this.withZone('America/New_York');\n }\n\n get inLondon(): DateTime {\n return this.withZone('Europe/London');\n }\n\n get inWarsaw(): DateTime {\n return this.withZone('Europe/Warsaw');\n }\n\n protected get utc(): LuxonDateTime {\n return this.luxon.setZone('utc');\n }\n\n from(locale?: string): string;\n\n from(date?: DateTime, locale?: string): string;\n\n from(dateOrLocale?: string | DateTime, maybeLocale?: string): string {\n return (\n use((isString(dateOrLocale) ? dateOrLocale : maybeLocale) ?? 'en', locale =>\n ifDefined(\n isA<DateTime>(dateOrLocale) ? dateOrLocale : undefined,\n d => this.utc.setLocale(locale).toRelative({ base: d.utc }),\n () => this.utc.setLocale(locale).toRelative()\n )\n ) ?? ''\n );\n }\n\n isAfter(dt: DateTime): boolean {\n return this.utc > dt.utc;\n }\n\n isBefore(dt: DateTime): boolean {\n return this.utc < dt.utc;\n }\n\n equals(dt: DateTime): boolean {\n return this.utc.hasSame(dt.utc, 'millisecond');\n }\n\n add(n: number, unit?: DurationUnit): DateTime;\n\n add(duration: Duration): DateTime;\n\n add(n: number | Duration, unit: DurationUnit = 'day'): DateTime {\n return new DateTime(this.luxon.plus(isNumber(n) ? { [unit]: n } : n) as any);\n }\n\n subtract(n: number, unit?: DurationUnit): DateTime;\n\n subtract(duration: Duration): DateTime;\n\n subtract(n: number | Duration, unit: DurationUnit = 'day'): DateTime {\n return new DateTime(this.luxon.minus(isNumber(n) ? { [unit]: n } : n) as any);\n }\n\n diff(other: DateTime, unit: DateTimeUnit = 'day', opts?: DiffOptions): number {\n return Math[opts?.rounding ?? 'floor'](this.utc.diff(other.utc).as(unit));\n }\n\n startOf(unit: DateTimeUnit = 'day'): DateTime {\n return new DateTime(this.luxon.startOf(unit) as any);\n }\n\n endOf(unit: DateTimeUnit = 'day'): DateTime {\n return new DateTime(this.luxon.endOf(unit) as any);\n }\n\n isWeekend(): boolean {\n return this.luxon.isWeekend;\n }\n\n withZone(zone: string): DateTime {\n return new DateTime(this.luxon.setZone(zone) as any);\n }\n\n toString(): string {\n return this.value ?? '';\n }\n\n toJSON(): JsonValue {\n return this.utc.toISO();\n }\n\n toFormat(format: string): string {\n return this.luxon.toFormat(format);\n }\n\n toLocale(locale = 'nl-NL', format = 'D'): string {\n return this.luxon.setLocale(locale).toFormat(format);\n }\n\n toFull(locale?: string): string {\n return this.toLocale(locale, 'DDD');\n }\n\n toDate(): Optional<Date> {\n return this.isValid ? this.utc.toJSDate() : undefined;\n }\n\n toEpoch(): number {\n return this.luxon.toMillis();\n }\n\n ago(end: DateTime = DateTime.now): string {\n return seconds.toText(end.diff(this, 'second'));\n }\n\n withClock(clock: DateTime): DateTime {\n return tryTo(() => [this.toDate() as Date, clock.toDate() as Date])\n .map(([td, cd]) => new Date(td.getFullYear(), td.getMonth(), td.getDate(), cd.getHours(), cd.getMinutes(), cd.getSeconds()))\n .map(d => new DateTime(d)).value;\n }\n}\n\nexport const isDateTime = (dt?: unknown): dt is DateTime => isDefined(dt) && dt instanceof DateTime;\n\nexport const dt = (dt?: DatetimeInput): DateTime => new DateTime(dt);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,eAAqF,gBAAgB;AAa1H,SAAS,cAAc;AAYhB,IAAM,WAAN,MAAM,kBAAiB,MAAwB;AAAA,EACjC;AAAA,EAInB,YAAY,OAAuB,QAAiB;AAClD,UAAM,QAAQ,OAAO,KAAK,EACvB,KAAK,UAAU,OAAM,SAAS,cAAc,WAAW,GAAG,QAAQ,EAAE,SAAS,KAAK,CAAC,IAAI,cAAc,QAAQ,GAAG,EAAE,SAAS,KAAK,CAAC,CAAE,EACnI,KAAK,UAAU,OAAK,cAAc,WAAW,CAAC,CAAC,EAC/C,KAAK,QAAQ,OAAK,cAAc,WAAW,CAAC,CAAC,EAC7C,KAAK,YAAY,OAAK,EAAE,KAAK,EAE7B,KAAK,iBAAiB,gBAAgB,QAAQ,c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