@duplojs/utils 1.3.29 → 1.3.31

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 (246) hide show
  1. package/dist/clean/entity.d.ts +2 -2
  2. package/dist/clean/flag.cjs +4 -0
  3. package/dist/clean/flag.d.ts +1 -0
  4. package/dist/clean/flag.mjs +4 -0
  5. package/dist/clean/index.cjs +15 -0
  6. package/dist/clean/index.d.ts +1 -0
  7. package/dist/clean/index.mjs +8 -1
  8. package/dist/clean/newType.d.ts +2 -2
  9. package/dist/clean/primitive/base.cjs +3 -0
  10. package/dist/clean/primitive/base.d.ts +4 -2
  11. package/dist/clean/primitive/base.mjs +3 -1
  12. package/dist/clean/primitive/operations/date/dateAddTime.cjs +16 -0
  13. package/dist/clean/primitive/operations/date/dateAddTime.d.ts +4 -0
  14. package/dist/clean/primitive/operations/date/dateAddTime.mjs +14 -0
  15. package/dist/clean/primitive/operations/date/dateMax.cjs +1 -5
  16. package/dist/clean/primitive/operations/date/dateMax.d.ts +1 -2
  17. package/dist/clean/primitive/operations/date/dateMax.mjs +1 -5
  18. package/dist/clean/primitive/operations/date/dateMin.cjs +1 -5
  19. package/dist/clean/primitive/operations/date/dateMin.d.ts +1 -2
  20. package/dist/clean/primitive/operations/date/dateMin.mjs +1 -5
  21. package/dist/clean/primitive/operations/date/dateSubtractTime.cjs +16 -0
  22. package/dist/clean/primitive/operations/date/dateSubtractTime.d.ts +4 -0
  23. package/dist/clean/primitive/operations/date/dateSubtractTime.mjs +14 -0
  24. package/dist/clean/primitive/operations/date/index.d.ts +2 -4
  25. package/dist/clean/primitive/operations/equal.d.ts +3 -3
  26. package/dist/clean/primitive/operations/index.d.ts +1 -0
  27. package/dist/clean/primitive/operations/sort.cjs +6 -0
  28. package/dist/clean/primitive/operations/sort.d.ts +4 -8
  29. package/dist/clean/primitive/operations/sort.mjs +6 -0
  30. package/dist/clean/primitive/operations/time/index.d.ts +4 -0
  31. package/dist/clean/primitive/operations/time/timeGreaterThan.cjs +15 -0
  32. package/dist/clean/primitive/operations/time/timeGreaterThan.d.ts +4 -0
  33. package/dist/clean/primitive/operations/time/timeGreaterThan.mjs +13 -0
  34. package/dist/clean/primitive/operations/time/timeLessThan.cjs +15 -0
  35. package/dist/clean/primitive/operations/time/timeLessThan.d.ts +4 -0
  36. package/dist/clean/primitive/operations/time/timeLessThan.mjs +13 -0
  37. package/dist/clean/primitive/operations/time/timeMax.cjs +12 -0
  38. package/dist/clean/primitive/operations/time/timeMax.d.ts +4 -0
  39. package/dist/clean/primitive/operations/time/timeMax.mjs +10 -0
  40. package/dist/clean/primitive/operations/time/timeMin.cjs +12 -0
  41. package/dist/clean/primitive/operations/time/timeMin.d.ts +4 -0
  42. package/dist/clean/primitive/operations/time/timeMin.mjs +10 -0
  43. package/dist/clean/unwrapEntity.cjs +26 -0
  44. package/dist/clean/unwrapEntity.d.ts +13 -0
  45. package/dist/clean/unwrapEntity.mjs +24 -0
  46. package/dist/common/index.d.ts +2 -0
  47. package/dist/common/override.cjs +38 -17
  48. package/dist/common/override.d.ts +5 -8
  49. package/dist/common/override.mjs +38 -17
  50. package/dist/common/pipeCall.cjs +7 -0
  51. package/dist/common/pipeCall.d.ts +1 -0
  52. package/dist/common/pipeCall.mjs +5 -0
  53. package/dist/common/toCurriedPredicate.cjs +7 -0
  54. package/dist/common/toCurriedPredicate.d.ts +1 -0
  55. package/dist/common/toCurriedPredicate.mjs +5 -0
  56. package/dist/common/toWrappedValue.d.ts +2 -1
  57. package/dist/common/types/DeepReadonly.d.ts +3 -0
  58. package/dist/common/types/index.d.ts +1 -0
  59. package/dist/dataParser/extended/coerce/index.cjs +2 -0
  60. package/dist/dataParser/extended/coerce/index.d.ts +1 -0
  61. package/dist/dataParser/extended/coerce/index.mjs +1 -0
  62. package/dist/dataParser/extended/coerce/time.cjs +12 -0
  63. package/dist/dataParser/extended/coerce/time.d.ts +7 -0
  64. package/dist/dataParser/extended/coerce/time.mjs +10 -0
  65. package/dist/dataParser/extended/index.cjs +2 -0
  66. package/dist/dataParser/extended/index.d.ts +1 -0
  67. package/dist/dataParser/extended/index.mjs +1 -0
  68. package/dist/dataParser/extended/object.cjs +5 -0
  69. package/dist/dataParser/extended/object.d.ts +4 -0
  70. package/dist/dataParser/extended/object.mjs +5 -0
  71. package/dist/dataParser/extended/time.cjs +22 -0
  72. package/dist/dataParser/extended/time.d.ts +34 -0
  73. package/dist/dataParser/extended/time.mjs +20 -0
  74. package/dist/dataParser/identifier.d.ts +10 -4
  75. package/dist/dataParser/index.cjs +36 -24
  76. package/dist/dataParser/index.mjs +4 -0
  77. package/dist/dataParser/parsers/coerce/index.cjs +2 -0
  78. package/dist/dataParser/parsers/coerce/index.d.ts +1 -0
  79. package/dist/dataParser/parsers/coerce/index.mjs +1 -0
  80. package/dist/dataParser/parsers/coerce/time.cjs +12 -0
  81. package/dist/dataParser/parsers/coerce/time.d.ts +6 -0
  82. package/dist/dataParser/parsers/coerce/time.mjs +10 -0
  83. package/dist/dataParser/parsers/date.cjs +6 -12
  84. package/dist/dataParser/parsers/date.mjs +6 -12
  85. package/dist/dataParser/parsers/index.d.ts +1 -0
  86. package/dist/dataParser/parsers/literal.d.ts +2 -2
  87. package/dist/dataParser/parsers/object/extends.cjs +15 -0
  88. package/dist/dataParser/parsers/object/extends.d.ts +9 -0
  89. package/dist/dataParser/parsers/object/extends.mjs +12 -0
  90. package/dist/dataParser/parsers/object/index.d.ts +1 -0
  91. package/dist/dataParser/parsers/time/checkers/index.d.ts +2 -0
  92. package/dist/dataParser/parsers/time/checkers/max.cjs +19 -0
  93. package/dist/dataParser/parsers/time/checkers/max.d.ts +12 -0
  94. package/dist/dataParser/parsers/time/checkers/max.mjs +16 -0
  95. package/dist/dataParser/parsers/time/checkers/min.cjs +19 -0
  96. package/dist/dataParser/parsers/time/checkers/min.d.ts +12 -0
  97. package/dist/dataParser/parsers/time/checkers/min.mjs +16 -0
  98. package/dist/dataParser/parsers/time/index.cjs +47 -0
  99. package/dist/dataParser/parsers/time/index.d.ts +33 -0
  100. package/dist/dataParser/parsers/time/index.mjs +44 -0
  101. package/dist/dataParser/types/checkers.d.ts +1 -1
  102. package/dist/dataParser/types/dataParsers.d.ts +2 -2
  103. package/dist/date/applyTimezone.cjs +17 -0
  104. package/dist/date/applyTimezone.d.ts +4 -0
  105. package/dist/date/applyTimezone.mjs +15 -0
  106. package/dist/date/constants.cjs +13 -3
  107. package/dist/date/constants.d.ts +6 -1
  108. package/dist/date/constants.mjs +9 -4
  109. package/dist/date/create.cjs +62 -29
  110. package/dist/date/create.d.ts +10 -6
  111. package/dist/date/create.mjs +60 -27
  112. package/dist/date/createOrThrow.cjs +4 -1
  113. package/dist/date/createOrThrow.d.ts +5 -4
  114. package/dist/date/createOrThrow.mjs +4 -1
  115. package/dist/date/createTheDate.cjs +10 -0
  116. package/dist/date/createTheDate.d.ts +2 -0
  117. package/dist/date/createTheDate.mjs +8 -0
  118. package/dist/date/createTheTime.cjs +10 -0
  119. package/dist/date/createTheTime.d.ts +2 -0
  120. package/dist/date/createTheTime.mjs +8 -0
  121. package/dist/date/createTime.cjs +61 -0
  122. package/dist/date/createTime.d.ts +44 -0
  123. package/dist/date/createTime.mjs +59 -0
  124. package/dist/date/createTimeOrThrow.cjs +28 -0
  125. package/dist/date/createTimeOrThrow.d.ts +10 -0
  126. package/dist/date/createTimeOrThrow.mjs +25 -0
  127. package/dist/date/format.cjs +37 -0
  128. package/dist/date/format.d.ts +4 -0
  129. package/dist/date/format.mjs +35 -0
  130. package/dist/date/getTimezoneOffset.cjs +27 -0
  131. package/dist/date/getTimezoneOffset.d.ts +4 -0
  132. package/dist/date/getTimezoneOffset.mjs +25 -0
  133. package/dist/date/getters/getDayOfYear.cjs +2 -1
  134. package/dist/date/getters/getDayOfYear.mjs +2 -1
  135. package/dist/date/index.cjs +51 -2
  136. package/dist/date/index.d.ts +15 -0
  137. package/dist/date/index.mjs +25 -3
  138. package/dist/date/is.cjs +9 -1
  139. package/dist/date/is.mjs +9 -1
  140. package/dist/date/isSafeTimeValue.cjs +15 -0
  141. package/dist/date/isSafeTimeValue.d.ts +1 -0
  142. package/dist/date/isSafeTimeValue.mjs +13 -0
  143. package/dist/date/isSafeTimestamp.cjs +3 -3
  144. package/dist/date/isSafeTimestamp.d.ts +1 -1
  145. package/dist/date/isSafeTimestamp.mjs +3 -3
  146. package/dist/date/isTime.cjs +17 -0
  147. package/dist/date/isTime.d.ts +2 -0
  148. package/dist/date/isTime.mjs +15 -0
  149. package/dist/date/makeSafeTimeValue.cjs +20 -0
  150. package/dist/date/makeSafeTimeValue.d.ts +1 -0
  151. package/dist/date/makeSafeTimeValue.mjs +18 -0
  152. package/dist/date/makeSafeTimestamp.cjs +20 -0
  153. package/dist/date/makeSafeTimestamp.d.ts +1 -0
  154. package/dist/date/makeSafeTimestamp.mjs +18 -0
  155. package/dist/date/maxTime.cjs +10 -0
  156. package/dist/date/maxTime.d.ts +3 -0
  157. package/dist/date/maxTime.mjs +8 -0
  158. package/dist/date/minTime.cjs +10 -0
  159. package/dist/date/minTime.d.ts +3 -0
  160. package/dist/date/minTime.mjs +8 -0
  161. package/dist/date/operators/addDays.cjs +2 -3
  162. package/dist/date/operators/addDays.mjs +2 -3
  163. package/dist/date/operators/addHours.cjs +2 -3
  164. package/dist/date/operators/addHours.mjs +2 -3
  165. package/dist/date/operators/addMilliseconds.cjs +2 -3
  166. package/dist/date/operators/addMilliseconds.mjs +2 -3
  167. package/dist/date/operators/addMinutes.cjs +2 -3
  168. package/dist/date/operators/addMinutes.mjs +2 -3
  169. package/dist/date/operators/addMonths.cjs +2 -3
  170. package/dist/date/operators/addMonths.mjs +2 -3
  171. package/dist/date/operators/addSeconds.cjs +2 -3
  172. package/dist/date/operators/addSeconds.mjs +2 -3
  173. package/dist/date/operators/addTime.cjs +21 -0
  174. package/dist/date/operators/addTime.d.ts +5 -0
  175. package/dist/date/operators/addTime.mjs +19 -0
  176. package/dist/date/operators/addWeeks.cjs +2 -3
  177. package/dist/date/operators/addWeeks.mjs +2 -3
  178. package/dist/date/operators/addYears.cjs +2 -3
  179. package/dist/date/operators/addYears.mjs +2 -3
  180. package/dist/date/operators/betweenThanTime.cjs +17 -0
  181. package/dist/date/operators/betweenThanTime.d.ts +3 -0
  182. package/dist/date/operators/betweenThanTime.mjs +15 -0
  183. package/dist/date/operators/betweenTime.cjs +17 -0
  184. package/dist/date/operators/betweenTime.d.ts +3 -0
  185. package/dist/date/operators/betweenTime.mjs +15 -0
  186. package/dist/date/operators/greaterThanTime.cjs +16 -0
  187. package/dist/date/operators/greaterThanTime.d.ts +3 -0
  188. package/dist/date/operators/greaterThanTime.mjs +14 -0
  189. package/dist/date/operators/greaterTime.cjs +16 -0
  190. package/dist/date/operators/greaterTime.d.ts +3 -0
  191. package/dist/date/operators/greaterTime.mjs +14 -0
  192. package/dist/date/operators/index.d.ts +8 -0
  193. package/dist/date/operators/lessThanTime.cjs +16 -0
  194. package/dist/date/operators/lessThanTime.d.ts +3 -0
  195. package/dist/date/operators/lessThanTime.mjs +14 -0
  196. package/dist/date/operators/lessTime.cjs +16 -0
  197. package/dist/date/operators/lessTime.d.ts +3 -0
  198. package/dist/date/operators/lessTime.mjs +14 -0
  199. package/dist/date/operators/subtractDays.cjs +2 -3
  200. package/dist/date/operators/subtractDays.mjs +2 -3
  201. package/dist/date/operators/subtractHours.cjs +2 -3
  202. package/dist/date/operators/subtractHours.mjs +2 -3
  203. package/dist/date/operators/subtractMilliseconds.cjs +2 -3
  204. package/dist/date/operators/subtractMilliseconds.mjs +2 -3
  205. package/dist/date/operators/subtractMinutes.cjs +2 -3
  206. package/dist/date/operators/subtractMinutes.mjs +2 -3
  207. package/dist/date/operators/subtractMonths.cjs +2 -3
  208. package/dist/date/operators/subtractMonths.mjs +2 -3
  209. package/dist/date/operators/subtractSeconds.cjs +2 -3
  210. package/dist/date/operators/subtractSeconds.mjs +2 -3
  211. package/dist/date/operators/subtractTime.cjs +21 -0
  212. package/dist/date/operators/subtractTime.d.ts +5 -0
  213. package/dist/date/operators/subtractTime.mjs +19 -0
  214. package/dist/date/operators/subtractWeeks.cjs +2 -3
  215. package/dist/date/operators/subtractWeeks.mjs +2 -3
  216. package/dist/date/operators/subtractYears.cjs +2 -3
  217. package/dist/date/operators/subtractYears.mjs +2 -3
  218. package/dist/date/sortTimes.cjs +20 -0
  219. package/dist/date/sortTimes.d.ts +4 -0
  220. package/dist/date/sortTimes.mjs +18 -0
  221. package/dist/date/{types/timezone.cjs → timezone.cjs} +1 -1
  222. package/dist/date/{types/timezone.d.ts → timezone.d.ts} +1 -1
  223. package/dist/date/{types/timezone.mjs → timezone.mjs} +1 -1
  224. package/dist/date/toTimeValue.cjs +14 -0
  225. package/dist/date/toTimeValue.d.ts +2 -0
  226. package/dist/date/toTimeValue.mjs +12 -0
  227. package/dist/date/toTimestamp.cjs +6 -21
  228. package/dist/date/toTimestamp.d.ts +0 -8
  229. package/dist/date/toTimestamp.mjs +8 -22
  230. package/dist/date/types/index.d.ts +3 -1
  231. package/dist/date/types/isSafeYear.d.ts +5 -52
  232. package/dist/date/types/spoolingDate.d.ts +12 -0
  233. package/dist/date/types/spoolingTime.d.ts +9 -0
  234. package/dist/date/types/theTime.d.ts +1 -0
  235. package/dist/index.cjs +4 -0
  236. package/dist/index.mjs +2 -0
  237. package/dist/metadata.json +401 -5
  238. package/dist/number/types/index.d.ts +2 -0
  239. package/dist/number/types/isGreater.d.ts +50 -0
  240. package/dist/number/types/isLess.d.ts +3 -0
  241. package/dist/object/hasKeys.d.ts +2 -2
  242. package/dist/object/types/forbiddenKey.d.ts +6 -0
  243. package/dist/object/types/index.d.ts +1 -0
  244. package/dist/string/types/index.d.ts +1 -0
  245. package/dist/string/types/replace.d.ts +1 -0
  246. package/package.json +1 -1
