@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
@@ -0,0 +1 @@
1
+ export { };
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-date",
3
- "version": "0.12.140",
3
+ "version": "0.12.142",
4
4
  "type": "module",
5
5
  "description": "A package containing a Powerlines plugin for injecting static .env configuration values to the code so that they're accessible at runtime.",
6
6
  "repository": {
@@ -128,7 +128,7 @@
128
128
  "files": ["dist/**/*"],
129
129
  "keywords": ["powerlines", "storm-software", "powerlines-plugin"],
130
130
  "dependencies": {
131
- "@powerlines/plugin-env": "^0.15.2",
131
+ "@powerlines/plugin-env": "^0.15.4",
132
132
  "@storm-software/config-tools": "^1.188.75",
133
133
  "@stryke/path": "^0.24.1",
134
134
  "powerlines": "^0.36.26"
@@ -138,5 +138,5 @@
138
138
  "@types/node": "^24.10.4"
139
139
  },
140
140
  "publishConfig": { "access": "public" },
141
- "gitHead": "936b3cc1d4bba49e2ddfa38662e37868d0a30fd6"
141
+ "gitHead": "a703a2dd9be6175a67a9bf4847d0217be4e920af"
142
142
  }
@@ -1,37 +0,0 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) {
13
- __defProp(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- }
19
- }
20
- return to;
21
- };
22
- var __reExport = (target, mod, secondTarget, symbols) => {
23
- if (symbols) {
24
- __defProp(target, Symbol.toStringTag, { value: "Module" });
25
- secondTarget && __defProp(secondTarget, Symbol.toStringTag, { value: "Module" });
26
- }
27
- __copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default");
28
- };
29
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
30
- value: mod,
31
- enumerable: true
32
- }) : target, mod));
33
-
34
- //#endregion
35
-
36
- exports.__reExport = __reExport;
37
- exports.__toESM = __toESM;
@@ -1,29 +0,0 @@
1
- //#region rolldown:runtime
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
9
- key = keys[i];
10
- if (!__hasOwnProp.call(to, key) && key !== except) {
11
- __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- }
17
- }
18
- return to;
19
- };
20
- var __reExport = (target, mod, secondTarget, symbols) => {
21
- if (symbols) {
22
- __defProp(target, Symbol.toStringTag, { value: "Module" });
23
- secondTarget && __defProp(secondTarget, Symbol.toStringTag, { value: "Module" });
24
- }
25
- __copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default");
26
- };
27
-
28
- //#endregion
29
- export { __reExport };
@@ -1,527 +0,0 @@
1
- const require_file_header = require('../powerlines/src/lib/utilities/file-header.cjs');
2
-
3
- //#region src/components/date-fns.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 dateFnsModule(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 { DateFormats, TimeUnit } from "@powerlines/plugin-date/types/runtime";
21
- import { addDays as dateFnsAddDays } from "date-fns/addDays";
22
- import { addHours as dateFnsAddHours } from "date-fns/addHours";
23
- import { addMinutes as dateFnsAddMinutes } from "date-fns/addMinutes";
24
- import { addMonths as dateFnsAddMonths } from "date-fns/addMonths";
25
- import { addSeconds as dateFnsAddSeconds } from "date-fns/addSeconds";
26
- import { addWeeks as dateFnsAddWeeks } from "date-fns/addWeeks";
27
- import { addYears as dateFnsAddYears } from "date-fns/addYears";
28
- import { differenceInDays } from "date-fns/differenceInDays";
29
- import { differenceInHours } from "date-fns/differenceInHours";
30
- import { differenceInMilliseconds } from "date-fns/differenceInMilliseconds";
31
- import { differenceInMinutes } from "date-fns/differenceInMinutes";
32
- import { differenceInMonths } from "date-fns/differenceInMonths";
33
- import { differenceInQuarters } from "date-fns/differenceInQuarters";
34
- import { differenceInSeconds } from "date-fns/differenceInSeconds";
35
- import { differenceInWeeks } from "date-fns/differenceInWeeks";
36
- import { differenceInYears } from "date-fns/differenceInYears";
37
- import { eachDayOfInterval } from "date-fns/eachDayOfInterval";
38
- import { endOfDay as dateFnsEndOfDay } from "date-fns/endOfDay";
39
- import { endOfMonth as dateFnsEndOfMonth } from "date-fns/endOfMonth";
40
- import { endOfWeek as dateFnsEndOfWeek } from "date-fns/endOfWeek";
41
- import { endOfYear as dateFnsEndOfYear } from "date-fns/endOfYear";
42
- import { format as dateFnsFormat, longFormatters } from "date-fns/format";
43
- import { formatISO } from "date-fns/formatISO";
44
- import { getDate as dateFnsGetDate } from "date-fns/getDate";
45
- import { getDay as dateFnsGetDay } from "date-fns/getDay";
46
- import { getDaysInMonth as dateFnsGetDaysInMonth } from "date-fns/getDaysInMonth";
47
- import { getHours as dateFnsGetHours } from "date-fns/getHours";
48
- import { getMinutes as dateFnsGetMinutes } from "date-fns/getMinutes";
49
- import { getMonth as dateFnsGetMonth } from "date-fns/getMonth";
50
- import { getSeconds as dateFnsGetSeconds } from "date-fns/getSeconds";
51
- import { getWeek as dateFnsGetWeek } from "date-fns/getWeek";
52
- import { getYear as dateFnsGetYear } from "date-fns/getYear";
53
- import { isAfter as dateFnsIsAfter } from "date-fns/isAfter";
54
- import { isBefore as dateFnsIsBefore } from "date-fns/isBefore";
55
- import { isEqual as dateFnsIsEqual } from "date-fns/isEqual";
56
- import { isSameDay as dateFnsIsSameDay } from "date-fns/isSameDay";
57
- import { isSameHour as dateFnsIsSameHour } from "date-fns/isSameHour";
58
- import { isSameMonth as dateFnsIsSameMonth } from "date-fns/isSameMonth";
59
- import { isSameYear as dateFnsIsSameYear } from "date-fns/isSameYear";
60
- import { isValid as dateFnsIsValid } from "date-fns/isValid";
61
- import { isWithinInterval } from "date-fns/isWithinInterval";
62
- import { Locale } from "date-fns/locale";
63
- import { ${context.env.parsed.DEFAULT_LOCALE?.replaceAll("-", "") || "enUS"} as defaultLocale } from "date-fns/locale/${context.env.parsed.DEFAULT_LOCALE || "en-US"}";
64
- import { parse as dateFnsParse } from "date-fns/parse";
65
- import { parseISO as dateFnsParseISO } from "date-fns/parseISO";
66
- import { setDate as dateFnsSetDate } from "date-fns/setDate";
67
- import { setHours as dateFnsSetHours } from "date-fns/setHours";
68
- import { setMinutes as dateFnsSetMinutes } from "date-fns/setMinutes";
69
- import { setMonth as dateFnsSetMonth } from "date-fns/setMonth";
70
- import { setSeconds as dateFnsSetSeconds } from "date-fns/setSeconds";
71
- import { setYear as dateFnsSetYear } from "date-fns/setYear";
72
- import { startOfDay as dateFnsStartOfDay } from "date-fns/startOfDay";
73
- import { startOfMonth as dateFnsStartOfMonth } from "date-fns/startOfMonth";
74
- import { startOfWeek as dateFnsStartOfWeek } from "date-fns/startOfWeek";
75
- import { startOfYear as dateFnsStartOfYear } from "date-fns/startOfYear";
76
-
77
- export const formats: DateFormats = {
78
- dayOfMonth: "d",
79
- fullDate: "PP",
80
- fullDateWithWeekday: "PPPP",
81
- fullDateTime: "PP p",
82
- fullDateTime12h: "PP hh:mm aa",
83
- fullDateTime24h: "PP HH:mm",
84
- fullTime: "p",
85
- fullTime12h: "hh:mm aa",
86
- fullTime24h: "HH:mm",
87
- hours12h: "hh",
88
- hours24h: "HH",
89
- keyboardDate: "P",
90
- keyboardDateTime: "P p",
91
- keyboardDateTime12h: "P hh:mm aa",
92
- keyboardDateTime24h: "P HH:mm",
93
- systemDateTime: "P HH:mm:ss.SSS",
94
- filePathDateTime: "P_HH-mm-ss-SSS",
95
- minutes: "mm",
96
- month: "LLLL",
97
- monthAndDate: "MMMM d",
98
- monthAndYear: "LLLL yyyy",
99
- monthShort: "MMM",
100
- weekday: "EEEE",
101
- weekdayShort: "EEE",
102
- normalDate: "d MMMM",
103
- normalDateWithWeekday: "EEE, MMM d",
104
- seconds: "ss",
105
- shortDate: "MMM d",
106
- year: "yyyy"
107
- };
108
-
109
- export const locale: Locale = defaultLocale;
110
-
111
- /**
112
- * Creates a date object using the provided value.
113
- *
114
- * @remarks
115
- * 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.
116
- *
117
- * @example
118
- * \`\`\`ts
119
- * import { createDate } from "storm:date";
120
- *
121
- * const date = createDate("2023-10-01");
122
- * console.log(date.format("YYYY-MM-DD")); // Outputs: 2023-10-01
123
- * \`\`\`
124
- *
125
- * @param value - The value to create the date object from.
126
- * @returns A date object or \`null\` if the value is \`null\`.
127
- */
128
- export function createDate<
129
- TArg = undefined,
130
- TResultingDate = TArg extends null
131
- ? null
132
- : TArg extends undefined
133
- ? Date
134
- : Date | null
135
- >(value?: TArg): TResultingDate {
136
- if (typeof value === "undefined") {
137
- return new Date() as TResultingDate;
138
- }
139
- if (value === null) {
140
- return null as TResultingDate;
141
- }
142
- return new Date(value as string | number) as TResultingDate;
143
- }
144
-
145
- export const type = "date-fns";
146
-
147
- // Note: date-fns input types are more lenient than this adapter, so we need to expose our more
148
- // strict signature and delegate to the more lenient signature. Otherwise, we have downstream type errors upon usage.
149
- export function is12HourCycleInCurrentLocale(): boolean {
150
- if (locale) {
151
- return /a/.test(locale.formatLong?.time({}));
152
- }
153
-
154
- // By default date-fns is using en-US locale with am/pm enabled
155
- return true;
156
- }
157
-
158
- export function getFormatHelperText(format: string) {
159
- // @see https://github.com/date-fns/date-fns/blob/master/src/format/index.js#L31
160
- const longFormatRegexp = /P+p+|P+|p+|''|'(?:''|[^'])+(?:'|$)|./g;
161
- const _locale = locale || defaultLocale;
162
-
163
- return (
164
- format
165
- .match(longFormatRegexp)
166
- ?.map(token => {
167
- const firstCharacter = token[0];
168
- if (firstCharacter === "p" || firstCharacter === "P") {
169
- const longFormatter = longFormatters[firstCharacter]!;
170
-
171
- return longFormatter(token, _locale.formatLong);
172
- }
173
-
174
- return token;
175
- })
176
- .join("")
177
- .replace(/aaa|aa|a/g, "(a|p)m")
178
- .toLocaleLowerCase() ?? format
179
- );
180
- }
181
-
182
- export function parseISO(isoString: string) {
183
- return dateFnsParseISO(isoString);
184
- }
185
-
186
- export function toISO(value: Date) {
187
- return formatISO(value, {
188
- format: "extended"
189
- });
190
- }
191
-
192
- export function getCurrentLocaleCode() {
193
- return locale?.code || $storm.env.DEFAULT_LOCALE;
194
- }
195
-
196
- export function addSeconds(value: Date, count: number) {
197
- return dateFnsAddSeconds(value, count);
198
- }
199
-
200
- export function addMinutes(value: Date, count: number) {
201
- return dateFnsAddMinutes(value, count);
202
- }
203
-
204
- export function addHours(value: Date, count: number) {
205
- return dateFnsAddHours(value, count);
206
- }
207
-
208
- export function addDays(value: Date, count: number) {
209
- return dateFnsAddDays(value, count);
210
- }
211
-
212
- export function addWeeks(value: Date, count: number) {
213
- return dateFnsAddWeeks(value, count);
214
- }
215
-
216
- export function addMonths(value: Date, count: number) {
217
- return dateFnsAddMonths(value, count);
218
- }
219
-
220
- export function addYears(value: Date, count: number) {
221
- return dateFnsAddYears(value, count);
222
- }
223
-
224
- export function isValid(value: any) {
225
- return dateFnsIsValid(createDate(value));
226
- }
227
-
228
- export function getDiff(
229
- value: Date,
230
- comparing: Date | string,
231
- unit?: TimeUnit
232
- ) {
233
- // we output 0 if the compare date is string and parsing is not valid
234
- const dateToCompare = createDate(comparing) ?? value;
235
- if (!isValid(dateToCompare)) {
236
- return 0;
237
- }
238
-
239
- switch (unit) {
240
- case "years":
241
- return differenceInYears(value, dateToCompare);
242
- case "quarters":
243
- return differenceInQuarters(value, dateToCompare);
244
- case "months":
245
- return differenceInMonths(value, dateToCompare);
246
- case "weeks":
247
- return differenceInWeeks(value, dateToCompare);
248
- case "days":
249
- return differenceInDays(value, dateToCompare);
250
- case "hours":
251
- return differenceInHours(value, dateToCompare);
252
- case "minutes":
253
- return differenceInMinutes(value, dateToCompare);
254
- case "seconds":
255
- return differenceInSeconds(value, dateToCompare);
256
- case "milliseconds":
257
- case undefined:
258
- default:
259
- return differenceInMilliseconds(value, dateToCompare);
260
- }
261
- }
262
-
263
- export function isAfter(value: Date, comparing: Date) {
264
- return dateFnsIsAfter(value, comparing);
265
- }
266
-
267
- export function isBefore(value: Date, comparing: Date) {
268
- return dateFnsIsBefore(value, comparing);
269
- }
270
-
271
- export function startOfDay(value: Date) {
272
- return dateFnsStartOfDay(value);
273
- }
274
-
275
- export function endOfDay(value: Date) {
276
- return dateFnsEndOfDay(value);
277
- }
278
-
279
- export function getHours(value: Date) {
280
- return dateFnsGetHours(value);
281
- }
282
-
283
- export function setHours(value: Date, count: number) {
284
- return dateFnsSetHours(value, count);
285
- }
286
-
287
- export function setMinutes(value: Date, count: number) {
288
- return dateFnsSetMinutes(value, count);
289
- }
290
-
291
- export function getSeconds(value: Date) {
292
- return dateFnsGetSeconds(value);
293
- }
294
-
295
- export function setSeconds(value: Date, count: number) {
296
- return dateFnsSetSeconds(value, count);
297
- }
298
-
299
- export function isSameDay(value: Date, comparing: Date) {
300
- return dateFnsIsSameDay(value, comparing);
301
- }
302
-
303
- export function isSameMonth(value: Date, comparing: Date) {
304
- return dateFnsIsSameMonth(value, comparing);
305
- }
306
-
307
- export function isSameYear(value: Date, comparing: Date) {
308
- return dateFnsIsSameYear(value, comparing);
309
- }
310
-
311
- export function isSameHour(value: Date, comparing: Date) {
312
- return dateFnsIsSameHour(value, comparing);
313
- }
314
-
315
- export function startOfYear(value: Date) {
316
- return dateFnsStartOfYear(value);
317
- }
318
-
319
- export function endOfYear(value: Date) {
320
- return dateFnsEndOfYear(value);
321
- }
322
-
323
- export function startOfMonth(value: Date) {
324
- return dateFnsStartOfMonth(value);
325
- }
326
-
327
- export function endOfMonth(value: Date) {
328
- return dateFnsEndOfMonth(value);
329
- }
330
-
331
- export function startOfWeek(value: Date) {
332
- return dateFnsStartOfWeek(value, {
333
- locale
334
- });
335
- }
336
-
337
- export function endOfWeek(value: Date) {
338
- return dateFnsEndOfWeek(value, {
339
- locale
340
- });
341
- }
342
-
343
- export function getYear(value: Date) {
344
- return dateFnsGetYear(value);
345
- }
346
-
347
- export function setYear(value: Date, count: number) {
348
- return dateFnsSetYear(value, count);
349
- }
350
-
351
- export function toJsDate(value: Date) {
352
- return value;
353
- }
354
-
355
- export function parse(value: string, formatString: string) {
356
- if (value === "") {
357
- return null;
358
- }
359
- return dateFnsParse(value, formatString, new Date(), {
360
- locale
361
- });
362
- }
363
-
364
- export function format(date: Date, formatKey: keyof DateFormats) {
365
- return formatByString(date, formats[formatKey]);
366
- }
367
-
368
- export function formatByString(date: Date, formatString: string) {
369
- return dateFnsFormat(date, formatString, {
370
- locale
371
- });
372
- }
373
-
374
- export function isEqual(date: any, comparing: any) {
375
- if (date === null && comparing === null) {
376
- return true;
377
- }
378
- return dateFnsIsEqual(date, comparing);
379
- }
380
-
381
- export function isNull(date: Date) {
382
- return date === null;
383
- }
384
-
385
- export function isAfterDay(date: Date, value: Date) {
386
- return isAfter(date, endOfDay(value));
387
- }
388
-
389
- export function isBeforeDay(date: Date, value: Date) {
390
- return isBefore(date, startOfDay(value));
391
- }
392
-
393
- export function isBeforeYear(date: Date, value: Date) {
394
- return isBefore(date, startOfYear(value));
395
- }
396
-
397
- export function isBeforeMonth(value: Date, comparing: Date): boolean {
398
- return isBefore(value, startOfMonth(comparing));
399
- }
400
-
401
- export function isAfterMonth(value: Date, comparing: Date): boolean {
402
- return isAfter(value, startOfMonth(comparing));
403
- }
404
-
405
- export function isAfterYear(date: Date, value: Date) {
406
- return isAfter(date, endOfYear(value));
407
- }
408
-
409
- export function isWithinRange(date: Date, [start, end]: [Date, Date]) {
410
- return isWithinInterval(date, {
411
- start,
412
- end
413
- });
414
- }
415
-
416
- export function formatNumber(numberToFormat: string) {
417
- return numberToFormat;
418
- }
419
-
420
- export function getMinutes(date: Date) {
421
- return dateFnsGetMinutes(date);
422
- }
423
-
424
- export function getDate(date: Date) {
425
- return dateFnsGetDate(date);
426
- }
427
-
428
- export function setDate(date: Date, count: number) {
429
- return dateFnsSetDate(date, count);
430
- }
431
-
432
- export function getWeek(date: Date) {
433
- return dateFnsGetWeek(date);
434
- }
435
-
436
- export function getMonth(date: Date) {
437
- return dateFnsGetMonth(date);
438
- }
439
-
440
- export function getDaysInMonth(date: Date) {
441
- return dateFnsGetDaysInMonth(date);
442
- }
443
-
444
- export function setMonth(date: Date, count: number) {
445
- return dateFnsSetMonth(date, count);
446
- }
447
-
448
- export function getMeridiemText(meridiem: "am" | "pm") {
449
- return meridiem === "am" ? "AM" : "PM";
450
- }
451
-
452
- export function getNextMonth(date: Date) {
453
- return addMonths(date, 1);
454
- }
455
-
456
- export function getPreviousMonth(date: Date) {
457
- return addMonths(date, -1);
458
- }
459
-
460
- export function getMonthArray(date: Date) {
461
- const firstMonth = startOfYear(date);
462
- const monthArray = [firstMonth];
463
-
464
- while (monthArray.length < 12) {
465
- const prevMonth = monthArray[monthArray.length - 1]!;
466
- monthArray.push(getNextMonth(prevMonth));
467
- }
468
-
469
- return monthArray;
470
- }
471
-
472
- export function mergeDateAndTime(date: Date, time: Date) {
473
- return setSeconds(
474
- setMinutes(setHours(date, getHours(time)), getMinutes(time)),
475
- getSeconds(time)
476
- );
477
- }
478
-
479
- export function getWeekdays() {
480
- const now = new Date();
481
-
482
- return eachDayOfInterval({
483
- start: startOfWeek(now),
484
- end: endOfWeek(now)
485
- }).map(day => formatByString(day, "EEEEEE"));
486
- }
487
-
488
- export function getWeekArray(date: Date) {
489
- const start = startOfWeek(startOfMonth(date));
490
- const end = endOfWeek(endOfMonth(date));
491
- let count = 0;
492
- let current = start;
493
- const nestedWeeks: Date[][] = [];
494
- let lastDay = null as null | number;
495
- while (isBefore(current, end)) {
496
- const weekNumber = Math.floor(count / 7);
497
- nestedWeeks[weekNumber] ??= [];
498
- const day = dateFnsGetDay(current);
499
- if (lastDay !== day) {
500
- lastDay = day;
501
- nestedWeeks[weekNumber].push(current);
502
- count += 1;
503
- }
504
- current = addDays(current, 1);
505
- }
506
- return nestedWeeks;
507
- }
508
-
509
- export function getYearRange(start: Date, end: Date) {
510
- const startDate = startOfYear(start);
511
- const endDate = endOfYear(end);
512
- const years: Date[] = [];
513
-
514
- let current = startDate;
515
- while (isBefore(current, endDate)) {
516
- years.push(current);
517
- current = addYears(current, 1);
518
- }
519
- return years;
520
- }
521
-
522
-
523
- `;
524
- }
525
-
526
- //#endregion
527
- exports.dateFnsModule = dateFnsModule;
@@ -1,13 +0,0 @@
1
- import { DatePluginContext } from "../types/plugin.cjs";
2
-
3
- //#region src/components/date-fns.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 dateFnsModule(context: DatePluginContext): string;
12
- //#endregion
13
- export { dateFnsModule };
@@ -1,13 +0,0 @@
1
- import { DatePluginContext } from "../types/plugin.mjs";
2
-
3
- //#region src/components/date-fns.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 dateFnsModule(context: DatePluginContext): string;
12
- //#endregion
13
- export { dateFnsModule };