@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,472 +0,0 @@
1
- const require_file_header = require('../powerlines/src/lib/utilities/file-header.cjs');
2
-
3
- //#region src/components/dayjs.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 dayjsModule(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
- ${require_file_header.getFileHeader(context)}
19
-
20
- import defaultDayjs, { QUnitType } from "dayjs";
21
- import customParseFormatPlugin from "dayjs/plugin/customParseFormat";
22
- import localizedFormatPlugin from "dayjs/plugin/localizedFormat";
23
- import isBetweenPlugin from "dayjs/plugin/isBetween";
24
- import weekOfYear from "dayjs/plugin/weekOfYear";
25
- import {
26
- StormDateInterface,
27
- DateFormats,
28
- TimeUnit
29
- } from "@powerlines/plugin-date/types/runtime";
30
-
31
- defaultDayjs.extend(customParseFormatPlugin);
32
- defaultDayjs.extend(localizedFormatPlugin);
33
- defaultDayjs.extend(isBetweenPlugin);
34
- defaultDayjs.extend(weekOfYear);
35
-
36
- interface Opts {
37
- locale?: string;
38
- /** Make sure that your dayjs instance extends customParseFormat and advancedFormat */
39
- instance?: typeof defaultDayjs;
40
- formats?: Partial<DateFormats>;
41
- }
42
-
43
- type Dayjs = defaultDayjs.Dayjs;
44
- type Constructor<TDate extends Dayjs> = (
45
- ...args: Parameters<typeof defaultDayjs>
46
- ) => TDate;
47
- const withLocale = <TDate extends Dayjs>(
48
- dayjs: any,
49
- locale?: string
50
- ): Constructor<TDate> => (!locale ? dayjs : (...args) => dayjs(...args).locale(locale));
51
-
52
- export const formats: DateFormats = {
53
- normalDateWithWeekday: "ddd, MMM D",
54
- normalDate: "D MMMM",
55
- shortDate: "MMM D",
56
- monthAndDate: "MMMM D",
57
- dayOfMonth: "D",
58
- year: "YYYY",
59
- month: "MMMM",
60
- monthShort: "MMM",
61
- monthAndYear: "MMMM YYYY",
62
- weekday: "dddd",
63
- weekdayShort: "ddd",
64
- minutes: "mm",
65
- hours12h: "hh",
66
- hours24h: "HH",
67
- seconds: "ss",
68
- fullTime: "LT",
69
- fullTime12h: "hh:mm A",
70
- fullTime24h: "HH:mm",
71
- fullDate: "ll",
72
- fullDateWithWeekday: "dddd, LL",
73
- fullDateTime: "lll",
74
- fullDateTime12h: "ll hh:mm A",
75
- fullDateTime24h: "ll HH:mm",
76
- keyboardDate: "L",
77
- keyboardDateTime: "L LT",
78
- keyboardDateTime12h: "L hh:mm A",
79
- keyboardDateTime24h: "L HH:mm",
80
- systemDateTime: "L HH:mm:ss.SSS",
81
- filePathDateTime: "L_HH-mm-ss-SSS"
82
- };
83
-
84
- export let locale = "${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale ? `${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale}` : "en-US"}";
85
-
86
- export const dayjs = withLocale(defaultDayjs, locale);
87
-
88
- export const type = "dayjs";
89
-
90
- /**
91
- * Creates a date object using the provided value.
92
- *
93
- * @remarks
94
- * 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.
95
- *
96
- * @example
97
- * \`\`\`ts
98
- * import { createDate } from "storm:date";
99
- *
100
- * const date = createDate("2023-10-01");
101
- * console.log(date.format("YYYY-MM-DD")); // Outputs: 2023-10-01
102
- * \`\`\`
103
- *
104
- * @param value - The value to create the date object from.
105
- * @returns A date object or \`null\` if the value is \`null\`.
106
- */
107
- export function createDate<
108
- TArg extends unknown = undefined,
109
- TResultingDate extends unknown = TArg extends null
110
- ? null
111
- : TArg extends undefined
112
- ? TDate
113
- : TDate | null
114
- >(value?: TArg): TResultingDate {
115
- if (value === null) {
116
- return null as TResultingDate;
117
- }
118
-
119
- return dayjs(value as any) as unknown as TResultingDate;
120
- }
121
-
122
- export function is12HourCycleInCurrentLocale() {
123
- /* istanbul ignore next */
124
- return /A|a/.test(dayjs.Ls[dayjs.locale() || $storm.env.DEFAULT_LOCALE]?.formats?.LT ?? "");
125
- };
126
-
127
- export function getCurrentLocaleCode() {
128
- return dayjs.locale() || $storm.env.DEFAULT_LOCALE;
129
- };
130
-
131
- export function getFormatHelperText(format: string) {
132
- // @see https://github.com/iamkun/dayjs/blob/dev/src/plugin/localizedFormat/index.js
133
- const localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?)|./g;
134
-
135
- return (
136
- format
137
- .match(localFormattingTokens)
138
- ?.map((token) => {
139
- const firstCharacter = token[0];
140
- if (firstCharacter === "L") {
141
- /* istanbul ignore next */
142
- return (
143
- dayjs.Ls[dayjs.locale() || $storm.env.DEFAULT_LOCALE]?.formats[
144
- token as keyof ILocale["formats"]
145
- ] ?? token
146
- );
147
- }
148
- return token;
149
- })
150
- .join("")
151
- .replace(/a/gi, "(a|p)m")
152
- .toLocaleLowerCase() ?? format
153
- );
154
- };
155
-
156
- export function parseISO(isoString: string) {
157
- return dayjs(isoString);
158
- };
159
-
160
- export function toISO(value: Dayjs) {
161
- return value.toISOString();
162
- };
163
-
164
- export function parse(value: any, format: string) {
165
- if (value === "") {
166
- return null;
167
- }
168
-
169
- return dayjs(value, format, dayjs.locale(), true);
170
- };
171
-
172
- export function toJsDate(value: Dayjs) {
173
- return value.toDate();
174
- };
175
-
176
- export function isValid(value: any) {
177
- return dayjs(value).isValid();
178
- };
179
-
180
- export function isNull(date: Dayjs | null) {
181
- return date === null;
182
- };
183
-
184
- export function getDiff(date: Dayjs, comparing: Dayjs | string, units?: Unit) {
185
- if (typeof comparing === "string") {
186
- comparing = dayjs(comparing);
187
- }
188
-
189
- if (!comparing.isValid()) {
190
- return 0;
191
- }
192
-
193
- return date.diff(comparing, units as QUnitType);
194
- };
195
-
196
- export function isAfter(date: Dayjs, value: Dayjs) {
197
- return date.isAfter(value);
198
- };
199
-
200
- export function isBefore(date: Dayjs, value: Dayjs) {
201
- return date.isBefore(value);
202
- };
203
-
204
- export function isAfterDay(date: Dayjs, value: Dayjs) {
205
- return date.isAfter(value, "day");
206
- };
207
-
208
- export function isBeforeDay(date: Dayjs, value: Dayjs) {
209
- return date.isBefore(value, "day");
210
- };
211
-
212
- export function isAfterMonth(date: Dayjs, value: Dayjs) {
213
- return date.isAfter(value, "month");
214
- };
215
-
216
- export function isBeforeMonth(date: Dayjs, value: Dayjs) {
217
- return date.isBefore(value, "month");
218
- };
219
-
220
- export function isBeforeYear(date: Dayjs, value: Dayjs) {
221
- return date.isBefore(value, "year");
222
- };
223
-
224
- export function isAfterYear(date: Dayjs, value: Dayjs) {
225
- return date.isAfter(value, "year");
226
- };
227
-
228
- export function startOfDay(date: Dayjs) {
229
- return date.startOf("day");
230
- };
231
-
232
- export function endOfDay(date: Dayjs) {
233
- return date.endOf("day");
234
- };
235
-
236
- export function format(date: Dayjs, formatKey: keyof DateFormats) {
237
- return formatByString(date, formats[formatKey]);
238
- };
239
-
240
- export function formatByString(date: Dayjs, formatString: string) {
241
- return dayjs(date).format(formatString);
242
- };
243
-
244
- export function formatNumber(numberToFormat: string) {
245
- return numberToFormat;
246
- };
247
-
248
- export function getHours(date: Dayjs) {
249
- return date.hour();
250
- };
251
-
252
- export function addSeconds(date: Dayjs, count: number) {
253
- return count < 0
254
- ? (date.subtract(Math.abs(count), "second") as Dayjs)
255
- : (date.add(count, "second") as Dayjs);
256
- };
257
-
258
- export function addMinutes(date: Dayjs, count: number) {
259
- return count < 0
260
- ? (date.subtract(Math.abs(count), "minute") as Dayjs)
261
- : (date.add(count, "minute") as Dayjs);
262
- };
263
-
264
- export function addHours(date: Dayjs, count: number) {
265
- return count < 0
266
- ? (date.subtract(Math.abs(count), "hour") as Dayjs)
267
- : (date.add(count, "hour") as Dayjs);
268
- };
269
-
270
- export function addDays(date: Dayjs, count: number) {
271
- return count < 0
272
- ? (date.subtract(Math.abs(count), "day") as Dayjs)
273
- : (date.add(count, "day") as Dayjs);
274
- };
275
-
276
- export function addWeeks(date: Dayjs, count: number) {
277
- return count < 0
278
- ? (date.subtract(Math.abs(count), "week") as Dayjs)
279
- : (date.add(count, "week") as Dayjs);
280
- };
281
-
282
- export function addMonths(date: Dayjs, count: number) {
283
- return count < 0
284
- ? (date.subtract(Math.abs(count), "month") as Dayjs)
285
- : (date.add(count, "month") as Dayjs);
286
- };
287
-
288
- export function addYears(date: Dayjs, count: number) {
289
- return count < 0
290
- ? (date.subtract(Math.abs(count), "year") as Dayjs)
291
- : (date.add(count, "year") as Dayjs);
292
- };
293
-
294
- export function setMonth(date: Dayjs, count: number) {
295
- return date.set("month", count) as Dayjs;
296
- };
297
-
298
- export function setHours(date: Dayjs, count: number) {
299
- return date.set("hour", count) as Dayjs;
300
- };
301
-
302
- export function getMinutes(date: Dayjs) {
303
- return date.minute();
304
- };
305
-
306
- export function setMinutes(date: Dayjs, count: number) {
307
- return date.set("minute", count) as Dayjs;
308
- };
309
-
310
- export function getSeconds(date: Dayjs) {
311
- return date.second();
312
- };
313
-
314
- export function setSeconds(date: Dayjs, count: number) {
315
- return date.set("second", count) as Dayjs;
316
- };
317
-
318
- export function getWeek(date: Dayjs) {
319
- return date.week();
320
- };
321
-
322
- export function getMonth(date: Dayjs) {
323
- return date.month();
324
- };
325
-
326
- export function getDate(date: Dayjs) {
327
- return date.date();
328
- };
329
-
330
- export function setDate(date: Dayjs, count: number) {
331
- return date.set("date", count) as Dayjs;
332
- };
333
-
334
- export function getDaysInMonth(date: Dayjs) {
335
- return date.daysInMonth();
336
- };
337
-
338
- export function isSameDay(date: Dayjs, comparing: Dayjs) {
339
- return date.isSame(comparing, "day");
340
- };
341
-
342
- export function isSameMonth(date: Dayjs, comparing: Dayjs) {
343
- return date.isSame(comparing, "month");
344
- };
345
-
346
- export function isSameYear(date: Dayjs, comparing: Dayjs) {
347
- return date.isSame(comparing, "year");
348
- };
349
-
350
- export function isSameHour(date: Dayjs, comparing: Dayjs) {
351
- return date.isSame(comparing, "hour");
352
- };
353
-
354
- export function getMeridiemText(meridiem: "am" | "pm") {
355
- return meridiem === "am" ? "AM" : "PM";
356
- };
357
-
358
- export function startOfYear(date: Dayjs) {
359
- return date.startOf("year") as Dayjs;
360
- };
361
-
362
- export function endOfYear(date: Dayjs) {
363
- return date.endOf("year") as Dayjs;
364
- };
365
-
366
- export function startOfMonth(date: Dayjs) {
367
- return date.startOf("month") as Dayjs;
368
- };
369
-
370
- export function endOfMonth(date: Dayjs) {
371
- return date.endOf("month") as Dayjs;
372
- };
373
-
374
- export function startOfWeek(date: Dayjs) {
375
- return date.startOf("week") as Dayjs;
376
- };
377
-
378
- export function endOfWeek(date: Dayjs) {
379
- return date.endOf("week") as Dayjs;
380
- };
381
-
382
- export function getNextMonth(date: Dayjs) {
383
- return date.add(1, "month") as Dayjs;
384
- };
385
-
386
- export function getPreviousMonth(date: Dayjs) {
387
- return date.subtract(1, "month") as Dayjs;
388
- };
389
-
390
- export function getMonthArray(date: Dayjs) {
391
- const firstMonth = date.startOf("year") as Dayjs;
392
- const monthArray = [firstMonth];
393
-
394
- while (monthArray.length < 12) {
395
- const prevMonth = monthArray[monthArray.length - 1];
396
- monthArray.push(getNextMonth(prevMonth));
397
- }
398
-
399
- return monthArray;
400
- };
401
-
402
- export function getYear(date: Dayjs) {
403
- return date.year();
404
- };
405
-
406
- export function setYear(date: Dayjs, year: number) {
407
- return date.set("year", year) as Dayjs;
408
- };
409
-
410
- export function mergeDateAndTime(date: Dayjs, time: Dayjs) {
411
- return date.hour(time.hour()).minute(time.minute()).second(time.second()) as Dayjs;
412
- };
413
-
414
- export function getWeekdays() {
415
- const start = dayjs().startOf("week");
416
- return [0, 1, 2, 3, 4, 5, 6].map((diff) =>
417
- formatByString(start.add(diff, "day"), "dd")
418
- );
419
- };
420
-
421
- export function isEqual(value: any, comparing: any) {
422
- if (value === null && comparing === null) {
423
- return true;
424
- }
425
-
426
- return dayjs(value).isSame(comparing);
427
- };
428
-
429
- export function getWeekArray(date: Dayjs) {
430
- const start = dayjs(date).startOf("month").startOf("week") as Dayjs;
431
- const end = dayjs(date).endOf("month").endOf("week") as Dayjs;
432
-
433
- let count = 0;
434
- let current = start;
435
- const nestedWeeks: Dayjs[][] = [];
436
-
437
- while (current.isBefore(end)) {
438
- const weekNumber = Math.floor(count / 7);
439
- nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
440
- nestedWeeks[weekNumber].push(current);
441
-
442
- current = current.add(1, "day") as TDate;
443
- count += 1;
444
- }
445
-
446
- return nestedWeeks;
447
- };
448
-
449
- export function getYearRange(start: Dayjs, end: Dayjs) {
450
- const startDate = start.startOf("year");
451
- const endDate = end.endOf("year");
452
- const years: Dayjs[] = [];
453
-
454
- let current = startDate;
455
- while (current.isBefore(endDate)) {
456
- years.push(current);
457
- current = current.add(1, "year");
458
- }
459
-
460
- return years;
461
- };
462
-
463
- export function isWithinRange(date: Dayjs, [start, end]: [Dayjs, Dayjs]) {
464
- return date.isBetween(start, end, null, "[]");
465
- };
466
-
467
-
468
- `;
469
- }
470
-
471
- //#endregion
472
- exports.dayjsModule = dayjsModule;
@@ -1,13 +0,0 @@
1
- import { DatePluginContext } from "../types/plugin.cjs";
2
-
3
- //#region src/components/dayjs.d.ts
4
-
5
- /**
6
- * Generates the Powerlines configuration file.
7
- *
8
- * @param context - The build context containing runtime information.
9
- * @returns A string representing the configuration file content.
10
- */
11
- declare function dayjsModule(context: DatePluginContext): string;
12
- //#endregion
13
- export { dayjsModule };
@@ -1,13 +0,0 @@
1
- import { DatePluginContext } from "../types/plugin.mjs";
2
-
3
- //#region src/components/dayjs.d.ts
4
-
5
- /**
6
- * Generates the Powerlines configuration file.
7
- *
8
- * @param context - The build context containing runtime information.
9
- * @returns A string representing the configuration file content.
10
- */
11
- declare function dayjsModule(context: DatePluginContext): string;
12
- //#endregion
13
- export { dayjsModule };