@@ -1,22 +1,36 @@
1
- export { daysInOneWeek, hoursInOneDay, maxTimestamp, millisecondInOneHour, millisecondInOneMinute, millisecondInOneWeek, millisecondsInOneDay, millisecondsInOneSecond, minTimestamp, minutesInOneHour, monthsInOneYear, secondsInOneMinute, theDateRegex } from './constants.mjs';
1
+ export { daysInOneWeek, hoursInOneDay, isoDateRegex, isoTimeRegex, maxTimeValue, maxTimestamp, millisecondInOneHour, millisecondInOneMinute, millisecondInOneWeek, millisecondsInOneDay, millisecondsInOneSecond, minTimeValue, minTimestamp, minutesInOneHour, monthsInOneYear, secondsInOneMinute, theDateRegex, theTimeRegex } from './constants.mjs';
2
2
  export { create } from './create.mjs';
3
3
  export { now } from './now.mjs';
4
4
  export { today } from './today.mjs';
5
5
  export { yesterday } from './yesterday.mjs';
6
6
  export { tomorrow } from './tomorrow.mjs';
7
7
  export { toNative } from './toNative.mjs';
8
- export { InvalidTheDateError, toTimestamp } from './toTimestamp.mjs';
8
+ export { toTimestamp } from './toTimestamp.mjs';
9
+ export { toTimeValue } from './toTimeValue.mjs';
9
10
  export { toISOString } from './toISOString.mjs';
