@powerlines/plugin-date 0.12.140 → 0.12.142

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 (204) hide show
  1. package/dist/index-CA4VvAY_.d.mts +1 -0
  2. package/dist/index-CmCelmEL.d.cts +1 -0
  3. package/dist/index.cjs +13844 -17
  4. package/dist/index.d.cts +40 -7
  5. package/dist/index.d.mts +40 -9
  6. package/dist/index.mjs +13800 -6
  7. package/dist/plugin-BUfZ6cT1.d.cts +4432 -0
  8. package/dist/plugin-CuNMs4r-.d.mts +4434 -0
  9. package/dist/plugin-DHXHjv16.cjs +0 -0
  10. package/dist/plugin-ufqFO5xS.mjs +1 -0
  11. package/dist/runtime-B7WoCmC4.mjs +1 -0
  12. package/dist/runtime-B8LVkjWB.d.cts +711 -0
  13. package/dist/runtime-CiYq8JJ6.d.mts +711 -0
  14. package/dist/runtime-D4zTdSwv.cjs +0 -0
  15. package/dist/types/index.cjs +3 -0
  16. package/dist/types/index.d.cts +3 -2
  17. package/dist/types/index.d.mts +3 -2
  18. package/dist/types/index.mjs +4 -0
  19. package/dist/types/plugin.cjs +1 -0
  20. package/dist/types/plugin.d.cts +1 -42
  21. package/dist/types/plugin.d.mts +1 -42
  22. package/dist/types/plugin.mjs +2 -0
  23. package/dist/types/runtime.cjs +1 -0
  24. package/dist/types/runtime.d.cts +1 -710
  25. package/dist/types/runtime.d.mts +1 -710
  26. package/dist/types/runtime.mjs +2 -0
  27. package/dist/types-BReKsBV6.mjs +1 -0
  28. package/dist/types-CBTc19th.cjs +0 -0
  29. package/package.json +3 -3
  30. package/dist/_virtual/rolldown_runtime.cjs +0 -37
  31. package/dist/_virtual/rolldown_runtime.mjs +0 -29
  32. package/dist/components/date-fns.cjs +0 -527
  33. package/dist/components/date-fns.d.cts +0 -13
  34. package/dist/components/date-fns.d.mts +0 -13
  35. package/dist/components/date-fns.mjs +0 -527
  36. package/dist/components/dayjs.cjs +0 -472
  37. package/dist/components/dayjs.d.cts +0 -13
  38. package/dist/components/dayjs.d.mts +0 -13
  39. package/dist/components/dayjs.mjs +0 -472
  40. package/dist/components/index.cjs +0 -4
  41. package/dist/components/index.d.mts +0 -4
  42. package/dist/components/index.mjs +0 -6
  43. package/dist/components/luxon.cjs +0 -476
  44. package/dist/components/luxon.d.cts +0 -13
  45. package/dist/components/luxon.d.mts +0 -13
  46. package/dist/components/luxon.mjs +0 -476
  47. package/dist/components/moment.cjs +0 -462
  48. package/dist/components/moment.d.cts +0 -13
  49. package/dist/components/moment.d.mts +0 -13
  50. package/dist/components/moment.mjs +0 -462
  51. package/dist/deepkit/schemas/reflection.cjs +0 -3998
  52. package/dist/deepkit/schemas/reflection.d.cts +0 -1560
  53. package/dist/deepkit/schemas/reflection.d.mts +0 -1560
  54. package/dist/deepkit/schemas/reflection.mjs +0 -3996
  55. package/dist/deepkit/schemas/reflection2.cjs +0 -4112
  56. package/dist/deepkit/schemas/reflection2.mjs +0 -4110
  57. package/dist/deepkit/src/capnp.cjs +0 -913
  58. package/dist/deepkit/src/capnp.mjs +0 -911
  59. package/dist/deepkit/src/esbuild-plugin.cjs +0 -47
  60. package/dist/deepkit/src/esbuild-plugin.mjs +0 -46
  61. package/dist/deepkit/src/reflect-type.cjs +0 -22
  62. package/dist/deepkit/src/reflect-type.mjs +0 -20
  63. package/dist/deepkit/src/resolve-reflections.cjs +0 -16
  64. package/dist/deepkit/src/resolve-reflections.mjs +0 -15
  65. package/dist/deepkit/src/transformer.cjs +0 -52
  66. package/dist/deepkit/src/transformer.mjs +0 -49
  67. package/dist/deepkit/src/transpile.cjs +0 -29
  68. package/dist/deepkit/src/transpile.mjs +0 -27
  69. package/dist/deepkit/src/types.d.cts +0 -10
  70. package/dist/deepkit/src/types.d.mts +0 -10
  71. package/dist/deepkit/src/utilities.cjs +0 -66
  72. package/dist/deepkit/src/utilities.mjs +0 -65
  73. package/dist/deepkit/src/vendor/type-compiler/index.cjs +0 -38
  74. package/dist/deepkit/src/vendor/type-compiler/index.mjs +0 -19
  75. package/dist/deepkit/src/vendor/type.cjs +0 -20
  76. package/dist/deepkit/src/vendor/type.d.cts +0 -7
  77. package/dist/deepkit/src/vendor/type.d.mts +0 -7
  78. package/dist/deepkit/src/vendor/type.mjs +0 -11
  79. package/dist/plugin-alloy/src/core/components/output.cjs +0 -38
  80. package/dist/plugin-alloy/src/core/components/output.mjs +0 -37
  81. package/dist/plugin-alloy/src/core/components/single-line-comment.cjs +0 -20
  82. package/dist/plugin-alloy/src/core/components/single-line-comment.mjs +0 -19
  83. package/dist/plugin-alloy/src/core/components/source-file.cjs +0 -60
  84. package/dist/plugin-alloy/src/core/components/source-file.mjs +0 -58
  85. package/dist/plugin-alloy/src/core/contexts/context.cjs +0 -60
  86. package/dist/plugin-alloy/src/core/contexts/context.mjs +0 -54
  87. package/dist/plugin-alloy/src/core/contexts/index.cjs +0 -2
  88. package/dist/plugin-alloy/src/core/contexts/index.mjs +0 -4
  89. package/dist/plugin-alloy/src/core/contexts/reflection.cjs +0 -46
  90. package/dist/plugin-alloy/src/core/contexts/reflection.mjs +0 -42
  91. package/dist/plugin-alloy/src/helpers/refkey.cjs +0 -16
  92. package/dist/plugin-alloy/src/helpers/refkey.mjs +0 -15
  93. package/dist/plugin-alloy/src/index.cjs +0 -90
  94. package/dist/plugin-alloy/src/index.mjs +0 -88
  95. package/dist/plugin-alloy/src/markdown/components/markdown-file.cjs +0 -7
  96. package/dist/plugin-alloy/src/markdown/components/markdown-file.mjs +0 -9
  97. package/dist/plugin-alloy/src/markdown/components/markdown-table.cjs +0 -5
  98. package/dist/plugin-alloy/src/markdown/components/markdown-table.mjs +0 -7
  99. package/dist/plugin-alloy/src/markdown/contexts/markdown-table.cjs +0 -17
  100. package/dist/plugin-alloy/src/markdown/contexts/markdown-table.mjs +0 -17
  101. package/dist/plugin-alloy/src/types/components.d.mts +0 -4
  102. package/dist/plugin-alloy/src/types/index.d.mts +0 -2
  103. package/dist/plugin-alloy/src/types/plugin.d.cts +0 -37
  104. package/dist/plugin-alloy/src/types/plugin.d.mts +0 -37
  105. package/dist/plugin-alloy/src/typescript/components/builtin-file.cjs +0 -47
  106. package/dist/plugin-alloy/src/typescript/components/builtin-file.mjs +0 -46
  107. package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.cjs +0 -75
  108. package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.mjs +0 -73
  109. package/dist/plugin-alloy/src/typescript/components/tsdoc.cjs +0 -359
  110. package/dist/plugin-alloy/src/typescript/components/tsdoc.mjs +0 -350
  111. package/dist/plugin-alloy/src/typescript/components/typescript-file.cjs +0 -143
  112. package/dist/plugin-alloy/src/typescript/components/typescript-file.mjs +0 -140
  113. package/dist/plugin-alloy/src/typescript/components/typescript-interface.cjs +0 -53
  114. package/dist/plugin-alloy/src/typescript/components/typescript-interface.mjs +0 -52
  115. package/dist/plugin-alloy/src/typescript/components/typescript-object.cjs +0 -94
  116. package/dist/plugin-alloy/src/typescript/components/typescript-object.mjs +0 -93
  117. package/dist/plugin-automd/src/index.cjs +0 -101
  118. package/dist/plugin-automd/src/index.mjs +0 -98
  119. package/dist/plugin-automd/src/types/plugin.d.cts +0 -38
  120. package/dist/plugin-automd/src/types/plugin.d.mts +0 -40
  121. package/dist/plugin-automd/src/types/toc.d.cts +0 -33
  122. package/dist/plugin-automd/src/types/toc.d.mts +0 -33
  123. package/dist/plugin-babel/src/helpers/ast-utils.cjs +0 -10
  124. package/dist/plugin-babel/src/helpers/ast-utils.mjs +0 -9
  125. package/dist/plugin-babel/src/helpers/create-plugin.cjs +0 -41
  126. package/dist/plugin-babel/src/helpers/create-plugin.mjs +0 -39
  127. package/dist/plugin-babel/src/helpers/filters.cjs +0 -23
  128. package/dist/plugin-babel/src/helpers/filters.mjs +0 -21
  129. package/dist/plugin-babel/src/helpers/index.cjs +0 -5
  130. package/dist/plugin-babel/src/helpers/index.mjs +0 -7
  131. package/dist/plugin-babel/src/helpers/module-helpers.cjs +0 -38
  132. package/dist/plugin-babel/src/helpers/module-helpers.mjs +0 -35
  133. package/dist/plugin-babel/src/helpers/options.cjs +0 -50
  134. package/dist/plugin-babel/src/helpers/options.mjs +0 -47
  135. package/dist/plugin-babel/src/index.cjs +0 -91
  136. package/dist/plugin-babel/src/index.mjs +0 -89
  137. package/dist/plugin-babel/src/types/index.d.mts +0 -1
  138. package/dist/plugin-babel/src/types/plugin.d.cts +0 -15
  139. package/dist/plugin-babel/src/types/plugin.d.mts +0 -15
  140. package/dist/plugin-env/src/babel/index.cjs +0 -1
  141. package/dist/plugin-env/src/babel/index.mjs +0 -3
  142. package/dist/plugin-env/src/babel/plugin.cjs +0 -121
  143. package/dist/plugin-env/src/babel/plugin.mjs +0 -119
  144. package/dist/plugin-env/src/components/docs.cjs +0 -9
  145. package/dist/plugin-env/src/components/docs.mjs +0 -11
  146. package/dist/plugin-env/src/components/env.cjs +0 -487
  147. package/dist/plugin-env/src/components/env.mjs +0 -484
  148. package/dist/plugin-env/src/components/index.cjs +0 -2
  149. package/dist/plugin-env/src/components/index.mjs +0 -4
  150. package/dist/plugin-env/src/helpers/automd-generator.cjs +0 -22
  151. package/dist/plugin-env/src/helpers/automd-generator.mjs +0 -21
  152. package/dist/plugin-env/src/helpers/create-reflection-resource.cjs +0 -55
  153. package/dist/plugin-env/src/helpers/create-reflection-resource.mjs +0 -54
  154. package/dist/plugin-env/src/helpers/index.cjs +0 -6
  155. package/dist/plugin-env/src/helpers/index.mjs +0 -8
  156. package/dist/plugin-env/src/helpers/load.cjs +0 -83
  157. package/dist/plugin-env/src/helpers/load.mjs +0 -80
  158. package/dist/plugin-env/src/helpers/persistence.cjs +0 -200
  159. package/dist/plugin-env/src/helpers/persistence.mjs +0 -189
  160. package/dist/plugin-env/src/helpers/reflect.cjs +0 -125
  161. package/dist/plugin-env/src/helpers/reflect.mjs +0 -117
  162. package/dist/plugin-env/src/helpers/source-file-env.cjs +0 -24
  163. package/dist/plugin-env/src/helpers/source-file-env.mjs +0 -23
  164. package/dist/plugin-env/src/helpers/template-helpers.cjs +0 -2
  165. package/dist/plugin-env/src/helpers/template-helpers.mjs +0 -4
  166. package/dist/plugin-env/src/index.cjs +0 -172
  167. package/dist/plugin-env/src/index.mjs +0 -170
  168. package/dist/plugin-env/src/types/plugin.d.cts +0 -151
  169. package/dist/plugin-env/src/types/plugin.d.mts +0 -153
  170. package/dist/plugin-env/src/types/runtime.d.cts +0 -792
  171. package/dist/plugin-env/src/types/runtime.d.mts +0 -792
  172. package/dist/powerlines/src/lib/build/esbuild.cjs +0 -102
  173. package/dist/powerlines/src/lib/build/esbuild.mjs +0 -100
  174. package/dist/powerlines/src/lib/entry.cjs +0 -12
  175. package/dist/powerlines/src/lib/entry.mjs +0 -14
  176. package/dist/powerlines/src/lib/logger.cjs +0 -41
  177. package/dist/powerlines/src/lib/logger.mjs +0 -39
  178. package/dist/powerlines/src/lib/utilities/bundle.cjs +0 -35
  179. package/dist/powerlines/src/lib/utilities/bundle.mjs +0 -34
  180. package/dist/powerlines/src/lib/utilities/file-header.cjs +0 -22
  181. package/dist/powerlines/src/lib/utilities/file-header.mjs +0 -21
  182. package/dist/powerlines/src/lib/utilities/resolve.cjs +0 -30
  183. package/dist/powerlines/src/lib/utilities/resolve.mjs +0 -29
  184. package/dist/powerlines/src/plugin-utils/paths.cjs +0 -1
  185. package/dist/powerlines/src/plugin-utils/paths.mjs +0 -3
  186. package/dist/powerlines/src/types/babel.d.cts +0 -22
  187. package/dist/powerlines/src/types/babel.d.mts +0 -22
  188. package/dist/powerlines/src/types/build.d.cts +0 -145
  189. package/dist/powerlines/src/types/build.d.mts +0 -147
  190. package/dist/powerlines/src/types/commands.d.cts +0 -8
  191. package/dist/powerlines/src/types/commands.d.mts +0 -9
  192. package/dist/powerlines/src/types/config.d.cts +0 -380
  193. package/dist/powerlines/src/types/config.d.mts +0 -381
  194. package/dist/powerlines/src/types/context.d.cts +0 -414
  195. package/dist/powerlines/src/types/context.d.mts +0 -416
  196. package/dist/powerlines/src/types/fs.d.cts +0 -486
  197. package/dist/powerlines/src/types/fs.d.mts +0 -486
  198. package/dist/powerlines/src/types/hooks.d.mts +0 -2
  199. package/dist/powerlines/src/types/plugin.d.cts +0 -231
  200. package/dist/powerlines/src/types/plugin.d.mts +0 -231
  201. package/dist/powerlines/src/types/resolved.d.cts +0 -82
  202. package/dist/powerlines/src/types/resolved.d.mts +0 -83
  203. package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
  204. package/dist/powerlines/src/types/tsconfig.d.mts +0 -69