10
11
  export { closestTo } from './closestTo.mjs';
11
12
  export { each } from './each.mjs';
12
13
  export { CreateTheDateError, createOrThrow } from './createOrThrow.mjs';
13
14
  export { round } from './round.mjs';
14
15
  export { isSafeTimestamp } from './isSafeTimestamp.mjs';
16
+ export { isSafeTimeValue } from './isSafeTimeValue.mjs';
15
17
  export { min } from './min.mjs';
18
+ export { minTime } from './minTime.mjs';
16
19
  export { max } from './max.mjs';
20
+ export { maxTime } from './maxTime.mjs';
17
21
  export { sort } from './sort.mjs';
22
+ export { sortTimes } from './sortTimes.mjs';
18
23
  export { is } from './is.mjs';
19
- export { timezone } from './types/timezone.mjs';
24
+ export { isTime } from './isTime.mjs';
25
+ export { timezone } from './timezone.mjs';
26
+ export { getTimezoneOffset } from './getTimezoneOffset.mjs';
27
+ export { applyTimezone } from './applyTimezone.mjs';
28
+ export { format } from './format.mjs';
29
+ export { makeSafeTimestamp } from './makeSafeTimestamp.mjs';
30
+ export { createTheDate } from './createTheDate.mjs';
31
+ export { createTheTime } from './createTheTime.mjs';
32
+ export { createTime } from './createTime.mjs';
33
+ export { CreateTheTimeError, createTimeOrThrow } from './createTimeOrThrow.mjs';
20
34
  export { getDayOfMonth } from './getters/getDayOfMonth.mjs';
21
35
  export { getDayOfWeek } from './getters/getDayOfWeek.mjs';
22
36
  export { getFirstDayOfWeek } from './getters/getFirstDayOfWeek.mjs';
@@ -37,6 +51,7 @@ export { addMilliseconds } from './operators/addMilliseconds.mjs';
37
51
  export { addMinutes } from './operators/addMinutes.mjs';
38
52
  export { addMonths } from './operators/addMonths.mjs';
39
53
  export { addSeconds } from './operators/addSeconds.mjs';
54
+ export { addTime } from './operators/addTime.mjs';
40
55
  export { addWeeks } from './operators/addWeeks.mjs';
41
56
  export { addYears } from './operators/addYears.mjs';
42
57
  export { subtractDays } from './operators/subtractDays.mjs';
@@ -45,11 +60,18 @@ export { subtractMilliseconds } from './operators/subtractMilliseconds.mjs';
45
60
  export { subtractMinutes } from './operators/subtractMinutes.mjs';
46
61
  export { subtractMonths } from './operators/subtractMonths.mjs';
47
62
  export { subtractSeconds } from './operators/subtractSeconds.mjs';
63
+ export { subtractTime } from './operators/subtractTime.mjs';
48
64
  export { subtractWeeks } from './operators/subtractWeeks.mjs';
49
65
  export { subtractYears } from './operators/subtractYears.mjs';
50
66
  export { between } from './operators/between.mjs';
51
67
  export { betweenThan } from './operators/betweenThan.mjs';