@@ -1,462 +0,0 @@
1
- import { getFileHeader } from "../powerlines/src/lib/utilities/file-header.mjs";
2
-
3
- //#region src/components/moment.ts
4
- /**
5
- * Generates the Powerlines configuration file.
6
- *
7
- * @param context - The build context containing runtime information.
8
- * @returns A string representing the configuration file content.
9
- */
10
- function momentModule(context) {
11
- return `
12
- /**
13
- * The Date module provides utility functions for date manipulation and formatting
14
- *
15
- * @module ${context.config.output.builtinPrefix}:date
16
- */
17
-
18
- ${getFileHeader(context)}
19
-
20
- import defaultMoment, { LongDateFormatKey } from "moment";
21
- import {
22
- StormDateInterface,
23
- DateFormats,
24
- TimeUnit
25
- } from "@powerlines/plugin-date/types/runtime";
26
-
27
- type Moment = defaultMoment.Moment;
28
-
29
- export const formats: DateFormats = {
30
- normalDateWithWeekday: "ddd, MMM D",
31
- normalDate: "D MMMM",
32
- shortDate: "MMM D",
33
- monthAndDate: "MMMM D",
34
- dayOfMonth: "D",
35
- year: "YYYY",
36
- month: "MMMM",
37
- monthShort: "MMM",
38
- monthAndYear: "MMMM YYYY",
39
- weekday: "dddd",
40
- weekdayShort: "ddd",
41
- minutes: "mm",
42
- hours12h: "hh",
43
- hours24h: "HH",
44
- seconds: "ss",
45
- fullTime: "LT",
46
- fullTime12h: "hh:mm A",
47
- fullTime24h: "HH:mm",
48
- fullDate: "ll",
49
- fullDateWithWeekday: "dddd, LL",
50
- fullDateTime: "lll",
51
- fullDateTime12h: "ll hh:mm A",
52
- fullDateTime24h: "ll HH:mm",
53
- keyboardDate: "L",
54
- keyboardDateTime: "L LT",
55
- keyboardDateTime12h: "L hh:mm A",
56
- keyboardDateTime24h: "L HH:mm",
57
- systemDateTime: "L HH:mm:ss.SSS",
58
- filePathDateTime: "L_HH-mm-ss-SSS"
59
- };
60
-
61
- export let locale = "${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale ? `${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale}` : "en-US"}";
62
-
63
- export const type = "moment";
64
-
65
- const moment = defaultMoment;
66
-
67
- /**
68
- * Creates a date object using the provided value.
69
- *
70
- * @remarks
71
- * This function creates a date object using the provided value. If the value is \`null\`, it returns \`null\`. If the value is \`undefined\`, it returns the current date. If the value is a string, it parses the string as a date. If the value is a number, it treats it as a timestamp. If the value is a date object, it returns the date object.
72
- *
73
- * @example
74
- * \`\`\`ts
75
- * import { createDate } from "storm:date";
76
- *
77
- * const date = createDate("2023-10-01");
78
- * console.log(date.format("YYYY-MM-DD")); // Outputs: 2023-10-01
79
- * \`\`\`
80
- *
81
- * @param value - The value to create the date object from.
82
- * @returns A date object or \`null\` if the value is \`null\`.
83
- */
84
- export function createDate<
85
- TArg extends unknown = undefined,
86
- TResultingDate extends unknown = TArg extends null
87
- ? null
88
- : TArg extends undefined
89
- ? defaultMoment.Moment
90
- : defaultMoment.Moment | null
91
- >(value?: TArg): TResultingDate {
92
- if (value === null) {
93
- return null as TResultingDate;
94
- }
95
-
96
- const _moment = moment(value);
97
- if (locale) {
98
- _moment.locale(locale);
99
- }
100
-
101
- return _moment as TResultingDate;
102
- }
103
-
104
-
105
- export function is12HourCycleInCurrentLocale(): boolean {
106
- return /A|a/.test(
107
- moment.localeData(getCurrentLocaleCode()).longDateFormat("LT")
108
- );
109
- };
110
-
111
- export function getFormatHelperText(format: string) {
112
- // @see https://github.com/moment/moment/blob/develop/src/lib/format/format.js#L6
113
- const localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})|./g;
114
-
115
- return (
116
- format
117
- .match(localFormattingTokens)
118
- ?.map((token) => {
119
- const firstCharacter = token[0];
120
- if (firstCharacter === "L" || firstCharacter === ";") {
121
- return moment
122
- .localeData(getCurrentLocaleCode())
123
- .longDateFormat(token as LongDateFormatKey);
124
- }
125
-
126
- return token;
127
- })
128
- .join("")
129
- .replace(/a/gi, "(a|p)m")
130
- .toLocaleLowerCase() ?? format
131
- );
132
- };
133
-
134
- export function getCurrentLocaleCode() {
135
- return locale || moment.locale();
136
- };
137
-
138
- export function parseISO(isoString: string) {
139
- return moment(isoString, true);
140
- };
141
-
142
- export function toISO(value: Moment) {
143
- return value.toISOString();
144
- };
145
-
146
- export function parse(value: string, format: string) {
147
- if (value === "") {
148
- return null;
149
- }
150
-
151
- if (locale) {
152
- return moment(value, format, locale, true);
153
- }
154
-
155
- return moment(value, format, true);
156
- };
157
-
158
- export function toJsDate(value: Moment) {
159
- return value.toDate();
160
- };
161
-
162
- export function isValid(value: any) {
163
- return moment(value).isValid();
164
- };
165
-
166
- export function isNull(date: Moment) {
167
- return date === null;
168
- };
169
-
170
- export function getDiff(date: Moment, comparing: Moment | string, unit?: TimeUnit) {
171
- if (!moment(comparing).isValid()) {
172
- return 0;
173
- }
174
-
175
- return date.diff(comparing, unit);
176
- };
177
-
178
- export function isAfter(date: Moment, value: Moment) {
179
- return date.isAfter(value);
180
- };
181
-
182
- export function isBefore(date: Moment, value: Moment) {
183
- return date.isBefore(value);
184
- };
185
-
186
- export function isAfterDay(date: Moment, value: Moment) {
187
- return date.isAfter(value, "day");
188
- };
189
-
190
- export function isBeforeDay(date: Moment, value: Moment) {
191
- return date.isBefore(value, "day");
192
- };
193
-
194
- export function isBeforeMonth(date: Moment, value: Moment) {
195
- return date.isBefore(value, "month");
196
- };
197
-
198
- export function isAfterMonth(date: Moment, value: Moment) {
199
- return date.isAfter(value, "month");
200
- };
201
-
202
- export function isBeforeYear(date: Moment, value: Moment) {
203
- return date.isBefore(value, "year");
204
- };
205
-
206
- export function isAfterYear(date: Moment, value: Moment) {
207
- return date.isAfter(value, "year");
208
- };
209
-
210
- export function startOfDay(date: Moment) {
211
- return date.clone().startOf("day");
212
- };
213
-
214
- export function endOfDay(date: Moment) {
215
- return date.clone().endOf("day");
216
- };
217
-
218
- export function format(date: Moment, formatKey: keyof DateFormats) {
219
- return formatByString(date, formats[formatKey]);
220
- };
221
-
222
- export function formatByString(date: Moment, formatString: string) {
223
- const clonedDate = date.clone();
224
- if (locale) {
225
- clonedDate.locale(locale);
226
- }
227
- return clonedDate.format(formatString);
228
- };
229
-
230
- export function formatNumber(numberToFormat: string) {
231
- return numberToFormat;
232
- };
233
-
234
- export function getHours(date: Moment) {
235
- return date.get("hours");
236
- };
237
-
238
- export function addSeconds(date: Moment, count: number) {
239
- return count < 0
240
- ? date.clone().subtract(Math.abs(count), "seconds")
241
- : date.clone().add(count, "seconds");
242
- };
243
-
244
- export function addMinutes(date: Moment, count: number) {
245
- return count < 0
246
- ? date.clone().subtract(Math.abs(count), "minutes")
247
- : date.clone().add(count, "minutes");
248
- };
249
-
250
- export function addHours(date: Moment, count: number) {
251
- return count < 0
252
- ? date.clone().subtract(Math.abs(count), "hours")
253
- : date.clone().add(count, "hours");
254
- };
255
-
256
- export function addDays(date: Moment, count: number) {
257
- return count < 0
258
- ? date.clone().subtract(Math.abs(count), "days")
259
- : date.clone().add(count, "days");
260
- };
261
-
262
- export function addWeeks(date: Moment, count: number) {
263
- return count < 0
264
- ? date.clone().subtract(Math.abs(count), "weeks")
265
- : date.clone().add(count, "weeks");
266
- };
267
-
268
- export function addMonths(date: Moment, count: number) {
269
- return count < 0
270
- ? date.clone().subtract(Math.abs(count), "months")
271
- : date.clone().add(count, "months");
272
- };
273
-
274
- export function addYears(date: Moment, count: number) {
275
- return count < 0
276
- ? date.clone().subtract(Math.abs(count), "years")
277
- : date.clone().add(count, "years");
278
- };
279
-
280
- export function setHours(date: Moment, count: number) {
281
- return date.clone().hours(count);
282
- };
283
-
284
- export function getMinutes(date: Moment) {
285
- return date.get("minutes");
286
- };
287
-
288
- export function setMinutes(date: Moment, count: number) {
289
- return date.clone().minutes(count);
290
- };
291
-
292
- export function getSeconds(date: Moment) {
293
- return date.get("seconds");
294
- };
295
-
296
- export function setSeconds(date: Moment, count: number) {
297
- return date.clone().seconds(count);
298
- };
299
-
300
- export function getWeek(date: Moment) {
301
- return date.get("week");
302
- };
303
-
304
- export function getMonth(date: Moment) {
305
- return date.get("month");
306
- };
307
-
308
- export function getDaysInMonth(date: Moment) {
309
- return date.daysInMonth();
310
- };
311
-
312
- export function isSameDay(date: Moment, comparing: Moment) {
313
- return date.isSame(comparing, "day");
314
- };
315
-
316
- export function isSameMonth(date: Moment, comparing: Moment) {
317
- return date.isSame(comparing, "month");
318
- };
319
-
320
- export function isSameYear(date: Moment, comparing: Moment) {
321
- return date.isSame(comparing, "year");
322
- };
323
-
324
- export function isSameHour(date: Moment, comparing: Moment) {
325
- return date.isSame(comparing, "hour");
326
- };
327
-
328
- export function setMonth(date: Moment, count: number) {
329
- return date.clone().month(count);
330
- };
331
-
332
- export function getMeridiemText(meridiem: "am" | "pm") {
333
- if (is12HourCycleInCurrentLocale()) {
334
- // AM/PM translation only possible in those who have 12 hour cycle in locale.
335
- return moment
336
- .localeData(getCurrentLocaleCode())
337
- .meridiem(meridiem === "am" ? 0 : 13, 0, false);
338
- }
339
-
340
- return meridiem === "am" ? "AM" : "PM"; // fallback for de, ru, ...etc
341
- };
342
-
343
- export function startOfYear(date: Moment) {
344
- return date.clone().startOf("year");
345
- };
346
-
347
- export function endOfYear(date: Moment) {
348
- return date.clone().endOf("year");
349
- };
350
-
351
- export function startOfMonth(date: Moment) {
352
- return date.clone().startOf("month");
353
- };
354
-
355
- export function endOfMonth(date: Moment) {
356
- return date.clone().endOf("month");
357
- };
358
-
359
- export function startOfWeek(date: Moment) {
360
- return date.clone().startOf("week");
361
- };
362
-
363
- export function endOfWeek(date: Moment) {
364
- return date.clone().endOf("week");
365
- };
366
-
367
- export function getNextMonth(date: Moment) {
368
- return date.clone().add(1, "month");
369
- };
370
-
371
- export function getPreviousMonth(date: Moment) {
372
- return date.clone().subtract(1, "month");
373
- };
374
-
375
- export function getMonthArray(date: Moment) {
376
- const firstMonth = date.clone().startOf("year");
377
- const monthArray = [firstMonth];
378
-
379
- while (monthArray.length < 12) {
380
- const prevMonth = monthArray[monthArray.length - 1];
381
- monthArray.push(getNextMonth(prevMonth));
382
- }
383
-
384
- return monthArray;
385
- };
386
-
387
- export function getYear(date: Moment) {
388
- return date.get("year");
389
- };
390
-
391
- export function setYear(date: Moment, year: number) {
392
- return date.clone().set("year", year);
393
- };
394
-
395
- export function getDate(date: Moment) {
396
- return date.get("date");
397
- };
398
-
399
- export function setDate(date: Moment, day: number) {
400
- return date.clone().set("date", day);
401
- };
402
-
403
- export function mergeDateAndTime(date: Moment, time: Moment) {
404
- return date.hour(time.hour()).minute(time.minute()).second(time.second());
405
- };
406
-
407
- export function getWeekdays() {
408
- return moment.weekdaysShort(true);
409
- };
410
-
411
- export function isEqual(value: any, comparing: any) {
412
- if (value === null && comparing === null) {
413
- return true;
414
- }
415
-
416
- return moment(value).isSame(comparing);
417
- };
418
-
419
- export function getWeekArray(date: Moment) {
420
- const start = date.clone().startOf("month").startOf("week");
421
- const end = date.clone().endOf("month").endOf("week");
422
-
423
- let count = 0;
424
- let current = start;
425
- const nestedWeeks: Moment[][] = [];
426
-
427
- while (current.isBefore(end)) {
428
- const weekNumber = Math.floor(count / 7);
429
- nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
430
- nestedWeeks[weekNumber].push(current);
431
-
432
- current = current.clone().add(1, "day");
433
- count += 1;
434
- }
435
-
436
- return nestedWeeks;
437
- };
438
-
439
- export function getYearRange(start: Moment, end: Moment) {
440
- const startDate = moment(start).startOf("year");
441
- const endDate = moment(end).endOf("year");
442
- const years: Moment[] = [];
443
-
444
- let current = startDate;
445
- while (current.isBefore(endDate)) {
446
- years.push(current);
447
- current = current.clone().add(1, "year");
448
- }
449
-
450
- return years;
451
- };
452
-
453
- export function isWithinRange(date: Moment, [start, end]: [Moment, Moment]) {
454
- return date.isBetween(start, end, null, "[]");
455
- };
456
-
457
-
458
- `;
459
- }
460
-
461
- //#endregion
462
- export { momentModule };