68
+ export { betweenThanTime } from './operators/betweenThanTime.mjs';
69
+ export { betweenTime } from './operators/betweenTime.mjs';
52
70
  export { greater } from './operators/greater.mjs';
53
71
  export { greaterThan } from './operators/greaterThan.mjs';
72
+ export { greaterThanTime } from './operators/greaterThanTime.mjs';
73
+ export { greaterTime } from './operators/greaterTime.mjs';
54
74
  export { less } from './operators/less.mjs';
55
75
  export { lessThan } from './operators/lessThan.mjs';
76
+ export { lessThanTime } from './operators/lessThanTime.mjs';
77
+ export { lessTime } from './operators/lessTime.mjs';
package/dist/date/is.cjs CHANGED
@@ -1,9 +1,17 @@
1
1
  'use strict';
2
2
 
3
3
  var constants = require('./constants.cjs');
4
+ var isSafeTimestamp = require('./isSafeTimestamp.cjs');
4
5
 
5
6
  function is(input) {
6
- return constants.theDateRegex.test(input);
7
+ const theDateMatch = input.match(constants.theDateRegex);
8
+ if (theDateMatch) {
9
+ const { value, sign } = theDateMatch.groups;
10
+ return isSafeTimestamp.isSafeTimestamp(Number(sign === "-"
11
+ ? `-${value}`
12
+ : value));
13
+ }
14
+ return false;
7
15
  }
8
16
 
9
17
  exports.is = is;
package/dist/date/is.mjs CHANGED
@@ -1,7 +1,15 @@
1
1
  import { theDateRegex } from './constants.mjs';
2
+ import { isSafeTimestamp } from './isSafeTimestamp.mjs';
2
3
 
3
4
  function is(input) {
4
- return theDateRegex.test(input);
5
+ const theDateMatch = input.match(theDateRegex);
6
+ if (theDateMatch) {
7
+ const { value, sign } = theDateMatch.groups;
8
+ return isSafeTimestamp(Number(sign === "-"
9
+ ? `-${value}`
10
+ : value));
11
+ }
12
+ return false;
5
13
  }
6
14
 
7
15
  export { is };
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ var constants = require('./constants.cjs');
4
+
5
+ function isSafeTimeValue(timeValue) {
6
+ if (!Number.isSafeInteger(timeValue)) {
7
+ return false;
8
+ }
9
+ if (timeValue <= constants.minTimeValue || timeValue >= constants.maxTimeValue) {
10
+ return false;
11
+ }
12
+ return true;
13
+ }
14
+
15
+ exports.isSafeTimeValue = isSafeTimeValue;
@@ -0,0 +1 @@
1
+ export declare function isSafeTimeValue(timeValue: number): boolean;
@@ -0,0 +1,13 @@
1
+ import { minTimeValue, maxTimeValue } from './constants.mjs';
2
+
3
+ function isSafeTimeValue(timeValue) {
4
+ if (!Number.isSafeInteger(timeValue)) {
5
+ return false;
6
+ }
7
+ if (timeValue <= minTimeValue || timeValue >= maxTimeValue) {
8
+ return false;
9
+ }
10
+ return true;
11
+ }
12
+
13
+ export { isSafeTimeValue };
@@ -2,11 +2,11 @@
2
2
 
3
3
  var constants = require('./constants.cjs');
4
4
 
5
- function isSafeTimestamp(input) {
6
- if (!Number.isSafeInteger(input)) {
5
+ function isSafeTimestamp(timestamp) {
6
+ if (!Number.isSafeInteger(timestamp)) {
7
7
  return false;
8
8
  }
9
- if (input <= constants.minTimestamp || input >= constants.maxTimestamp) {
9
+ if (timestamp <= constants.minTimestamp || timestamp >= constants.maxTimestamp) {
10
10
  return false;
11
11
  }
12
12
  return true;
@@ -1 +1 @@
1
- export declare function isSafeTimestamp(input: number): boolean;
1
+ export declare function isSafeTimestamp(timestamp: number): boolean;
@@ -1,10 +1,10 @@
1
1
  import { minTimestamp, maxTimestamp } from './constants.mjs';
2
2
 
3
- function isSafeTimestamp(input) {
4
- if (!Number.isSafeInteger(input)) {
3
+ function isSafeTimestamp(timestamp) {
4
+ if (!Number.isSafeInteger(timestamp)) {
5
5
  return false;
6
6
  }
7
- if (input <= minTimestamp || input >= maxTimestamp) {
7
+ if (timestamp <= minTimestamp || timestamp >= maxTimestamp) {
8
8
  return false;
9
9
  }
10
10
  return true;
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var constants = require('./constants.cjs');
4
+ var isSafeTimestamp = require('./isSafeTimestamp.cjs');
5
+
6
+ function isTime(input) {
7
+ const theTimeMatch = input.match(constants.theTimeRegex);
8
+ if (theTimeMatch) {
9
+ const { value, sign } = theTimeMatch.groups;
10
+ return isSafeTimestamp.isSafeTimestamp(Number(sign === "-"
11
+ ? `-${value}`
12
+ : value));
13
+ }
14
+ return false;
15
+ }
16
+
17
+ exports.isTime = isTime;
@@ -0,0 +1,2 @@
1
+ import { type TheTime } from "./types";
2
+ export declare function isTime(input: string): input is TheTime;
@@ -0,0 +1,15 @@
1
+ import { theTimeRegex } from './constants.mjs';
2
+ import { isSafeTimestamp } from './isSafeTimestamp.mjs';
3
+
4
+ function isTime(input) {
5
+ const theTimeMatch = input.match(theTimeRegex);
6
+ if (theTimeMatch) {
7
+ const { value, sign } = theTimeMatch.groups;
8
+ return isSafeTimestamp(Number(sign === "-"
9
+ ? `-${value}`
10
+ : value));
11
+ }
12
+ return false;
13
+ }
14
+
15
+ export { isTime };
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ var constants = require('./constants.cjs');
4
+
5
+ function makeSafeTimeValue(timeValue) {
6
+ if (Number.isNaN(timeValue)) {
7
+ return 0;
8
+ }
9
+ if (timeValue > constants.maxTimeValue) {
10
+ return constants.maxTimeValue;
11
+ }
12
+ if (timeValue < constants.minTimeValue) {
13
+ return constants.minTimeValue;
14
+ }
15
+ return Number.isInteger(timeValue)
16
+ ? timeValue
17
+ : Math.round(timeValue);
18
+ }
19
+
20
+ exports.makeSafeTimeValue = makeSafeTimeValue;
@@ -0,0 +1 @@
1
+ export declare function makeSafeTimeValue(timeValue: number): number;
@@ -0,0 +1,18 @@
1
+ import { maxTimeValue, minTimeValue } from './constants.mjs';
2
+
3
+ function makeSafeTimeValue(timeValue) {
4
+ if (Number.isNaN(timeValue)) {
5
+ return 0;
6
+ }
7
+ if (timeValue > maxTimeValue) {
8
+ return maxTimeValue;
9
+ }
10
+ if (timeValue < minTimeValue) {
11
+ return minTimeValue;
12
+ }
13
+ return Number.isInteger(timeValue)
14
+ ? timeValue
15
+ : Math.round(timeValue);
16
+ }
17
+
18
+ export { makeSafeTimeValue };
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ var constants = require('./constants.cjs');
4
+
5
+ function makeSafeTimestamp(timestamp) {
6
+ if (Number.isNaN(timestamp)) {
7
+ return 0;
8
+ }
9
+ if (timestamp > constants.maxTimestamp) {
10
+ return constants.maxTimestamp;
11
+ }
12
+ if (timestamp < constants.minTimestamp) {
13
+ return constants.minTimestamp;
14
+ }
15
+ return Number.isInteger(timestamp)
16
+ ? timestamp
17
+ : Math.round(timestamp);
18
+ }
19
+
20
+ exports.makeSafeTimestamp = makeSafeTimestamp;
@@ -0,0 +1 @@
1
+ export declare function makeSafeTimestamp(timestamp: number): number;
@@ -0,0 +1,18 @@
1
+ import { maxTimestamp, minTimestamp } from './constants.mjs';
2
+
3
+ function makeSafeTimestamp(timestamp) {
4
+ if (Number.isNaN(timestamp)) {
5
+ return 0;
6
+ }
7
+ if (timestamp > maxTimestamp) {
8
+ return maxTimestamp;
9
+ }
10
+ if (timestamp < minTimestamp) {
11
+ return minTimestamp;
12
+ }
13
+ return Number.isInteger(timestamp)
14
+ ? timestamp
15
+ : Math.round(timestamp);
16
+ }
17
+
18
+ export { makeSafeTimestamp };
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ var createTheTime = require('./createTheTime.cjs');
4
+ var toTimeValue = require('./toTimeValue.cjs');
5
+
6
+ function maxTime(input) {
7
+ return createTheTime.createTheTime(Math.max(...input.map(toTimeValue.toTimeValue)));
8
+ }
9
+
10
+ exports.maxTime = maxTime;
@@ -0,0 +1,3 @@
1
+ import { type AnyTuple } from "../common";
2
+ import { type TheTime } from "./types";
3
+ export declare function maxTime<GenericInput extends AnyTuple<TheTime>>(input: GenericInput): `time${number}-` | `time${number}+`;
@@ -0,0 +1,8 @@
1
+ import { createTheTime } from './createTheTime.mjs';
2
+ import { toTimeValue } from './toTimeValue.mjs';
3
+
4
+ function maxTime(input) {
5
+ return createTheTime(Math.max(...input.map(toTimeValue)));
6
+ }
7
+
8
+ export { maxTime };
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ var createTheTime = require('./createTheTime.cjs');
4
+ var toTimeValue = require('./toTimeValue.cjs');
5
+
6
+ function minTime(input) {
7
+ return createTheTime.createTheTime(Math.min(...input.map(toTimeValue.toTimeValue)));
8
+ }
9
+
10
+ exports.minTime = minTime;
@@ -0,0 +1,3 @@
1
+ import { type AnyTuple } from "../common";
2
+ import { type TheTime } from "./types";
3
+ export declare function minTime<GenericInput extends AnyTuple<TheTime>>(input: GenericInput): `time${number}-` | `time${number}+`;
@@ -0,0 +1,8 @@
1
+ import { createTheTime } from './createTheTime.mjs';
2
+ import { toTimeValue } from './toTimeValue.mjs';
3
+
4
+ function minTime(input) {
5
+ return createTheTime(Math.min(...input.map(toTimeValue)));
6
+ }
7
+
8
+ export { minTime };
@@ -2,6 +2,7 @@
2
2
 
3
3
  var toNative = require('../toNative.cjs');
4
4
  var constants = require('../constants.cjs');
5
+ var createTheDate = require('../createTheDate.cjs');
5
6
 
6
7
  function addDays(...args) {
7
8
  if (args.length === 1) {
@@ -11,9 +12,7 @@ function addDays(...args) {
11
12
  const [input, day] = args;
12
13
  const date = toNative.toNative(input);
13
14
  date.setTime(date.getTime() + (day * constants.millisecondsInOneDay));
14
- const timestamp = date.getTime();
15
- const isNegative = timestamp < 0;
16
- return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
15
+ return createTheDate.createTheDate(date.getTime());
17
16
  }
18
17
 
19
18
  exports.addDays = addDays;
@@ -1,5 +1,6 @@
1
1
  import { toNative } from '../toNative.mjs';
2
2
  import { millisecondsInOneDay } from '../constants.mjs';
3
+ import { createTheDate } from '../createTheDate.mjs';
3
4
 
4
5
  function addDays(...args) {
5
6
  if (args.length === 1) {
@@ -9,9 +10,7 @@ function addDays(...args) {
9
10
  const [input, day] = args;
10
11
  const date = toNative(input);
11
12
  date.setTime(date.getTime() + (day * millisecondsInOneDay));
12
- const timestamp = date.getTime();
13
- const isNegative = timestamp < 0;
14
- return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
13
+ return createTheDate(date.getTime());
15
14
  }
16
15
 
17
16
  export { addDays };
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var constants = require('../constants.cjs');
4
+ var createTheDate = require('../createTheDate.cjs');
4
5
  var toNative = require('../toNative.cjs');
5
6
 
6
7
  function addHours(...args) {
@@ -11,9 +12,7 @@ function addHours(...args) {
11
12
  const [input, hour] = args;
12
13
  const date = toNative.toNative(input);
13
14
  date.setTime(date.getTime() + (hour * constants.millisecondInOneHour));
14
- const timestamp = date.getTime();
15
- const isNegative = timestamp < 0;
16
- return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
15
+ return createTheDate.createTheDate(date.getTime());
17
16
  }
18
17
 
19
18
  exports.addHours = addHours;
@@ -1,4 +1,5 @@
1
1
  import { millisecondInOneHour } from '../constants.mjs';
2
+ import { createTheDate } from '../createTheDate.mjs';
2
3
  import { toNative } from '../toNative.mjs';
3
4
 
4
5
  function addHours(...args) {
@@ -9,9 +10,7 @@ function addHours(...args) {
9
10
  const [input, hour] = args;
10
11
  const date = toNative(input);
11
12
  date.setTime(date.getTime() + (hour * millisecondInOneHour));
12
- const timestamp = date.getTime();
13
- const isNegative = timestamp < 0;
14
- return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
13
+ return createTheDate(date.getTime());
15
14
  }
16
15
 
17
16
  export { addHours };
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var createTheDate = require('../createTheDate.cjs');
3
4
  var toNative = require('../toNative.cjs');
4
5
 
5
6
  function addMilliseconds(...args) {
@@ -10,9 +11,7 @@ function addMilliseconds(...args) {
10
11
  const [input, millisecond] = args;
11
12
  const date = toNative.toNative(input);
12
13
  date.setTime(date.getTime() + millisecond);
13
- const timestamp = date.getTime();
14
- const isNegative = timestamp < 0;
15
- return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
14
+ return createTheDate.createTheDate(date.getTime());
16
15
  }
17
16
 
18
17
  exports.addMilliseconds = addMilliseconds;
@@ -1,3 +1,4 @@
1
+ import { createTheDate } from '../createTheDate.mjs';
1
2
  import { toNative } from '../toNative.mjs';
2
3
 
3
4
  function addMilliseconds(...args) {
@@ -8,9 +9,7 @@ function addMilliseconds(...args) {
8
9
  const [input, millisecond] = args;
9
10
  const date = toNative(input);
10
11
  date.setTime(date.getTime() + millisecond);
11
- const timestamp = date.getTime();
12
- const isNegative = timestamp < 0;
13
- return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
12
+ return createTheDate(date.getTime());
14
13
  }
15
14
 
16
15
  export { addMilliseconds };
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var constants = require('../constants.cjs');
4
+ var createTheDate = require('../createTheDate.cjs');
4
5
  var toNative = require('../toNative.cjs');
5
6
 
6
7
  function addMinutes(...args) {
@@ -11,9 +12,7 @@ function addMinutes(...args) {
11
12
  const [input, minute] = args;
12
13
  const date = toNative.toNative(input);
13
14
  date.setTime(date.getTime() + (minute * constants.millisecondInOneMinute));
14
- const timestamp = date.getTime();
15
- const isNegative = timestamp < 0;
16
- return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
15
+ return createTheDate.createTheDate(date.getTime());
17
16
  }
18
17
 
19
18
  exports.addMinutes = addMinutes;
@@ -1,4 +1,5 @@
1
1
  import { millisecondInOneMinute } from '../constants.mjs';
2
+ import { createTheDate } from '../createTheDate.mjs';
2
3
  import { toNative } from '../toNative.mjs';
3
4
 
4
5
  function addMinutes(...args) {
@@ -9,9 +10,7 @@ function addMinutes(...args) {
9
10
  const [input, minute] = args;
10
11
  const date = toNative(input);
11
12
  date.setTime(date.getTime() + (minute * millisecondInOneMinute));
12
- const timestamp = date.getTime();
13
- const isNegative = timestamp < 0;
14
- return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
13
+ return createTheDate(date.getTime());
15
14
  }
16
15
 
17
16
  export { addMinutes };
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var createTheDate = require('../createTheDate.cjs');
3
4
  var toNative = require('../toNative.cjs');
4
5
 
5
6
  function addMonths(...args) {
@@ -10,9 +11,7 @@ function addMonths(...args) {
10
11
  const [input, month] = args;
11
12
  const date = toNative.toNative(input);
12
13
  date.setUTCMonth(date.getUTCMonth() + month);
13
- const timestamp = date.getTime();
14
- const isNegative = timestamp < 0;
15
- return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
14
+ return createTheDate.createTheDate(date.getTime());
16
15
  }
17
16
 
18
17
  exports.addMonths = addMonths;
@@ -1,3 +1,4 @@
1
+ import { createTheDate } from '../createTheDate.mjs';
1
2
  import { toNative } from '../toNative.mjs';
2
3
 
3
4
  function addMonths(...args) {
@@ -8,9 +9,7 @@ function addMonths(...args) {
8
9
  const [input, month] = args;
9
10
  const date = toNative(input);
10
11
  date.setUTCMonth(date.getUTCMonth() + month);
11
- const timestamp = date.getTime();
12
- const isNegative = timestamp < 0;
13
- return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
12
+ return createTheDate(date.getTime());
14
13
  }
15
14
 
16
15
  export { addMonths };
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var constants = require('../constants.cjs');
4
+ var createTheDate = require('../createTheDate.cjs');
4
5
  var toNative = require('../toNative.cjs');
5
6
 
6
7
  function addSeconds(...args) {
@@ -11,9 +12,7 @@ function addSeconds(...args) {
11
12
  const [input, second] = args;
12
13
  const date = toNative.toNative(input);
13
14
  date.setTime(date.getTime() + (second * constants.millisecondsInOneSecond));
14
- const timestamp = date.getTime();
15
- const isNegative = timestamp < 0;
16
- return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
15
+ return createTheDate.createTheDate(date.getTime());
17
16
  }
18
17
 
19
18
  exports.addSeconds = addSeconds;
@@ -1,4 +1,5 @@
1
1
  import { millisecondsInOneSecond } from '../constants.mjs';
2
+ import { createTheDate } from '../createTheDate.mjs';
2
3
  import { toNative } from '../toNative.mjs';
3
4
 
4
5
  function addSeconds(...args) {
@@ -9,9 +10,7 @@ function addSeconds(...args) {
9
10
  const [input, second] = args;
10
11
  const date = toNative(input);
11
12
  date.setTime(date.getTime() + (second * millisecondsInOneSecond));
12
- const timestamp = date.getTime();
13
- const isNegative = timestamp < 0;
14
- return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
13
+ return createTheDate(date.getTime());
15
14
  }
16
15
 
17
16
  export { addSeconds };
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ var createTheDate = require('../createTheDate.cjs');
4
+ var createTheTime = require('../createTheTime.cjs');
5
+ var toTimestamp = require('../toTimestamp.cjs');
6
+ var toTimeValue = require('../toTimeValue.cjs');
7
+
8
+ function addTime(...args) {
9
+ if (args.length === 1) {
10
+ const [time] = args;
11
+ return (input) => addTime(input, time);
12
+ }
13
+ const [input, time] = args;
14
+ const timeTimestamp = toTimeValue.toTimeValue(time);
15
+ if (input.startsWith("date")) {
16
+ return createTheDate.createTheDate(toTimestamp.toTimestamp(input) + timeTimestamp);
17
+ }
18
+ return createTheTime.createTheTime(toTimeValue.toTimeValue(input) + timeTimestamp);
19
+ }
20
+
21
+ exports.addTime = addTime;
@@ -0,0 +1,5 @@
1
+ import type { TheDate, TheTime } from "../types";
2
+ export declare function addTime<GenericInput extends TheDate>(time: TheTime): (input: GenericInput) => TheDate;
3
+ export declare function addTime<GenericInput extends TheTime>(time: TheTime): (input: GenericInput) => TheTime;
4
+ export declare function addTime<GenericInput extends TheDate>(input: GenericInput, time: TheTime): TheDate;
5
+ export declare function addTime<GenericInput extends TheTime>(input: GenericInput, time: TheTime): TheTime;
@@ -0,0 +1,19 @@
1
+ import { createTheDate } from '../createTheDate.mjs';
2
+ import { createTheTime } from '../createTheTime.mjs';
3
+ import { toTimestamp } from '../toTimestamp.mjs';
4
+ import { toTimeValue } from '../toTimeValue.mjs';
5
+
6
+ function addTime(...args) {
7
+ if (args.length === 1) {
8
+ const [time] = args;
9
+ return (input) => addTime(input, time);
10
+ }
11
+ const [input, time] = args;
12
+ const timeTimestamp = toTimeValue(time);
13
+ if (input.startsWith("date")) {
14
+ return createTheDate(toTimestamp(input) + timeTimestamp);
15
+ }
16
+ return createTheTime(toTimeValue(input) + timeTimestamp);
17
+ }
18
+
19
+ export { addTime };
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var constants = require('../constants.cjs');
4
+ var createTheDate = require('../createTheDate.cjs');
4
5
  var toNative = require('../toNative.cjs');
5
6
 
6
7
  function addWeeks(...args) {
@@ -11,9 +12,7 @@ function addWeeks(...args) {
11
12
  const [input, week] = args;
12
13
  const date = toNative.toNative(input);
13
14
  date.setTime(date.getTime() + (week * constants.millisecondInOneWeek));
14
- const timestamp = date.getTime();
15
- const isNegative = timestamp < 0;
16
- return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
15
+ return createTheDate.createTheDate(date.getTime());
17
16
  }
18
17
 
19
18
  exports.addWeeks = addWeeks;