@powerlines/plugin-date 0.12.418 → 0.12.420

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 (49) hide show
  1. package/dist/{src/components → components}/date-fns.cjs +1 -1
  2. package/dist/{src/components → components}/date-fns.d.cts +1 -1
  3. package/dist/components/date-fns.d.cts.map +1 -0
  4. package/dist/{src/components → components}/date-fns.d.mts +1 -1
  5. package/dist/components/date-fns.d.mts.map +1 -0
  6. package/dist/components/date-fns.mjs.map +1 -0
  7. package/dist/{src/components → components}/dayjs.cjs +1 -1
  8. package/dist/{src/components → components}/dayjs.d.cts +1 -1
  9. package/dist/components/dayjs.d.cts.map +1 -0
  10. package/dist/{src/components → components}/dayjs.d.mts +1 -1
  11. package/dist/components/dayjs.d.mts.map +1 -0
  12. package/dist/components/dayjs.mjs.map +1 -0
  13. package/dist/{src/components → components}/luxon.cjs +1 -1
  14. package/dist/{src/components → components}/luxon.d.cts +1 -1
  15. package/dist/components/luxon.d.cts.map +1 -0
  16. package/dist/{src/components → components}/luxon.d.mts +1 -1
  17. package/dist/components/luxon.d.mts.map +1 -0
  18. package/dist/components/luxon.mjs.map +1 -0
  19. package/dist/{src/components → components}/moment.cjs +1 -1
  20. package/dist/{src/components → components}/moment.d.cts +1 -1
  21. package/dist/components/moment.d.cts.map +1 -0
  22. package/dist/{src/components → components}/moment.d.mts +1 -1
  23. package/dist/components/moment.d.mts.map +1 -0
  24. package/dist/components/moment.mjs.map +1 -0
  25. package/dist/index.cjs +5 -5
  26. package/dist/index.d.cts +4 -4
  27. package/dist/index.d.mts +4 -4
  28. package/dist/index.mjs +5 -5
  29. package/package.json +6 -6
  30. package/dist/src/components/date-fns.d.cts.map +0 -1
  31. package/dist/src/components/date-fns.d.mts.map +0 -1
  32. package/dist/src/components/date-fns.mjs.map +0 -1
  33. package/dist/src/components/dayjs.d.cts.map +0 -1
  34. package/dist/src/components/dayjs.d.mts.map +0 -1
  35. package/dist/src/components/dayjs.mjs.map +0 -1
  36. package/dist/src/components/luxon.d.cts.map +0 -1
  37. package/dist/src/components/luxon.d.mts.map +0 -1
  38. package/dist/src/components/luxon.mjs.map +0 -1
  39. package/dist/src/components/moment.d.cts.map +0 -1
  40. package/dist/src/components/moment.d.mts.map +0 -1
  41. package/dist/src/components/moment.mjs.map +0 -1
  42. /package/dist/{src/components → components}/date-fns.mjs +0 -0
  43. /package/dist/{src/components → components}/dayjs.mjs +0 -0
  44. /package/dist/{src/components → components}/index.cjs +0 -0
  45. /package/dist/{src/components → components}/index.d.cts +0 -0
  46. /package/dist/{src/components → components}/index.d.mts +0 -0
  47. /package/dist/{src/components → components}/index.mjs +0 -0
  48. /package/dist/{src/components → components}/luxon.mjs +0 -0
  49. /package/dist/{src/components → components}/moment.mjs +0 -0
@@ -1,4 +1,4 @@
1
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
1
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
2
  let powerlines_lib_utilities_file_header = require("powerlines/lib/utilities/file-header");
3
3
 
4
4
  //#region src/components/date-fns.ts
@@ -1,4 +1,4 @@
1
- import { DatePluginContext } from "../../types/plugin.cjs";
1
+ import { DatePluginContext } from "../types/plugin.cjs";
2
2
 
3
3
  //#region src/components/date-fns.d.ts
4
4
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-fns.d.cts","names":[],"sources":["../../src/components/date-fns.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,aAAA,CAAc,OAAA,EAAS,iBAAA"}
@@ -1,4 +1,4 @@
1
- import { DatePluginContext } from "../../types/plugin.mjs";
1
+ import { DatePluginContext } from "../types/plugin.mjs";
2
2
 
3
3
  //#region src/components/date-fns.d.ts
4
4
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-fns.d.mts","names":[],"sources":["../../src/components/date-fns.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,aAAA,CAAc,OAAA,EAAS,iBAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-fns.mjs","names":[],"sources":["../../src/components/date-fns.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getFileHeader } from \"powerlines/lib/utilities/file-header\";\nimport { DatePluginContext } from \"../types/plugin\";\n\n/**\n * Generates the Powerlines configuration file.\n *\n * @param context - The build context containing runtime information.\n * @returns A string representing the configuration file content.\n */\nexport function dateFnsModule(context: DatePluginContext) {\n return `\n/**\n * The Date module provides utility functions for date manipulation and formatting\n *\n * @module ${context.config.framework}:date\n */\n\n${getFileHeader(context)}\n\nimport { DateFormats, TimeUnit } from \"@powerlines/plugin-date/types/runtime\";\nimport { addDays as dateFnsAddDays } from \"date-fns/addDays\";\nimport { addHours as dateFnsAddHours } from \"date-fns/addHours\";\nimport { addMinutes as dateFnsAddMinutes } from \"date-fns/addMinutes\";\nimport { addMonths as dateFnsAddMonths } from \"date-fns/addMonths\";\nimport { addSeconds as dateFnsAddSeconds } from \"date-fns/addSeconds\";\nimport { addWeeks as dateFnsAddWeeks } from \"date-fns/addWeeks\";\nimport { addYears as dateFnsAddYears } from \"date-fns/addYears\";\nimport { differenceInDays } from \"date-fns/differenceInDays\";\nimport { differenceInHours } from \"date-fns/differenceInHours\";\nimport { differenceInMilliseconds } from \"date-fns/differenceInMilliseconds\";\nimport { differenceInMinutes } from \"date-fns/differenceInMinutes\";\nimport { differenceInMonths } from \"date-fns/differenceInMonths\";\nimport { differenceInQuarters } from \"date-fns/differenceInQuarters\";\nimport { differenceInSeconds } from \"date-fns/differenceInSeconds\";\nimport { differenceInWeeks } from \"date-fns/differenceInWeeks\";\nimport { differenceInYears } from \"date-fns/differenceInYears\";\nimport { eachDayOfInterval } from \"date-fns/eachDayOfInterval\";\nimport { endOfDay as dateFnsEndOfDay } from \"date-fns/endOfDay\";\nimport { endOfMonth as dateFnsEndOfMonth } from \"date-fns/endOfMonth\";\nimport { endOfWeek as dateFnsEndOfWeek } from \"date-fns/endOfWeek\";\nimport { endOfYear as dateFnsEndOfYear } from \"date-fns/endOfYear\";\nimport { format as dateFnsFormat, longFormatters } from \"date-fns/format\";\nimport { formatISO } from \"date-fns/formatISO\";\nimport { getDate as dateFnsGetDate } from \"date-fns/getDate\";\nimport { getDay as dateFnsGetDay } from \"date-fns/getDay\";\nimport { getDaysInMonth as dateFnsGetDaysInMonth } from \"date-fns/getDaysInMonth\";\nimport { getHours as dateFnsGetHours } from \"date-fns/getHours\";\nimport { getMinutes as dateFnsGetMinutes } from \"date-fns/getMinutes\";\nimport { getMonth as dateFnsGetMonth } from \"date-fns/getMonth\";\nimport { getSeconds as dateFnsGetSeconds } from \"date-fns/getSeconds\";\nimport { getWeek as dateFnsGetWeek } from \"date-fns/getWeek\";\nimport { getYear as dateFnsGetYear } from \"date-fns/getYear\";\nimport { isAfter as dateFnsIsAfter } from \"date-fns/isAfter\";\nimport { isBefore as dateFnsIsBefore } from \"date-fns/isBefore\";\nimport { isEqual as dateFnsIsEqual } from \"date-fns/isEqual\";\nimport { isSameDay as dateFnsIsSameDay } from \"date-fns/isSameDay\";\nimport { isSameHour as dateFnsIsSameHour } from \"date-fns/isSameHour\";\nimport { isSameMonth as dateFnsIsSameMonth } from \"date-fns/isSameMonth\";\nimport { isSameYear as dateFnsIsSameYear } from \"date-fns/isSameYear\";\nimport { isValid as dateFnsIsValid } from \"date-fns/isValid\";\nimport { isWithinInterval } from \"date-fns/isWithinInterval\";\nimport { Locale } from \"date-fns/locale\";\nimport { ${\n context.env.parsed.DEFAULT_LOCALE?.replaceAll(\"-\", \"\") || \"enUS\"\n } as defaultLocale } from \"date-fns/locale/${\n context.env.parsed.DEFAULT_LOCALE || \"en-US\"\n }\";\nimport { parse as dateFnsParse } from \"date-fns/parse\";\nimport { parseISO as dateFnsParseISO } from \"date-fns/parseISO\";\nimport { setDate as dateFnsSetDate } from \"date-fns/setDate\";\nimport { setHours as dateFnsSetHours } from \"date-fns/setHours\";\nimport { setMinutes as dateFnsSetMinutes } from \"date-fns/setMinutes\";\nimport { setMonth as dateFnsSetMonth } from \"date-fns/setMonth\";\nimport { setSeconds as dateFnsSetSeconds } from \"date-fns/setSeconds\";\nimport { setYear as dateFnsSetYear } from \"date-fns/setYear\";\nimport { startOfDay as dateFnsStartOfDay } from \"date-fns/startOfDay\";\nimport { startOfMonth as dateFnsStartOfMonth } from \"date-fns/startOfMonth\";\nimport { startOfWeek as dateFnsStartOfWeek } from \"date-fns/startOfWeek\";\nimport { startOfYear as dateFnsStartOfYear } from \"date-fns/startOfYear\";\n\nexport const formats: DateFormats = {\n dayOfMonth: \"d\",\n fullDate: \"PP\",\n fullDateWithWeekday: \"PPPP\",\n fullDateTime: \"PP p\",\n fullDateTime12h: \"PP hh:mm aa\",\n fullDateTime24h: \"PP HH:mm\",\n fullTime: \"p\",\n fullTime12h: \"hh:mm aa\",\n fullTime24h: \"HH:mm\",\n hours12h: \"hh\",\n hours24h: \"HH\",\n keyboardDate: \"P\",\n keyboardDateTime: \"P p\",\n keyboardDateTime12h: \"P hh:mm aa\",\n keyboardDateTime24h: \"P HH:mm\",\n systemDateTime: \"P HH:mm:ss.SSS\",\n filePathDateTime: \"P_HH-mm-ss-SSS\",\n minutes: \"mm\",\n month: \"LLLL\",\n monthAndDate: \"MMMM d\",\n monthAndYear: \"LLLL yyyy\",\n monthShort: \"MMM\",\n weekday: \"EEEE\",\n weekdayShort: \"EEE\",\n normalDate: \"d MMMM\",\n normalDateWithWeekday: \"EEE, MMM d\",\n seconds: \"ss\",\n shortDate: \"MMM d\",\n year: \"yyyy\"\n};\n\nexport const locale: Locale = defaultLocale;\n\n/**\n * Creates a date object using the provided value.\n *\n * @remarks\n * 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.\n *\n * @example\n * \\`\\`\\`ts\n * import { createDate } from \"storm:date\";\n *\n * const date = createDate(\"2023-10-01\");\n * console.log(date.format(\"YYYY-MM-DD\")); // Outputs: 2023-10-01\n * \\`\\`\\`\n *\n * @param value - The value to create the date object from.\n * @returns A date object or \\`null\\` if the value is \\`null\\`.\n */\nexport function createDate<\n TArg = undefined,\n TResultingDate = TArg extends null\n ? null\n : TArg extends undefined\n ? Date\n : Date | null\n>(value?: TArg): TResultingDate {\n if (typeof value === \"undefined\") {\n return new Date() as TResultingDate;\n }\n if (value === null) {\n return null as TResultingDate;\n }\n return new Date(value as string | number) as TResultingDate;\n}\n\nexport const type = \"date-fns\";\n\n// Note: date-fns input types are more lenient than this adapter, so we need to expose our more\n// strict signature and delegate to the more lenient signature. Otherwise, we have downstream type errors upon usage.\nexport function is12HourCycleInCurrentLocale(): boolean {\n if (locale) {\n return /a/.test(locale.formatLong?.time({}));\n }\n\n // By default date-fns is using en-US locale with am/pm enabled\n return true;\n}\n\nexport function getFormatHelperText(format: string) {\n // @see https://github.com/date-fns/date-fns/blob/master/src/format/index.js#L31\n const longFormatRegexp = /P+p+|P+|p+|''|'(?:''|[^'])+(?:'|$)|./g;\n const _locale = locale || defaultLocale;\n\n return (\n format\n .match(longFormatRegexp)\n ?.map(token => {\n const firstCharacter = token[0];\n if (firstCharacter === \"p\" || firstCharacter === \"P\") {\n const longFormatter = longFormatters[firstCharacter]!;\n\n return longFormatter(token, _locale.formatLong);\n }\n\n return token;\n })\n .join(\"\")\n .replace(/aaa|aa|a/g, \"(a|p)m\")\n .toLocaleLowerCase() ?? format\n );\n}\n\nexport function parseISO(isoString: string) {\n return dateFnsParseISO(isoString);\n}\n\nexport function toISO(value: Date) {\n return formatISO(value, {\n format: \"extended\"\n });\n}\n\nexport function getCurrentLocaleCode() {\n return locale?.code || $storm.env.DEFAULT_LOCALE;\n}\n\nexport function addSeconds(value: Date, count: number) {\n return dateFnsAddSeconds(value, count);\n}\n\nexport function addMinutes(value: Date, count: number) {\n return dateFnsAddMinutes(value, count);\n}\n\nexport function addHours(value: Date, count: number) {\n return dateFnsAddHours(value, count);\n}\n\nexport function addDays(value: Date, count: number) {\n return dateFnsAddDays(value, count);\n}\n\nexport function addWeeks(value: Date, count: number) {\n return dateFnsAddWeeks(value, count);\n}\n\nexport function addMonths(value: Date, count: number) {\n return dateFnsAddMonths(value, count);\n}\n\nexport function addYears(value: Date, count: number) {\n return dateFnsAddYears(value, count);\n}\n\nexport function isValid(value: any) {\n return dateFnsIsValid(createDate(value));\n}\n\nexport function getDiff(\n value: Date,\n comparing: Date | string,\n unit?: TimeUnit\n) {\n // we output 0 if the compare date is string and parsing is not valid\n const dateToCompare = createDate(comparing) ?? value;\n if (!isValid(dateToCompare)) {\n return 0;\n }\n\n switch (unit) {\n case \"years\":\n return differenceInYears(value, dateToCompare);\n case \"quarters\":\n return differenceInQuarters(value, dateToCompare);\n case \"months\":\n return differenceInMonths(value, dateToCompare);\n case \"weeks\":\n return differenceInWeeks(value, dateToCompare);\n case \"days\":\n return differenceInDays(value, dateToCompare);\n case \"hours\":\n return differenceInHours(value, dateToCompare);\n case \"minutes\":\n return differenceInMinutes(value, dateToCompare);\n case \"seconds\":\n return differenceInSeconds(value, dateToCompare);\n case \"milliseconds\":\n case undefined:\n default:\n return differenceInMilliseconds(value, dateToCompare);\n }\n}\n\nexport function isAfter(value: Date, comparing: Date) {\n return dateFnsIsAfter(value, comparing);\n}\n\nexport function isBefore(value: Date, comparing: Date) {\n return dateFnsIsBefore(value, comparing);\n}\n\nexport function startOfDay(value: Date) {\n return dateFnsStartOfDay(value);\n}\n\nexport function endOfDay(value: Date) {\n return dateFnsEndOfDay(value);\n}\n\nexport function getHours(value: Date) {\n return dateFnsGetHours(value);\n}\n\nexport function setHours(value: Date, count: number) {\n return dateFnsSetHours(value, count);\n}\n\nexport function setMinutes(value: Date, count: number) {\n return dateFnsSetMinutes(value, count);\n}\n\nexport function getSeconds(value: Date) {\n return dateFnsGetSeconds(value);\n}\n\nexport function setSeconds(value: Date, count: number) {\n return dateFnsSetSeconds(value, count);\n}\n\nexport function isSameDay(value: Date, comparing: Date) {\n return dateFnsIsSameDay(value, comparing);\n}\n\nexport function isSameMonth(value: Date, comparing: Date) {\n return dateFnsIsSameMonth(value, comparing);\n}\n\nexport function isSameYear(value: Date, comparing: Date) {\n return dateFnsIsSameYear(value, comparing);\n}\n\nexport function isSameHour(value: Date, comparing: Date) {\n return dateFnsIsSameHour(value, comparing);\n}\n\nexport function startOfYear(value: Date) {\n return dateFnsStartOfYear(value);\n}\n\nexport function endOfYear(value: Date) {\n return dateFnsEndOfYear(value);\n}\n\nexport function startOfMonth(value: Date) {\n return dateFnsStartOfMonth(value);\n}\n\nexport function endOfMonth(value: Date) {\n return dateFnsEndOfMonth(value);\n}\n\nexport function startOfWeek(value: Date) {\n return dateFnsStartOfWeek(value, {\n locale\n });\n}\n\nexport function endOfWeek(value: Date) {\n return dateFnsEndOfWeek(value, {\n locale\n });\n}\n\nexport function getYear(value: Date) {\n return dateFnsGetYear(value);\n}\n\nexport function setYear(value: Date, count: number) {\n return dateFnsSetYear(value, count);\n}\n\nexport function toJsDate(value: Date) {\n return value;\n}\n\nexport function parse(value: string, formatString: string) {\n if (value === \"\") {\n return null;\n }\n return dateFnsParse(value, formatString, new Date(), {\n locale\n });\n}\n\nexport function format(date: Date, formatKey: keyof DateFormats) {\n return formatByString(date, formats[formatKey]);\n}\n\nexport function formatByString(date: Date, formatString: string) {\n return dateFnsFormat(date, formatString, {\n locale\n });\n}\n\nexport function isEqual(date: any, comparing: any) {\n if (date === null && comparing === null) {\n return true;\n }\n return dateFnsIsEqual(date, comparing);\n}\n\nexport function isNull(date: Date) {\n return date === null;\n}\n\nexport function isAfterDay(date: Date, value: Date) {\n return isAfter(date, endOfDay(value));\n}\n\nexport function isBeforeDay(date: Date, value: Date) {\n return isBefore(date, startOfDay(value));\n}\n\nexport function isBeforeYear(date: Date, value: Date) {\n return isBefore(date, startOfYear(value));\n}\n\nexport function isBeforeMonth(value: Date, comparing: Date): boolean {\n return isBefore(value, startOfMonth(comparing));\n}\n\nexport function isAfterMonth(value: Date, comparing: Date): boolean {\n return isAfter(value, startOfMonth(comparing));\n}\n\nexport function isAfterYear(date: Date, value: Date) {\n return isAfter(date, endOfYear(value));\n}\n\nexport function isWithinRange(date: Date, [start, end]: [Date, Date]) {\n return isWithinInterval(date, {\n start,\n end\n });\n}\n\nexport function formatNumber(numberToFormat: string) {\n return numberToFormat;\n}\n\nexport function getMinutes(date: Date) {\n return dateFnsGetMinutes(date);\n}\n\nexport function getDate(date: Date) {\n return dateFnsGetDate(date);\n}\n\nexport function setDate(date: Date, count: number) {\n return dateFnsSetDate(date, count);\n}\n\nexport function getWeek(date: Date) {\n return dateFnsGetWeek(date);\n}\n\nexport function getMonth(date: Date) {\n return dateFnsGetMonth(date);\n}\n\nexport function getDaysInMonth(date: Date) {\n return dateFnsGetDaysInMonth(date);\n}\n\nexport function setMonth(date: Date, count: number) {\n return dateFnsSetMonth(date, count);\n}\n\nexport function getMeridiemText(meridiem: \"am\" | \"pm\") {\n return meridiem === \"am\" ? \"AM\" : \"PM\";\n}\n\nexport function getNextMonth(date: Date) {\n return addMonths(date, 1);\n}\n\nexport function getPreviousMonth(date: Date) {\n return addMonths(date, -1);\n}\n\nexport function getMonthArray(date: Date) {\n const firstMonth = startOfYear(date);\n const monthArray = [firstMonth];\n\n while (monthArray.length < 12) {\n const prevMonth = monthArray[monthArray.length - 1]!;\n monthArray.push(getNextMonth(prevMonth));\n }\n\n return monthArray;\n}\n\nexport function mergeDateAndTime(date: Date, time: Date) {\n return setSeconds(\n setMinutes(setHours(date, getHours(time)), getMinutes(time)),\n getSeconds(time)\n );\n}\n\nexport function getWeekdays() {\n const now = new Date();\n\n return eachDayOfInterval({\n start: startOfWeek(now),\n end: endOfWeek(now)\n }).map(day => formatByString(day, \"EEEEEE\"));\n}\n\nexport function getWeekArray(date: Date) {\n const start = startOfWeek(startOfMonth(date));\n const end = endOfWeek(endOfMonth(date));\n let count = 0;\n let current = start;\n const nestedWeeks: Date[][] = [];\n let lastDay = null as null | number;\n while (isBefore(current, end)) {\n const weekNumber = Math.floor(count / 7);\n nestedWeeks[weekNumber] ??= [];\n const day = dateFnsGetDay(current);\n if (lastDay !== day) {\n lastDay = day;\n nestedWeeks[weekNumber].push(current);\n count += 1;\n }\n current = addDays(current, 1);\n }\n return nestedWeeks;\n}\n\nexport function getYearRange(start: Date, end: Date) {\n const startDate = startOfYear(start);\n const endDate = endOfYear(end);\n const years: Date[] = [];\n\n let current = startDate;\n while (isBefore(current, endDate)) {\n years.push(current);\n current = addYears(current, 1);\n }\n return years;\n}\n\n\n`;\n}\n"],"mappings":";;;;;;;;;AA2BA,SAAgB,cAAc,SAA4B;AACxD,QAAO;;;;aAII,QAAQ,OAAO,UAAU;;;EAGpC,cAAc,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA8CrB,QAAQ,IAAI,OAAO,gBAAgB,WAAW,KAAK,GAAG,IAAI,OAC3D,4CACC,QAAQ,IAAI,OAAO,kBAAkB,QACtC"}
@@ -1,4 +1,4 @@
1
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
1
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
2
  let powerlines_lib_utilities_file_header = require("powerlines/lib/utilities/file-header");
3
3
 
4
4
  //#region src/components/dayjs.ts
@@ -1,4 +1,4 @@
1
- import { DatePluginContext } from "../../types/plugin.cjs";
1
+ import { DatePluginContext } from "../types/plugin.cjs";
2
2
 
3
3
  //#region src/components/dayjs.d.ts
4
4
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dayjs.d.cts","names":[],"sources":["../../src/components/dayjs.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,WAAA,CAAY,OAAA,EAAS,iBAAA"}
@@ -1,4 +1,4 @@
1
- import { DatePluginContext } from "../../types/plugin.mjs";
1
+ import { DatePluginContext } from "../types/plugin.mjs";
2
2
 
3
3
  //#region src/components/dayjs.d.ts
4
4
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dayjs.d.mts","names":[],"sources":["../../src/components/dayjs.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,WAAA,CAAY,OAAA,EAAS,iBAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dayjs.mjs","names":[],"sources":["../../src/components/dayjs.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getFileHeader } from \"powerlines/lib/utilities/file-header\";\nimport { DatePluginContext } from \"../types/plugin\";\n\n/**\n * Generates the Powerlines configuration file.\n *\n * @param context - The build context containing runtime information.\n * @returns A string representing the configuration file content.\n */\nexport function dayjsModule(context: DatePluginContext) {\n return `\n/**\n * The Date module provides utility functions for date manipulation and formatting\n *\n * @module ${context.config.framework}:date\n */\n\n${getFileHeader(context)}\n\nimport defaultDayjs, { QUnitType } from \"dayjs\";\nimport customParseFormatPlugin from \"dayjs/plugin/customParseFormat\";\nimport localizedFormatPlugin from \"dayjs/plugin/localizedFormat\";\nimport isBetweenPlugin from \"dayjs/plugin/isBetween\";\nimport weekOfYear from \"dayjs/plugin/weekOfYear\";\nimport {\n StormDateInterface,\n DateFormats,\n TimeUnit\n} from \"@powerlines/plugin-date/types/runtime\";\n\ndefaultDayjs.extend(customParseFormatPlugin);\ndefaultDayjs.extend(localizedFormatPlugin);\ndefaultDayjs.extend(isBetweenPlugin);\ndefaultDayjs.extend(weekOfYear);\n\ninterface Opts {\n locale?: string;\n /** Make sure that your dayjs instance extends customParseFormat and advancedFormat */\n instance?: typeof defaultDayjs;\n formats?: Partial<DateFormats>;\n}\n\ntype Dayjs = defaultDayjs.Dayjs;\ntype Constructor<TDate extends Dayjs> = (\n ...args: Parameters<typeof defaultDayjs>\n) => TDate;\nconst withLocale = <TDate extends Dayjs>(\n dayjs: any,\n locale?: string\n): Constructor<TDate> => (!locale ? dayjs : (...args) => dayjs(...args).locale(locale));\n\nexport const formats: DateFormats = {\n normalDateWithWeekday: \"ddd, MMM D\",\n normalDate: \"D MMMM\",\n shortDate: \"MMM D\",\n monthAndDate: \"MMMM D\",\n dayOfMonth: \"D\",\n year: \"YYYY\",\n month: \"MMMM\",\n monthShort: \"MMM\",\n monthAndYear: \"MMMM YYYY\",\n weekday: \"dddd\",\n weekdayShort: \"ddd\",\n minutes: \"mm\",\n hours12h: \"hh\",\n hours24h: \"HH\",\n seconds: \"ss\",\n fullTime: \"LT\",\n fullTime12h: \"hh:mm A\",\n fullTime24h: \"HH:mm\",\n fullDate: \"ll\",\n fullDateWithWeekday: \"dddd, LL\",\n fullDateTime: \"lll\",\n fullDateTime12h: \"ll hh:mm A\",\n fullDateTime24h: \"ll HH:mm\",\n keyboardDate: \"L\",\n keyboardDateTime: \"L LT\",\n keyboardDateTime12h: \"L hh:mm A\",\n keyboardDateTime24h: \"L HH:mm\",\n systemDateTime: \"L HH:mm:ss.SSS\",\n filePathDateTime: \"L_HH-mm-ss-SSS\"\n};\n\nexport let locale = \"${\n context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale\n ? `${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale}`\n : \"en-US\"\n }\";\n\nexport const dayjs = withLocale(defaultDayjs, locale);\n\nexport const type = \"dayjs\";\n\n/**\n * Creates a date object using the provided value.\n *\n * @remarks\n * 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.\n *\n * @example\n * \\`\\`\\`ts\n * import { createDate } from \"storm:date\";\n *\n * const date = createDate(\"2023-10-01\");\n * console.log(date.format(\"YYYY-MM-DD\")); // Outputs: 2023-10-01\n * \\`\\`\\`\n *\n * @param value - The value to create the date object from.\n * @returns A date object or \\`null\\` if the value is \\`null\\`.\n */\nexport function createDate<\n TArg extends unknown = undefined,\n TResultingDate extends unknown = TArg extends null\n ? null\n : TArg extends undefined\n ? TDate\n : TDate | null\n>(value?: TArg): TResultingDate {\n if (value === null) {\n return null as TResultingDate;\n }\n\n return dayjs(value as any) as unknown as TResultingDate;\n}\n\nexport function is12HourCycleInCurrentLocale() {\n /* istanbul ignore next */\n return /A|a/.test(dayjs.Ls[dayjs.locale() || $storm.env.DEFAULT_LOCALE]?.formats?.LT ?? \"\");\n};\n\nexport function getCurrentLocaleCode() {\n return dayjs.locale() || $storm.env.DEFAULT_LOCALE;\n};\n\nexport function getFormatHelperText(format: string) {\n // @see https://github.com/iamkun/dayjs/blob/dev/src/plugin/localizedFormat/index.js\n const localFormattingTokens = /(\\[[^\\[]*\\])|(\\\\)?(LTS|LT|LL?L?L?)|./g;\n\n return (\n format\n .match(localFormattingTokens)\n ?.map((token) => {\n const firstCharacter = token[0];\n if (firstCharacter === \"L\") {\n /* istanbul ignore next */\n return (\n dayjs.Ls[dayjs.locale() || $storm.env.DEFAULT_LOCALE]?.formats[\n token as keyof ILocale[\"formats\"]\n ] ?? token\n );\n }\n return token;\n })\n .join(\"\")\n .replace(/a/gi, \"(a|p)m\")\n .toLocaleLowerCase() ?? format\n );\n};\n\nexport function parseISO(isoString: string) {\n return dayjs(isoString);\n};\n\nexport function toISO(value: Dayjs) {\n return value.toISOString();\n};\n\nexport function parse(value: any, format: string) {\n if (value === \"\") {\n return null;\n }\n\n return dayjs(value, format, dayjs.locale(), true);\n};\n\nexport function toJsDate(value: Dayjs) {\n return value.toDate();\n};\n\nexport function isValid(value: any) {\n return dayjs(value).isValid();\n};\n\nexport function isNull(date: Dayjs | null) {\n return date === null;\n};\n\nexport function getDiff(date: Dayjs, comparing: Dayjs | string, units?: Unit) {\n if (typeof comparing === \"string\") {\n comparing = dayjs(comparing);\n }\n\n if (!comparing.isValid()) {\n return 0;\n }\n\n return date.diff(comparing, units as QUnitType);\n};\n\nexport function isAfter(date: Dayjs, value: Dayjs) {\n return date.isAfter(value);\n};\n\nexport function isBefore(date: Dayjs, value: Dayjs) {\n return date.isBefore(value);\n};\n\nexport function isAfterDay(date: Dayjs, value: Dayjs) {\n return date.isAfter(value, \"day\");\n};\n\nexport function isBeforeDay(date: Dayjs, value: Dayjs) {\n return date.isBefore(value, \"day\");\n};\n\nexport function isAfterMonth(date: Dayjs, value: Dayjs) {\n return date.isAfter(value, \"month\");\n};\n\nexport function isBeforeMonth(date: Dayjs, value: Dayjs) {\n return date.isBefore(value, \"month\");\n};\n\nexport function isBeforeYear(date: Dayjs, value: Dayjs) {\n return date.isBefore(value, \"year\");\n};\n\nexport function isAfterYear(date: Dayjs, value: Dayjs) {\n return date.isAfter(value, \"year\");\n};\n\nexport function startOfDay(date: Dayjs) {\n return date.startOf(\"day\");\n};\n\nexport function endOfDay(date: Dayjs) {\n return date.endOf(\"day\");\n};\n\nexport function format(date: Dayjs, formatKey: keyof DateFormats) {\n return formatByString(date, formats[formatKey]);\n};\n\nexport function formatByString(date: Dayjs, formatString: string) {\n return dayjs(date).format(formatString);\n};\n\nexport function formatNumber(numberToFormat: string) {\n return numberToFormat;\n};\n\nexport function getHours(date: Dayjs) {\n return date.hour();\n};\n\nexport function addSeconds(date: Dayjs, count: number) {\n return count < 0\n ? (date.subtract(Math.abs(count), \"second\") as Dayjs)\n : (date.add(count, \"second\") as Dayjs);\n};\n\nexport function addMinutes(date: Dayjs, count: number) {\n return count < 0\n ? (date.subtract(Math.abs(count), \"minute\") as Dayjs)\n : (date.add(count, \"minute\") as Dayjs);\n};\n\nexport function addHours(date: Dayjs, count: number) {\n return count < 0\n ? (date.subtract(Math.abs(count), \"hour\") as Dayjs)\n : (date.add(count, \"hour\") as Dayjs);\n};\n\nexport function addDays(date: Dayjs, count: number) {\n return count < 0\n ? (date.subtract(Math.abs(count), \"day\") as Dayjs)\n : (date.add(count, \"day\") as Dayjs);\n};\n\nexport function addWeeks(date: Dayjs, count: number) {\n return count < 0\n ? (date.subtract(Math.abs(count), \"week\") as Dayjs)\n : (date.add(count, \"week\") as Dayjs);\n};\n\nexport function addMonths(date: Dayjs, count: number) {\n return count < 0\n ? (date.subtract(Math.abs(count), \"month\") as Dayjs)\n : (date.add(count, \"month\") as Dayjs);\n};\n\nexport function addYears(date: Dayjs, count: number) {\n return count < 0\n ? (date.subtract(Math.abs(count), \"year\") as Dayjs)\n : (date.add(count, \"year\") as Dayjs);\n};\n\nexport function setMonth(date: Dayjs, count: number) {\n return date.set(\"month\", count) as Dayjs;\n};\n\nexport function setHours(date: Dayjs, count: number) {\n return date.set(\"hour\", count) as Dayjs;\n};\n\nexport function getMinutes(date: Dayjs) {\n return date.minute();\n};\n\nexport function setMinutes(date: Dayjs, count: number) {\n return date.set(\"minute\", count) as Dayjs;\n};\n\nexport function getSeconds(date: Dayjs) {\n return date.second();\n};\n\nexport function setSeconds(date: Dayjs, count: number) {\n return date.set(\"second\", count) as Dayjs;\n};\n\nexport function getWeek(date: Dayjs) {\n return date.week();\n};\n\nexport function getMonth(date: Dayjs) {\n return date.month();\n};\n\nexport function getDate(date: Dayjs) {\n return date.date();\n};\n\nexport function setDate(date: Dayjs, count: number) {\n return date.set(\"date\", count) as Dayjs;\n};\n\nexport function getDaysInMonth(date: Dayjs) {\n return date.daysInMonth();\n};\n\nexport function isSameDay(date: Dayjs, comparing: Dayjs) {\n return date.isSame(comparing, \"day\");\n};\n\nexport function isSameMonth(date: Dayjs, comparing: Dayjs) {\n return date.isSame(comparing, \"month\");\n};\n\nexport function isSameYear(date: Dayjs, comparing: Dayjs) {\n return date.isSame(comparing, \"year\");\n};\n\nexport function isSameHour(date: Dayjs, comparing: Dayjs) {\n return date.isSame(comparing, \"hour\");\n};\n\nexport function getMeridiemText(meridiem: \"am\" | \"pm\") {\n return meridiem === \"am\" ? \"AM\" : \"PM\";\n};\n\nexport function startOfYear(date: Dayjs) {\n return date.startOf(\"year\") as Dayjs;\n};\n\nexport function endOfYear(date: Dayjs) {\n return date.endOf(\"year\") as Dayjs;\n};\n\nexport function startOfMonth(date: Dayjs) {\n return date.startOf(\"month\") as Dayjs;\n};\n\nexport function endOfMonth(date: Dayjs) {\n return date.endOf(\"month\") as Dayjs;\n};\n\nexport function startOfWeek(date: Dayjs) {\n return date.startOf(\"week\") as Dayjs;\n};\n\nexport function endOfWeek(date: Dayjs) {\n return date.endOf(\"week\") as Dayjs;\n};\n\nexport function getNextMonth(date: Dayjs) {\n return date.add(1, \"month\") as Dayjs;\n};\n\nexport function getPreviousMonth(date: Dayjs) {\n return date.subtract(1, \"month\") as Dayjs;\n};\n\nexport function getMonthArray(date: Dayjs) {\n const firstMonth = date.startOf(\"year\") as Dayjs;\n const monthArray = [firstMonth];\n\n while (monthArray.length < 12) {\n const prevMonth = monthArray[monthArray.length - 1];\n monthArray.push(getNextMonth(prevMonth));\n }\n\n return monthArray;\n};\n\nexport function getYear(date: Dayjs) {\n return date.year();\n};\n\nexport function setYear(date: Dayjs, year: number) {\n return date.set(\"year\", year) as Dayjs;\n};\n\nexport function mergeDateAndTime(date: Dayjs, time: Dayjs) {\n return date.hour(time.hour()).minute(time.minute()).second(time.second()) as Dayjs;\n};\n\nexport function getWeekdays() {\n const start = dayjs().startOf(\"week\");\n return [0, 1, 2, 3, 4, 5, 6].map((diff) =>\n formatByString(start.add(diff, \"day\"), \"dd\")\n );\n};\n\nexport function isEqual(value: any, comparing: any) {\n if (value === null && comparing === null) {\n return true;\n }\n\n return dayjs(value).isSame(comparing);\n};\n\nexport function getWeekArray(date: Dayjs) {\n const start = dayjs(date).startOf(\"month\").startOf(\"week\") as Dayjs;\n const end = dayjs(date).endOf(\"month\").endOf(\"week\") as Dayjs;\n\n let count = 0;\n let current = start;\n const nestedWeeks: Dayjs[][] = [];\n\n while (current.isBefore(end)) {\n const weekNumber = Math.floor(count / 7);\n nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];\n nestedWeeks[weekNumber].push(current);\n\n current = current.add(1, \"day\") as TDate;\n count += 1;\n }\n\n return nestedWeeks;\n};\n\nexport function getYearRange(start: Dayjs, end: Dayjs) {\n const startDate = start.startOf(\"year\");\n const endDate = end.endOf(\"year\");\n const years: Dayjs[] = [];\n\n let current = startDate;\n while (current.isBefore(endDate)) {\n years.push(current);\n current = current.add(1, \"year\");\n }\n\n return years;\n};\n\nexport function isWithinRange(date: Dayjs, [start, end]: [Dayjs, Dayjs]) {\n return date.isBetween(start, end, null, \"[]\");\n};\n\n\n`;\n}\n"],"mappings":";;;;;;;;;AA2BA,SAAgB,YAAY,SAA4B;AACtD,QAAO;;;;aAII,QAAQ,OAAO,UAAU;;;EAGpC,cAAc,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAmErB,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,gBAAgB,SACzD,GAAG,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,gBAAgB,WAChE,QACL"}
@@ -1,4 +1,4 @@
1
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
1
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
2
  let powerlines_lib_utilities_file_header = require("powerlines/lib/utilities/file-header");
3
3
 
4
4
  //#region src/components/luxon.ts
@@ -1,4 +1,4 @@
1
- import { DatePluginContext } from "../../types/plugin.cjs";
1
+ import { DatePluginContext } from "../types/plugin.cjs";
2
2
 
3
3
  //#region src/components/luxon.d.ts
4
4
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"luxon.d.cts","names":[],"sources":["../../src/components/luxon.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,WAAA,CAAY,OAAA,EAAS,iBAAA"}
@@ -1,4 +1,4 @@
1
- import { DatePluginContext } from "../../types/plugin.mjs";
1
+ import { DatePluginContext } from "../types/plugin.mjs";
2
2
 
3
3
  //#region src/components/luxon.d.ts
4
4
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"luxon.d.mts","names":[],"sources":["../../src/components/luxon.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,WAAA,CAAY,OAAA,EAAS,iBAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"luxon.mjs","names":[],"sources":["../../src/components/luxon.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getFileHeader } from \"powerlines/lib/utilities/file-header\";\nimport { DatePluginContext } from \"../types/plugin\";\n\n/**\n * Generates the Powerlines configuration file.\n *\n * @param context - The build context containing runtime information.\n * @returns A string representing the configuration file content.\n */\nexport function luxonModule(context: DatePluginContext) {\n return `\n/**\n * The Date module provides utility functions for date manipulation and formatting\n *\n * @module ${context.config.framework}:date\n */\n\n${getFileHeader(context)}\n\nimport { DateTime, Settings, Info } from \"luxon\";\nimport {\n StormDateInterface,\n DateFormats,\n TimeUnit\n} from \"@powerlines/plugin-date/types/runtime\";\n\nexport const formats: DateFormats = {\n dayOfMonth: \"d\",\n fullDate: \"DD\",\n fullDateWithWeekday: \"DDDD\",\n fullDateTime: \"ff\",\n fullDateTime12h: \"DD, hh:mm a\",\n fullDateTime24h: \"DD, T\",\n fullTime: \"t\",\n fullTime12h: \"hh:mm a\",\n fullTime24h: \"HH:mm\",\n hours12h: \"hh\",\n hours24h: \"HH\",\n keyboardDate: \"D\",\n keyboardDateTime: \"D t\",\n keyboardDateTime12h: \"D hh:mm a\",\n keyboardDateTime24h: \"D T\",\n systemDateTime: \"D HH:mm:ss.SSS\",\n filePathDateTime: \"D_HH-mm-ss-SSS\",\n minutes: \"mm\",\n seconds: \"ss\",\n month: \"LLLL\",\n monthAndDate: \"MMMM d\",\n monthAndYear: \"LLLL yyyy\",\n monthShort: \"MMM\",\n weekday: \"cccc\",\n weekdayShort: \"ccc\",\n normalDate: \"d MMMM\",\n normalDateWithWeekday: \"EEE, MMM d\",\n shortDate: \"MMM d\",\n year: \"yyyy\",\n};\n\nexport let locale = \"${\n context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale\n ? `${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale}`\n : \"en-US\"\n }\";\n\nexport const type = \"luxon\";\n\n/**\n * Creates a date object using the provided value.\n *\n * @remarks\n * 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.\n *\n * @example\n * \\`\\`\\`ts\n * import { createDate } from \"storm:date\";\n *\n * const date = createDate(\"2023-10-01\");\n * console.log(date.format(\"YYYY-MM-DD\")); // Outputs: 2023-10-01\n * \\`\\`\\`\n *\n * @param value - The value to create the date object from.\n * @returns A date object or \\`null\\` if the value is \\`null\\`.\n */\nexport function createDate<\n TArg extends unknown = undefined,\n TResultingDate extends unknown = TArg extends null\n ? null\n : TArg extends undefined\n ? DateTime\n : DateTime | null\n>(value?: TArg): TResultingDate {\n if (typeof value === \"undefined\") {\n return DateTime.local() as TResultingDate;\n }\n\n if (value === null) {\n return null as TResultingDate;\n }\n\n if (typeof value === \"string\") {\n return DateTime.fromJSDate(new Date(value), { locale }) as TResultingDate;\n }\n\n if (DateTime.isDateTime(value)) {\n return value as TResultingDate;\n }\n\n if (value instanceof Date) {\n return DateTime.fromJSDate(value, { locale }) as TResultingDate;\n }\n\n /* istanbul ignore next */\n return DateTime.local() as TResultingDate;\n}\n\nexport function toJsDate(value: DateTime) {\n return value.toJSDate();\n};\n\nexport function parseISO(isoString: string) {\n return DateTime.fromISO(isoString);\n};\n\nexport function toISO(value: DateTime) {\n return value.toISO({ format: \"extended\" });\n};\n\nexport function parse(value: string, formatString: string) {\n if (value === \"\") {\n return null;\n }\n\n return DateTime.fromFormat(value, formatString, { locale });\n};\n\n/* istanbul ignore next */\nexport function is12HourCycleInCurrentLocale() {\n if (typeof Intl === \"undefined\" || typeof Intl.DateTimeFormat === \"undefined\") {\n return true; // Luxon defaults to en-US if Intl not found\n }\n\n return Boolean(\n new Intl.DateTimeFormat(this.locale, { hour: \"numeric\" })?.resolvedOptions()?.hour12\n );\n};\n\nexport function getFormatHelperText(format: string) {\n // Unfortunately there is no way for luxon to retrieve readable formats from localized format\n return \"\";\n};\n\n/* istanbul ignore next */\nexport function getCurrentLocaleCode() {\n return this.locale || Settings.defaultLocale;\n};\n\nexport function addSeconds(date: DateTime, count: number) {\n return date.plus({ seconds: count });\n};\n\nexport function addMinutes(date: DateTime, count: number) {\n return date.plus({ minutes: count });\n};\n\nexport function addHours(date: DateTime, count: number) {\n return date.plus({ hours: count });\n};\n\nexport function addDays(date: DateTime, count: number) {\n return date.plus({ days: count });\n};\n\nexport function addWeeks(date: DateTime, count: number) {\n return date.plus({ weeks: count });\n};\n\nexport function addMonths(date: DateTime, count: number) {\n return date.plus({ months: count });\n};\n\nexport function addYears(date: DateTime, count: number) {\n return date.plus({ years: count });\n};\n\nexport function isValid(value: any) {\n if (DateTime.isDateTime(value)) {\n return value.isValid;\n }\n\n if (value === null) {\n return false;\n }\n\n return createDate(value)?.isValid ?? false;\n};\n\nexport function isEqual(value: any, comparing: any) {\n if (value === null && comparing === null) {\n return true;\n }\n\n // make sure that null will not be passed to createDate\n if (value === null || comparing === null) {\n return false;\n }\n\n if (!createDate(comparing)) {\n /* istanbul ignore next */\n return false;\n }\n\n return createDate(value)?.equals(createDate(comparing) as DateTime) ?? false;\n};\n\nexport function isSameDay(date: DateTime, comparing: DateTime) {\n return date.hasSame(comparing, \"day\");\n};\n\nexport function isSameMonth(date: DateTime, comparing: DateTime) {\n return date.hasSame(comparing, \"month\");\n};\n\nexport function isSameYear(date: DateTime, comparing: DateTime) {\n return date.hasSame(comparing, \"year\");\n};\n\nexport function isSameHour(date: DateTime, comparing: DateTime) {\n return date.hasSame(comparing, \"hour\");\n};\n\nexport function isAfter(value: DateTime, comparing: DateTime) {\n return value > comparing;\n};\n\nexport function isBefore(value: DateTime, comparing: DateTime) {\n return value < comparing;\n};\n\nexport function isBeforeDay(value: DateTime, comparing: DateTime) {\n const diff = value.diff(comparing.startOf(\"day\"), \"days\").toObject();\n return diff.days! < 0;\n};\n\nexport function isAfterDay(value: DateTime, comparing: DateTime) {\n const diff = value.diff(comparing.endOf(\"day\"), \"days\").toObject();\n return diff.days! > 0;\n};\n\nexport function isBeforeMonth(value: DateTime, comparing: DateTime) {\n const diff = value.diff(comparing.startOf(\"month\"), \"months\").toObject();\n return diff.months! < 0;\n};\n\nexport function isAfterMonth(value: DateTime, comparing: DateTime) {\n const diff = value.diff(comparing.startOf(\"month\"), \"months\").toObject();\n return diff.months! > 0;\n};\n\nexport function isBeforeYear(value: DateTime, comparing: DateTime) {\n const diff = value.diff(comparing.startOf(\"year\"), \"years\").toObject();\n return diff.years! < 0;\n};\n\nexport function isAfterYear(value: DateTime, comparing: DateTime) {\n const diff = value.diff(comparing.endOf(\"year\"), \"years\").toObject();\n return diff.years! > 0;\n};\n\nexport function getDiff(value: DateTime, comparing: DateTime | string, unit?: TimeUnit) {\n if (typeof comparing === \"string\") {\n comparing = DateTime.fromJSDate(new Date(comparing));\n }\n\n if (!comparing.isValid) {\n return 0;\n }\n\n if (unit) {\n return Math.floor(value.diff(comparing).as(unit));\n }\n\n return value.diff(comparing).as(\"millisecond\");\n};\n\nexport function startOfDay(value: DateTime) {\n return value.startOf(\"day\");\n};\n\nexport function endOfDay(value: DateTime) {\n return value.endOf(\"day\");\n};\n\nexport function format(date: DateTime, formatKey: keyof DateFormats) {\n return formatByString(date, formats[formatKey]);\n};\n\nexport function formatByString(date: DateTime, format: string) {\n return date.setLocale(locale).toFormat(format);\n};\n\nexport function formatNumber(numberToFormat: string) {\n return numberToFormat;\n};\n\nexport function getHours(value: DateTime) {\n return value.get(\"hour\");\n};\n\nexport function setHours(value: DateTime, count: number) {\n return value.set({ hour: count });\n};\n\nexport function getMinutes(value: DateTime) {\n return value.get(\"minute\");\n};\n\nexport function setMinutes(value: DateTime, count: number) {\n return value.set({ minute: count });\n};\n\nexport function getSeconds(value: DateTime) {\n return value.get(\"second\");\n};\n\nexport function setSeconds(value: DateTime, count: number) {\n return value.set({ second: count });\n};\n\nexport function getWeek(value: DateTime) {\n return value.get(\"weekNumber\");\n};\n\nexport function getMonth(value: DateTime) {\n // See https://github.com/moment/luxon/blob/master/docs/moment.md#major-functional-differences\n return value.get(\"month\") - 1;\n};\n\nexport function getDaysInMonth(value: DateTime) {\n return value.daysInMonth;\n};\n\nexport function setMonth(value: DateTime, count: number) {\n return value.set({ month: count + 1 });\n};\n\nexport function getYear(value: DateTime) {\n return value.get(\"year\");\n};\n\nexport function setYear(value: DateTime, year: number) {\n return value.set({ year });\n};\n\nexport function getDate(value: DateTime) {\n return value.get(\"day\");\n};\n\nexport function setDate(value: DateTime, day: number) {\n return value.set({ day });\n};\n\nexport function mergeDateAndTime(date: DateTime, time: DateTime) {\n return date.set({\n second: time.second,\n hour: time.hour,\n minute: time.minute,\n });\n};\n\nexport function startOfYear(value: DateTime) {\n return value.startOf(\"year\");\n};\n\nexport function endOfYear(value: DateTime) {\n return value.endOf(\"year\");\n};\n\nexport function startOfMonth(value: DateTime) {\n return value.startOf(\"month\");\n};\n\nexport function endOfMonth(value: DateTime) {\n return value.endOf(\"month\");\n};\n\nexport function startOfWeek(value: DateTime) {\n return value.startOf(\"week\");\n};\n\nexport function endOfWeek(value: DateTime) {\n return value.endOf(\"week\");\n};\n\nexport function getNextMonth(value: DateTime) {\n return value.plus({ months: 1 });\n};\n\nexport function getPreviousMonth(value: DateTime) {\n return value.minus({ months: 1 });\n};\n\nexport function getMonthArray(date: DateTime) {\n const firstMonth = date.startOf(\"year\");\n const monthArray = [firstMonth];\n\n while (monthArray.length < 12) {\n const prevMonth = monthArray[monthArray.length - 1];\n monthArray.push(this.getNextMonth(prevMonth));\n }\n\n return monthArray;\n};\n\nexport function getWeekdays() {\n return Info.weekdaysFormat(\"short\", { locale });\n};\n\nexport function getWeekArray(date: DateTime) {\n const { days } = date\n .endOf(\"month\")\n .endOf(\"week\")\n .diff(date.startOf(\"month\").startOf(\"week\"), \"days\")\n .toObject();\n\n const weeks: DateTime[][] = [];\n new Array<number>(Math.round(days!))\n .fill(0)\n .map((_, i) => i)\n .map((day) => date.startOf(\"month\").startOf(\"week\").plus({ days: day }))\n .forEach((v, i) => {\n if (i === 0 || (i % 7 === 0 && i > 6)) {\n weeks.push([v]);\n return;\n }\n\n weeks[weeks.length - 1].push(v);\n });\n\n return weeks;\n};\n\nexport function getYearRange(start: DateTime, end: DateTime) {\n const startDate = start.startOf(\"year\");\n const endDate = end.endOf(\"year\");\n\n let current = startDate;\n const years: DateTime[] = [];\n\n while (current < endDate) {\n years.push(current);\n current = current.plus({ year: 1 });\n }\n\n return years;\n};\n\nexport function getMeridiemText(meridiem: \"am\" | \"pm\") {\n return Info.meridiems({ locale }).find(\n (v) => v.toLowerCase() === meridiem.toLowerCase()\n )!;\n};\n\nexport function isNull(date: DateTime | null) {\n return date === null;\n};\n\nexport function isWithinRange(date: DateTime, [start, end]: [DateTime, DateTime]) {\n return (\n date.equals(start) ||\n date.equals(end) ||\n (isAfter(date, start) && isBefore(date, end))\n );\n};\n\n\n`;\n}\n"],"mappings":";;;;;;;;;AA2BA,SAAgB,YAAY,SAA4B;AACtD,QAAO;;;;aAII,QAAQ,OAAO,UAAU;;;EAGpC,cAAc,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA0CrB,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,gBAAgB,SACzD,GAAG,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,gBAAgB,WAChE,QACL"}
@@ -1,4 +1,4 @@
1
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
1
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
2
  let powerlines_lib_utilities_file_header = require("powerlines/lib/utilities/file-header");
3
3
 
4
4
  //#region src/components/moment.ts
@@ -1,4 +1,4 @@
1
- import { DatePluginContext } from "../../types/plugin.cjs";
1
+ import { DatePluginContext } from "../types/plugin.cjs";
2
2
 
3
3
  //#region src/components/moment.d.ts
4
4
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moment.d.cts","names":[],"sources":["../../src/components/moment.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,YAAA,CAAa,OAAA,EAAS,iBAAA"}
@@ -1,4 +1,4 @@
1
- import { DatePluginContext } from "../../types/plugin.mjs";
1
+ import { DatePluginContext } from "../types/plugin.mjs";
2
2
 
3
3
  //#region src/components/moment.d.ts
4
4
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moment.d.mts","names":[],"sources":["../../src/components/moment.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,YAAA,CAAa,OAAA,EAAS,iBAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moment.mjs","names":[],"sources":["../../src/components/moment.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getFileHeader } from \"powerlines/lib/utilities/file-header\";\nimport { DatePluginContext } from \"../types/plugin\";\n\n/**\n * Generates the Powerlines configuration file.\n *\n * @param context - The build context containing runtime information.\n * @returns A string representing the configuration file content.\n */\nexport function momentModule(context: DatePluginContext) {\n return `\n/**\n * The Date module provides utility functions for date manipulation and formatting\n *\n * @module ${context.config.framework}:date\n */\n\n${getFileHeader(context)}\n\nimport defaultMoment, { LongDateFormatKey } from \"moment\";\nimport {\n StormDateInterface,\n DateFormats,\n TimeUnit\n} from \"@powerlines/plugin-date/types/runtime\";\n\ntype Moment = defaultMoment.Moment;\n\nexport const formats: DateFormats = {\n normalDateWithWeekday: \"ddd, MMM D\",\n normalDate: \"D MMMM\",\n shortDate: \"MMM D\",\n monthAndDate: \"MMMM D\",\n dayOfMonth: \"D\",\n year: \"YYYY\",\n month: \"MMMM\",\n monthShort: \"MMM\",\n monthAndYear: \"MMMM YYYY\",\n weekday: \"dddd\",\n weekdayShort: \"ddd\",\n minutes: \"mm\",\n hours12h: \"hh\",\n hours24h: \"HH\",\n seconds: \"ss\",\n fullTime: \"LT\",\n fullTime12h: \"hh:mm A\",\n fullTime24h: \"HH:mm\",\n fullDate: \"ll\",\n fullDateWithWeekday: \"dddd, LL\",\n fullDateTime: \"lll\",\n fullDateTime12h: \"ll hh:mm A\",\n fullDateTime24h: \"ll HH:mm\",\n keyboardDate: \"L\",\n keyboardDateTime: \"L LT\",\n keyboardDateTime12h: \"L hh:mm A\",\n keyboardDateTime24h: \"L HH:mm\",\n systemDateTime: \"L HH:mm:ss.SSS\",\n filePathDateTime: \"L_HH-mm-ss-SSS\"\n};\n\nexport let locale = \"${\n context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale\n ? `${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale}`\n : \"en-US\"\n }\";\n\nexport const type = \"moment\";\n\nconst moment = defaultMoment;\n\n/**\n * Creates a date object using the provided value.\n *\n * @remarks\n * 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.\n *\n * @example\n * \\`\\`\\`ts\n * import { createDate } from \"storm:date\";\n *\n * const date = createDate(\"2023-10-01\");\n * console.log(date.format(\"YYYY-MM-DD\")); // Outputs: 2023-10-01\n * \\`\\`\\`\n *\n * @param value - The value to create the date object from.\n * @returns A date object or \\`null\\` if the value is \\`null\\`.\n */\nexport function createDate<\n TArg extends unknown = undefined,\n TResultingDate extends unknown = TArg extends null\n ? null\n : TArg extends undefined\n ? defaultMoment.Moment\n : defaultMoment.Moment | null\n>(value?: TArg): TResultingDate {\n if (value === null) {\n return null as TResultingDate;\n }\n\n const _moment = moment(value);\n if (locale) {\n _moment.locale(locale);\n }\n\n return _moment as TResultingDate;\n}\n\n\nexport function is12HourCycleInCurrentLocale(): boolean {\n return /A|a/.test(\n moment.localeData(getCurrentLocaleCode()).longDateFormat(\"LT\")\n );\n};\n\nexport function getFormatHelperText(format: string) {\n // @see https://github.com/moment/moment/blob/develop/src/lib/format/format.js#L6\n const localFormattingTokens = /(\\[[^\\[]*\\])|(\\\\)?(LTS|LT|LL?L?L?|l{1,4})|./g;\n\n return (\n format\n .match(localFormattingTokens)\n ?.map((token) => {\n const firstCharacter = token[0];\n if (firstCharacter === \"L\" || firstCharacter === \";\") {\n return moment\n .localeData(getCurrentLocaleCode())\n .longDateFormat(token as LongDateFormatKey);\n }\n\n return token;\n })\n .join(\"\")\n .replace(/a/gi, \"(a|p)m\")\n .toLocaleLowerCase() ?? format\n );\n};\n\nexport function getCurrentLocaleCode() {\n return locale || moment.locale();\n};\n\nexport function parseISO(isoString: string) {\n return moment(isoString, true);\n};\n\nexport function toISO(value: Moment) {\n return value.toISOString();\n};\n\nexport function parse(value: string, format: string) {\n if (value === \"\") {\n return null;\n }\n\n if (locale) {\n return moment(value, format, locale, true);\n }\n\n return moment(value, format, true);\n};\n\nexport function toJsDate(value: Moment) {\n return value.toDate();\n};\n\nexport function isValid(value: any) {\n return moment(value).isValid();\n};\n\nexport function isNull(date: Moment) {\n return date === null;\n};\n\nexport function getDiff(date: Moment, comparing: Moment | string, unit?: TimeUnit) {\n if (!moment(comparing).isValid()) {\n return 0;\n }\n\n return date.diff(comparing, unit);\n};\n\nexport function isAfter(date: Moment, value: Moment) {\n return date.isAfter(value);\n};\n\nexport function isBefore(date: Moment, value: Moment) {\n return date.isBefore(value);\n};\n\nexport function isAfterDay(date: Moment, value: Moment) {\n return date.isAfter(value, \"day\");\n};\n\nexport function isBeforeDay(date: Moment, value: Moment) {\n return date.isBefore(value, \"day\");\n};\n\nexport function isBeforeMonth(date: Moment, value: Moment) {\n return date.isBefore(value, \"month\");\n};\n\nexport function isAfterMonth(date: Moment, value: Moment) {\n return date.isAfter(value, \"month\");\n};\n\nexport function isBeforeYear(date: Moment, value: Moment) {\n return date.isBefore(value, \"year\");\n};\n\nexport function isAfterYear(date: Moment, value: Moment) {\n return date.isAfter(value, \"year\");\n};\n\nexport function startOfDay(date: Moment) {\n return date.clone().startOf(\"day\");\n};\n\nexport function endOfDay(date: Moment) {\n return date.clone().endOf(\"day\");\n};\n\nexport function format(date: Moment, formatKey: keyof DateFormats) {\n return formatByString(date, formats[formatKey]);\n};\n\nexport function formatByString(date: Moment, formatString: string) {\n const clonedDate = date.clone();\n if (locale) {\n clonedDate.locale(locale);\n }\n return clonedDate.format(formatString);\n};\n\nexport function formatNumber(numberToFormat: string) {\n return numberToFormat;\n};\n\nexport function getHours(date: Moment) {\n return date.get(\"hours\");\n};\n\nexport function addSeconds(date: Moment, count: number) {\n return count < 0\n ? date.clone().subtract(Math.abs(count), \"seconds\")\n : date.clone().add(count, \"seconds\");\n};\n\nexport function addMinutes(date: Moment, count: number) {\n return count < 0\n ? date.clone().subtract(Math.abs(count), \"minutes\")\n : date.clone().add(count, \"minutes\");\n};\n\nexport function addHours(date: Moment, count: number) {\n return count < 0\n ? date.clone().subtract(Math.abs(count), \"hours\")\n : date.clone().add(count, \"hours\");\n};\n\nexport function addDays(date: Moment, count: number) {\n return count < 0\n ? date.clone().subtract(Math.abs(count), \"days\")\n : date.clone().add(count, \"days\");\n};\n\nexport function addWeeks(date: Moment, count: number) {\n return count < 0\n ? date.clone().subtract(Math.abs(count), \"weeks\")\n : date.clone().add(count, \"weeks\");\n};\n\nexport function addMonths(date: Moment, count: number) {\n return count < 0\n ? date.clone().subtract(Math.abs(count), \"months\")\n : date.clone().add(count, \"months\");\n};\n\nexport function addYears(date: Moment, count: number) {\n return count < 0\n ? date.clone().subtract(Math.abs(count), \"years\")\n : date.clone().add(count, \"years\");\n};\n\nexport function setHours(date: Moment, count: number) {\n return date.clone().hours(count);\n};\n\nexport function getMinutes(date: Moment) {\n return date.get(\"minutes\");\n};\n\nexport function setMinutes(date: Moment, count: number) {\n return date.clone().minutes(count);\n};\n\nexport function getSeconds(date: Moment) {\n return date.get(\"seconds\");\n};\n\nexport function setSeconds(date: Moment, count: number) {\n return date.clone().seconds(count);\n};\n\nexport function getWeek(date: Moment) {\n return date.get(\"week\");\n};\n\nexport function getMonth(date: Moment) {\n return date.get(\"month\");\n};\n\nexport function getDaysInMonth(date: Moment) {\n return date.daysInMonth();\n};\n\nexport function isSameDay(date: Moment, comparing: Moment) {\n return date.isSame(comparing, \"day\");\n};\n\nexport function isSameMonth(date: Moment, comparing: Moment) {\n return date.isSame(comparing, \"month\");\n};\n\nexport function isSameYear(date: Moment, comparing: Moment) {\n return date.isSame(comparing, \"year\");\n};\n\nexport function isSameHour(date: Moment, comparing: Moment) {\n return date.isSame(comparing, \"hour\");\n};\n\nexport function setMonth(date: Moment, count: number) {\n return date.clone().month(count);\n};\n\nexport function getMeridiemText(meridiem: \"am\" | \"pm\") {\n if (is12HourCycleInCurrentLocale()) {\n // AM/PM translation only possible in those who have 12 hour cycle in locale.\n return moment\n .localeData(getCurrentLocaleCode())\n .meridiem(meridiem === \"am\" ? 0 : 13, 0, false);\n }\n\n return meridiem === \"am\" ? \"AM\" : \"PM\"; // fallback for de, ru, ...etc\n};\n\nexport function startOfYear(date: Moment) {\n return date.clone().startOf(\"year\");\n};\n\nexport function endOfYear(date: Moment) {\n return date.clone().endOf(\"year\");\n};\n\nexport function startOfMonth(date: Moment) {\n return date.clone().startOf(\"month\");\n};\n\nexport function endOfMonth(date: Moment) {\n return date.clone().endOf(\"month\");\n};\n\nexport function startOfWeek(date: Moment) {\n return date.clone().startOf(\"week\");\n};\n\nexport function endOfWeek(date: Moment) {\n return date.clone().endOf(\"week\");\n};\n\nexport function getNextMonth(date: Moment) {\n return date.clone().add(1, \"month\");\n};\n\nexport function getPreviousMonth(date: Moment) {\n return date.clone().subtract(1, \"month\");\n};\n\nexport function getMonthArray(date: Moment) {\n const firstMonth = date.clone().startOf(\"year\");\n const monthArray = [firstMonth];\n\n while (monthArray.length < 12) {\n const prevMonth = monthArray[monthArray.length - 1];\n monthArray.push(getNextMonth(prevMonth));\n }\n\n return monthArray;\n};\n\nexport function getYear(date: Moment) {\n return date.get(\"year\");\n};\n\nexport function setYear(date: Moment, year: number) {\n return date.clone().set(\"year\", year);\n};\n\nexport function getDate(date: Moment) {\n return date.get(\"date\");\n};\n\nexport function setDate(date: Moment, day: number) {\n return date.clone().set(\"date\", day);\n};\n\nexport function mergeDateAndTime(date: Moment, time: Moment) {\n return date.hour(time.hour()).minute(time.minute()).second(time.second());\n};\n\nexport function getWeekdays() {\n return moment.weekdaysShort(true);\n};\n\nexport function isEqual(value: any, comparing: any) {\n if (value === null && comparing === null) {\n return true;\n }\n\n return moment(value).isSame(comparing);\n};\n\nexport function getWeekArray(date: Moment) {\n const start = date.clone().startOf(\"month\").startOf(\"week\");\n const end = date.clone().endOf(\"month\").endOf(\"week\");\n\n let count = 0;\n let current = start;\n const nestedWeeks: Moment[][] = [];\n\n while (current.isBefore(end)) {\n const weekNumber = Math.floor(count / 7);\n nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];\n nestedWeeks[weekNumber].push(current);\n\n current = current.clone().add(1, \"day\");\n count += 1;\n }\n\n return nestedWeeks;\n};\n\nexport function getYearRange(start: Moment, end: Moment) {\n const startDate = moment(start).startOf(\"year\");\n const endDate = moment(end).endOf(\"year\");\n const years: Moment[] = [];\n\n let current = startDate;\n while (current.isBefore(endDate)) {\n years.push(current);\n current = current.clone().add(1, \"year\");\n }\n\n return years;\n};\n\nexport function isWithinRange(date: Moment, [start, end]: [Moment, Moment]) {\n return date.isBetween(start, end, null, \"[]\");\n};\n\n\n`;\n}\n"],"mappings":";;;;;;;;;AA2BA,SAAgB,aAAa,SAA4B;AACvD,QAAO;;;;aAII,QAAQ,OAAO,UAAU;;;EAGpC,cAAc,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA4CrB,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,gBAAgB,SACzD,GAAG,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,gBAAgB,WAChE,QACL"}
package/dist/index.cjs CHANGED
@@ -1,10 +1,10 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
2
  const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
- const require_date_fns = require('./src/components/date-fns.cjs');
4
- const require_dayjs = require('./src/components/dayjs.cjs');
5
- const require_luxon = require('./src/components/luxon.cjs');
6
- const require_moment = require('./src/components/moment.cjs');
7
- require('./src/components/index.cjs');
3
+ const require_date_fns = require('./components/date-fns.cjs');
4
+ const require_dayjs = require('./components/dayjs.cjs');
5
+ const require_luxon = require('./components/luxon.cjs');
6
+ const require_moment = require('./components/moment.cjs');
7
+ require('./components/index.cjs');
8
8
  let _powerlines_plugin_env = require("@powerlines/plugin-env");
9
9
  _powerlines_plugin_env = require_runtime.__toESM(_powerlines_plugin_env);
10
10
  let defu = require("defu");
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { DateLibraryType, DatePluginContext, DatePluginOptions, DatePluginResolvedConfig, DatePluginUserConfig, __ΩDateLibraryType, __ΩDatePluginContext, __ΩDatePluginOptions, __ΩDatePluginResolvedConfig, __ΩDatePluginUserConfig } from "./types/plugin.cjs";
2
- import { dateFnsModule } from "./src/components/date-fns.cjs";
3
- import { dayjsModule } from "./src/components/dayjs.cjs";
4
- import { luxonModule } from "./src/components/luxon.cjs";
5
- import { momentModule } from "./src/components/moment.cjs";
2
+ import { dateFnsModule } from "./components/date-fns.cjs";
3
+ import { dayjsModule } from "./components/dayjs.cjs";
4
+ import { luxonModule } from "./components/luxon.cjs";
5
+ import { momentModule } from "./components/moment.cjs";
6
6
  import { DateFormats, StormDateInterface, TimeUnit, __ΩDateFormats, __ΩStormDateInterface, __ΩTimeUnit } from "./types/runtime.cjs";
7
7
  import { Plugin } from "powerlines";
8
8
 
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { DateLibraryType, DatePluginContext, DatePluginOptions, DatePluginResolvedConfig, DatePluginUserConfig, __ΩDateLibraryType, __ΩDatePluginContext, __ΩDatePluginOptions, __ΩDatePluginResolvedConfig, __ΩDatePluginUserConfig } from "./types/plugin.mjs";
2
- import { dateFnsModule } from "./src/components/date-fns.mjs";
3
- import { dayjsModule } from "./src/components/dayjs.mjs";
4
- import { luxonModule } from "./src/components/luxon.mjs";
5
- import { momentModule } from "./src/components/moment.mjs";
2
+ import { dateFnsModule } from "./components/date-fns.mjs";
3
+ import { dayjsModule } from "./components/dayjs.mjs";
4
+ import { luxonModule } from "./components/luxon.mjs";
5
+ import { momentModule } from "./components/moment.mjs";
6
6
  import { DateFormats, StormDateInterface, TimeUnit, __ΩDateFormats, __ΩStormDateInterface, __ΩTimeUnit } from "./types/runtime.mjs";
7
7
  import { Plugin } from "powerlines";
8
8
 
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { dateFnsModule } from "./src/components/date-fns.mjs";
2
- import { dayjsModule } from "./src/components/dayjs.mjs";
3
- import { luxonModule } from "./src/components/luxon.mjs";
4
- import { momentModule } from "./src/components/moment.mjs";
5
- import "./src/components/index.mjs";
1
+ import { dateFnsModule } from "./components/date-fns.mjs";
2
+ import { dayjsModule } from "./components/dayjs.mjs";
3
+ import { luxonModule } from "./components/luxon.mjs";
4
+ import { momentModule } from "./components/moment.mjs";
5
+ import "./components/index.mjs";
6
6
  import env from "@powerlines/plugin-env";
7
7
  import defu from "defu";
8
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-date",
3
- "version": "0.12.418",
3
+ "version": "0.12.420",
4
4
  "private": false,
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
  "keywords": ["powerlines", "storm-software", "powerlines-plugin"],
@@ -103,16 +103,16 @@
103
103
  "types": "./dist/index.d.cts",
104
104
  "files": ["dist/**/*"],
105
105
  "dependencies": {
106
- "@powerlines/plugin-env": "^0.16.74",
107
- "@storm-software/config-tools": "1.189.28",
106
+ "@powerlines/plugin-env": "^0.16.76",
107
+ "@storm-software/config-tools": "^1.189.31",
108
108
  "@stryke/path": "^0.27.0",
109
109
  "defu": "^6.1.4",
110
- "powerlines": "^0.41.18"
110
+ "powerlines": "^0.41.20"
111
111
  },
112
112
  "devDependencies": {
113
- "@powerlines/plugin-plugin": "^0.12.304",
113
+ "@powerlines/plugin-plugin": "^0.12.306",
114
114
  "@types/node": "^25.5.0"
115
115
  },
116
116
  "publishConfig": { "access": "public" },
117
- "gitHead": "a1a628f5572bdf69729d5f7504c63bfd7513785f"
117
+ "gitHead": "35de1fedab5f201f37c40614247597978a213844"
118
118
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"date-fns.d.cts","names":[],"sources":["../../../src/components/date-fns.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,aAAA,CAAc,OAAA,EAAS,iBAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"date-fns.d.mts","names":[],"sources":["../../../src/components/date-fns.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,aAAA,CAAc,OAAA,EAAS,iBAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"date-fns.mjs","names":[],"sources":["../../../src/components/date-fns.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getFileHeader } from \"powerlines/lib/utilities/file-header\";\nimport { DatePluginContext } from \"../types/plugin\";\n\n/**\n * Generates the Powerlines configuration file.\n *\n * @param context - The build context containing runtime information.\n * @returns A string representing the configuration file content.\n */\nexport function dateFnsModule(context: DatePluginContext) {\n return `\n/**\n * The Date module provides utility functions for date manipulation and formatting\n *\n * @module ${context.config.framework}:date\n */\n\n${getFileHeader(context)}\n\nimport { DateFormats, TimeUnit } from \"@powerlines/plugin-date/types/runtime\";\nimport { addDays as dateFnsAddDays } from \"date-fns/addDays\";\nimport { addHours as dateFnsAddHours } from \"date-fns/addHours\";\nimport { addMinutes as dateFnsAddMinutes } from \"date-fns/addMinutes\";\nimport { addMonths as dateFnsAddMonths } from \"date-fns/addMonths\";\nimport { addSeconds as dateFnsAddSeconds } from \"date-fns/addSeconds\";\nimport { addWeeks as dateFnsAddWeeks } from \"date-fns/addWeeks\";\nimport { addYears as dateFnsAddYears } from \"date-fns/addYears\";\nimport { differenceInDays } from \"date-fns/differenceInDays\";\nimport { differenceInHours } from \"date-fns/differenceInHours\";\nimport { differenceInMilliseconds } from \"date-fns/differenceInMilliseconds\";\nimport { differenceInMinutes } from \"date-fns/differenceInMinutes\";\nimport { differenceInMonths } from \"date-fns/differenceInMonths\";\nimport { differenceInQuarters } from \"date-fns/differenceInQuarters\";\nimport { differenceInSeconds } from \"date-fns/differenceInSeconds\";\nimport { differenceInWeeks } from \"date-fns/differenceInWeeks\";\nimport { differenceInYears } from \"date-fns/differenceInYears\";\nimport { eachDayOfInterval } from \"date-fns/eachDayOfInterval\";\nimport { endOfDay as dateFnsEndOfDay } from \"date-fns/endOfDay\";\nimport { endOfMonth as dateFnsEndOfMonth } from \"date-fns/endOfMonth\";\nimport { endOfWeek as dateFnsEndOfWeek } from \"date-fns/endOfWeek\";\nimport { endOfYear as dateFnsEndOfYear } from \"date-fns/endOfYear\";\nimport { format as dateFnsFormat, longFormatters } from \"date-fns/format\";\nimport { formatISO } from \"date-fns/formatISO\";\nimport { getDate as dateFnsGetDate } from \"date-fns/getDate\";\nimport { getDay as dateFnsGetDay } from \"date-fns/getDay\";\nimport { getDaysInMonth as dateFnsGetDaysInMonth } from \"date-fns/getDaysInMonth\";\nimport { getHours as dateFnsGetHours } from \"date-fns/getHours\";\nimport { getMinutes as dateFnsGetMinutes } from \"date-fns/getMinutes\";\nimport { getMonth as dateFnsGetMonth } from \"date-fns/getMonth\";\nimport { getSeconds as dateFnsGetSeconds } from \"date-fns/getSeconds\";\nimport { getWeek as dateFnsGetWeek } from \"date-fns/getWeek\";\nimport { getYear as dateFnsGetYear } from \"date-fns/getYear\";\nimport { isAfter as dateFnsIsAfter } from \"date-fns/isAfter\";\nimport { isBefore as dateFnsIsBefore } from \"date-fns/isBefore\";\nimport { isEqual as dateFnsIsEqual } from \"date-fns/isEqual\";\nimport { isSameDay as dateFnsIsSameDay } from \"date-fns/isSameDay\";\nimport { isSameHour as dateFnsIsSameHour } from \"date-fns/isSameHour\";\nimport { isSameMonth as dateFnsIsSameMonth } from \"date-fns/isSameMonth\";\nimport { isSameYear as dateFnsIsSameYear } from \"date-fns/isSameYear\";\nimport { isValid as dateFnsIsValid } from \"date-fns/isValid\";\nimport { isWithinInterval } from \"date-fns/isWithinInterval\";\nimport { Locale } from \"date-fns/locale\";\nimport { ${\n context.env.parsed.DEFAULT_LOCALE?.replaceAll(\"-\", \"\") || \"enUS\"\n } as defaultLocale } from \"date-fns/locale/${\n context.env.parsed.DEFAULT_LOCALE || \"en-US\"\n }\";\nimport { parse as dateFnsParse } from \"date-fns/parse\";\nimport { parseISO as dateFnsParseISO } from \"date-fns/parseISO\";\nimport { setDate as dateFnsSetDate } from \"date-fns/setDate\";\nimport { setHours as dateFnsSetHours } from \"date-fns/setHours\";\nimport { setMinutes as dateFnsSetMinutes } from \"date-fns/setMinutes\";\nimport { setMonth as dateFnsSetMonth } from \"date-fns/setMonth\";\nimport { setSeconds as dateFnsSetSeconds } from \"date-fns/setSeconds\";\nimport { setYear as dateFnsSetYear } from \"date-fns/setYear\";\nimport { startOfDay as dateFnsStartOfDay } from \"date-fns/startOfDay\";\nimport { startOfMonth as dateFnsStartOfMonth } from \"date-fns/startOfMonth\";\nimport { startOfWeek as dateFnsStartOfWeek } from \"date-fns/startOfWeek\";\nimport { startOfYear as dateFnsStartOfYear } from \"date-fns/startOfYear\";\n\nexport const formats: DateFormats = {\n dayOfMonth: \"d\",\n fullDate: \"PP\",\n fullDateWithWeekday: \"PPPP\",\n fullDateTime: \"PP p\",\n fullDateTime12h: \"PP hh:mm aa\",\n fullDateTime24h: \"PP HH:mm\",\n fullTime: \"p\",\n fullTime12h: \"hh:mm aa\",\n fullTime24h: \"HH:mm\",\n hours12h: \"hh\",\n hours24h: \"HH\",\n keyboardDate: \"P\",\n keyboardDateTime: \"P p\",\n keyboardDateTime12h: \"P hh:mm aa\",\n keyboardDateTime24h: \"P HH:mm\",\n systemDateTime: \"P HH:mm:ss.SSS\",\n filePathDateTime: \"P_HH-mm-ss-SSS\",\n minutes: \"mm\",\n month: \"LLLL\",\n monthAndDate: \"MMMM d\",\n monthAndYear: \"LLLL yyyy\",\n monthShort: \"MMM\",\n weekday: \"EEEE\",\n weekdayShort: \"EEE\",\n normalDate: \"d MMMM\",\n normalDateWithWeekday: \"EEE, MMM d\",\n seconds: \"ss\",\n shortDate: \"MMM d\",\n year: \"yyyy\"\n};\n\nexport const locale: Locale = defaultLocale;\n\n/**\n * Creates a date object using the provided value.\n *\n * @remarks\n * 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.\n *\n * @example\n * \\`\\`\\`ts\n * import { createDate } from \"storm:date\";\n *\n * const date = createDate(\"2023-10-01\");\n * console.log(date.format(\"YYYY-MM-DD\")); // Outputs: 2023-10-01\n * \\`\\`\\`\n *\n * @param value - The value to create the date object from.\n * @returns A date object or \\`null\\` if the value is \\`null\\`.\n */\nexport function createDate<\n TArg = undefined,\n TResultingDate = TArg extends null\n ? null\n : TArg extends undefined\n ? Date\n : Date | null\n>(value?: TArg): TResultingDate {\n if (typeof value === \"undefined\") {\n return new Date() as TResultingDate;\n }\n if (value === null) {\n return null as TResultingDate;\n }\n return new Date(value as string | number) as TResultingDate;\n}\n\nexport const type = \"date-fns\";\n\n// Note: date-fns input types are more lenient than this adapter, so we need to expose our more\n// strict signature and delegate to the more lenient signature. Otherwise, we have downstream type errors upon usage.\nexport function is12HourCycleInCurrentLocale(): boolean {\n if (locale) {\n return /a/.test(locale.formatLong?.time({}));\n }\n\n // By default date-fns is using en-US locale with am/pm enabled\n return true;\n}\n\nexport function getFormatHelperText(format: string) {\n // @see https://github.com/date-fns/date-fns/blob/master/src/format/index.js#L31\n const longFormatRegexp = /P+p+|P+|p+|''|'(?:''|[^'])+(?:'|$)|./g;\n const _locale = locale || defaultLocale;\n\n return (\n format\n .match(longFormatRegexp)\n ?.map(token => {\n const firstCharacter = token[0];\n if (firstCharacter === \"p\" || firstCharacter === \"P\") {\n const longFormatter = longFormatters[firstCharacter]!;\n\n return longFormatter(token, _locale.formatLong);\n }\n\n return token;\n })\n .join(\"\")\n .replace(/aaa|aa|a/g, \"(a|p)m\")\n .toLocaleLowerCase() ?? format\n );\n}\n\nexport function parseISO(isoString: string) {\n return dateFnsParseISO(isoString);\n}\n\nexport function toISO(value: Date) {\n return formatISO(value, {\n format: \"extended\"\n });\n}\n\nexport function getCurrentLocaleCode() {\n return locale?.code || $storm.env.DEFAULT_LOCALE;\n}\n\nexport function addSeconds(value: Date, count: number) {\n return dateFnsAddSeconds(value, count);\n}\n\nexport function addMinutes(value: Date, count: number) {\n return dateFnsAddMinutes(value, count);\n}\n\nexport function addHours(value: Date, count: number) {\n return dateFnsAddHours(value, count);\n}\n\nexport function addDays(value: Date, count: number) {\n return dateFnsAddDays(value, count);\n}\n\nexport function addWeeks(value: Date, count: number) {\n return dateFnsAddWeeks(value, count);\n}\n\nexport function addMonths(value: Date, count: number) {\n return dateFnsAddMonths(value, count);\n}\n\nexport function addYears(value: Date, count: number) {\n return dateFnsAddYears(value, count);\n}\n\nexport function isValid(value: any) {\n return dateFnsIsValid(createDate(value));\n}\n\nexport function getDiff(\n value: Date,\n comparing: Date | string,\n unit?: TimeUnit\n) {\n // we output 0 if the compare date is string and parsing is not valid\n const dateToCompare = createDate(comparing) ?? value;\n if (!isValid(dateToCompare)) {\n return 0;\n }\n\n switch (unit) {\n case \"years\":\n return differenceInYears(value, dateToCompare);\n case \"quarters\":\n return differenceInQuarters(value, dateToCompare);\n case \"months\":\n return differenceInMonths(value, dateToCompare);\n case \"weeks\":\n return differenceInWeeks(value, dateToCompare);\n case \"days\":\n return differenceInDays(value, dateToCompare);\n case \"hours\":\n return differenceInHours(value, dateToCompare);\n case \"minutes\":\n return differenceInMinutes(value, dateToCompare);\n case \"seconds\":\n return differenceInSeconds(value, dateToCompare);\n case \"milliseconds\":\n case undefined:\n default:\n return differenceInMilliseconds(value, dateToCompare);\n }\n}\n\nexport function isAfter(value: Date, comparing: Date) {\n return dateFnsIsAfter(value, comparing);\n}\n\nexport function isBefore(value: Date, comparing: Date) {\n return dateFnsIsBefore(value, comparing);\n}\n\nexport function startOfDay(value: Date) {\n return dateFnsStartOfDay(value);\n}\n\nexport function endOfDay(value: Date) {\n return dateFnsEndOfDay(value);\n}\n\nexport function getHours(value: Date) {\n return dateFnsGetHours(value);\n}\n\nexport function setHours(value: Date, count: number) {\n return dateFnsSetHours(value, count);\n}\n\nexport function setMinutes(value: Date, count: number) {\n return dateFnsSetMinutes(value, count);\n}\n\nexport function getSeconds(value: Date) {\n return dateFnsGetSeconds(value);\n}\n\nexport function setSeconds(value: Date, count: number) {\n return dateFnsSetSeconds(value, count);\n}\n\nexport function isSameDay(value: Date, comparing: Date) {\n return dateFnsIsSameDay(value, comparing);\n}\n\nexport function isSameMonth(value: Date, comparing: Date) {\n return dateFnsIsSameMonth(value, comparing);\n}\n\nexport function isSameYear(value: Date, comparing: Date) {\n return dateFnsIsSameYear(value, comparing);\n}\n\nexport function isSameHour(value: Date, comparing: Date) {\n return dateFnsIsSameHour(value, comparing);\n}\n\nexport function startOfYear(value: Date) {\n return dateFnsStartOfYear(value);\n}\n\nexport function endOfYear(value: Date) {\n return dateFnsEndOfYear(value);\n}\n\nexport function startOfMonth(value: Date) {\n return dateFnsStartOfMonth(value);\n}\n\nexport function endOfMonth(value: Date) {\n return dateFnsEndOfMonth(value);\n}\n\nexport function startOfWeek(value: Date) {\n return dateFnsStartOfWeek(value, {\n locale\n });\n}\n\nexport function endOfWeek(value: Date) {\n return dateFnsEndOfWeek(value, {\n locale\n });\n}\n\nexport function getYear(value: Date) {\n return dateFnsGetYear(value);\n}\n\nexport function setYear(value: Date, count: number) {\n return dateFnsSetYear(value, count);\n}\n\nexport function toJsDate(value: Date) {\n return value;\n}\n\nexport function parse(value: string, formatString: string) {\n if (value === \"\") {\n return null;\n }\n return dateFnsParse(value, formatString, new Date(), {\n locale\n });\n}\n\nexport function format(date: Date, formatKey: keyof DateFormats) {\n return formatByString(date, formats[formatKey]);\n}\n\nexport function formatByString(date: Date, formatString: string) {\n return dateFnsFormat(date, formatString, {\n locale\n });\n}\n\nexport function isEqual(date: any, comparing: any) {\n if (date === null && comparing === null) {\n return true;\n }\n return dateFnsIsEqual(date, comparing);\n}\n\nexport function isNull(date: Date) {\n return date === null;\n}\n\nexport function isAfterDay(date: Date, value: Date) {\n return isAfter(date, endOfDay(value));\n}\n\nexport function isBeforeDay(date: Date, value: Date) {\n return isBefore(date, startOfDay(value));\n}\n\nexport function isBeforeYear(date: Date, value: Date) {\n return isBefore(date, startOfYear(value));\n}\n\nexport function isBeforeMonth(value: Date, comparing: Date): boolean {\n return isBefore(value, startOfMonth(comparing));\n}\n\nexport function isAfterMonth(value: Date, comparing: Date): boolean {\n return isAfter(value, startOfMonth(comparing));\n}\n\nexport function isAfterYear(date: Date, value: Date) {\n return isAfter(date, endOfYear(value));\n}\n\nexport function isWithinRange(date: Date, [start, end]: [Date, Date]) {\n return isWithinInterval(date, {\n start,\n end\n });\n}\n\nexport function formatNumber(numberToFormat: string) {\n return numberToFormat;\n}\n\nexport function getMinutes(date: Date) {\n return dateFnsGetMinutes(date);\n}\n\nexport function getDate(date: Date) {\n return dateFnsGetDate(date);\n}\n\nexport function setDate(date: Date, count: number) {\n return dateFnsSetDate(date, count);\n}\n\nexport function getWeek(date: Date) {\n return dateFnsGetWeek(date);\n}\n\nexport function getMonth(date: Date) {\n return dateFnsGetMonth(date);\n}\n\nexport function getDaysInMonth(date: Date) {\n return dateFnsGetDaysInMonth(date);\n}\n\nexport function setMonth(date: Date, count: number) {\n return dateFnsSetMonth(date, count);\n}\n\nexport function getMeridiemText(meridiem: \"am\" | \"pm\") {\n return meridiem === \"am\" ? \"AM\" : \"PM\";\n}\n\nexport function getNextMonth(date: Date) {\n return addMonths(date, 1);\n}\n\nexport function getPreviousMonth(date: Date) {\n return addMonths(date, -1);\n}\n\nexport function getMonthArray(date: Date) {\n const firstMonth = startOfYear(date);\n const monthArray = [firstMonth];\n\n while (monthArray.length < 12) {\n const prevMonth = monthArray[monthArray.length - 1]!;\n monthArray.push(getNextMonth(prevMonth));\n }\n\n return monthArray;\n}\n\nexport function mergeDateAndTime(date: Date, time: Date) {\n return setSeconds(\n setMinutes(setHours(date, getHours(time)), getMinutes(time)),\n getSeconds(time)\n );\n}\n\nexport function getWeekdays() {\n const now = new Date();\n\n return eachDayOfInterval({\n start: startOfWeek(now),\n end: endOfWeek(now)\n }).map(day => formatByString(day, \"EEEEEE\"));\n}\n\nexport function getWeekArray(date: Date) {\n const start = startOfWeek(startOfMonth(date));\n const end = endOfWeek(endOfMonth(date));\n let count = 0;\n let current = start;\n const nestedWeeks: Date[][] = [];\n let lastDay = null as null | number;\n while (isBefore(current, end)) {\n const weekNumber = Math.floor(count / 7);\n nestedWeeks[weekNumber] ??= [];\n const day = dateFnsGetDay(current);\n if (lastDay !== day) {\n lastDay = day;\n nestedWeeks[weekNumber].push(current);\n count += 1;\n }\n current = addDays(current, 1);\n }\n return nestedWeeks;\n}\n\nexport function getYearRange(start: Date, end: Date) {\n const startDate = startOfYear(start);\n const endDate = endOfYear(end);\n const years: Date[] = [];\n\n let current = startDate;\n while (isBefore(current, endDate)) {\n years.push(current);\n current = addYears(current, 1);\n }\n return years;\n}\n\n\n`;\n}\n"],"mappings":";;;;;;;;;AA2BA,SAAgB,cAAc,SAA4B;AACxD,QAAO;;;;aAII,QAAQ,OAAO,UAAU;;;EAGpC,cAAc,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA8CrB,QAAQ,IAAI,OAAO,gBAAgB,WAAW,KAAK,GAAG,IAAI,OAC3D,4CACC,QAAQ,IAAI,OAAO,kBAAkB,QACtC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"dayjs.d.cts","names":[],"sources":["../../../src/components/dayjs.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,WAAA,CAAY,OAAA,EAAS,iBAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"dayjs.d.mts","names":[],"sources":["../../../src/components/dayjs.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,WAAA,CAAY,OAAA,EAAS,iBAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"dayjs.mjs","names":[],"sources":["../../../src/components/dayjs.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getFileHeader } from \"powerlines/lib/utilities/file-header\";\nimport { DatePluginContext } from \"../types/plugin\";\n\n/**\n * Generates the Powerlines configuration file.\n *\n * @param context - The build context containing runtime information.\n * @returns A string representing the configuration file content.\n */\nexport function dayjsModule(context: DatePluginContext) {\n return `\n/**\n * The Date module provides utility functions for date manipulation and formatting\n *\n * @module ${context.config.framework}:date\n */\n\n${getFileHeader(context)}\n\nimport defaultDayjs, { QUnitType } from \"dayjs\";\nimport customParseFormatPlugin from \"dayjs/plugin/customParseFormat\";\nimport localizedFormatPlugin from \"dayjs/plugin/localizedFormat\";\nimport isBetweenPlugin from \"dayjs/plugin/isBetween\";\nimport weekOfYear from \"dayjs/plugin/weekOfYear\";\nimport {\n StormDateInterface,\n DateFormats,\n TimeUnit\n} from \"@powerlines/plugin-date/types/runtime\";\n\ndefaultDayjs.extend(customParseFormatPlugin);\ndefaultDayjs.extend(localizedFormatPlugin);\ndefaultDayjs.extend(isBetweenPlugin);\ndefaultDayjs.extend(weekOfYear);\n\ninterface Opts {\n locale?: string;\n /** Make sure that your dayjs instance extends customParseFormat and advancedFormat */\n instance?: typeof defaultDayjs;\n formats?: Partial<DateFormats>;\n}\n\ntype Dayjs = defaultDayjs.Dayjs;\ntype Constructor<TDate extends Dayjs> = (\n ...args: Parameters<typeof defaultDayjs>\n) => TDate;\nconst withLocale = <TDate extends Dayjs>(\n dayjs: any,\n locale?: string\n): Constructor<TDate> => (!locale ? dayjs : (...args) => dayjs(...args).locale(locale));\n\nexport const formats: DateFormats = {\n normalDateWithWeekday: \"ddd, MMM D\",\n normalDate: \"D MMMM\",\n shortDate: \"MMM D\",\n monthAndDate: \"MMMM D\",\n dayOfMonth: \"D\",\n year: \"YYYY\",\n month: \"MMMM\",\n monthShort: \"MMM\",\n monthAndYear: \"MMMM YYYY\",\n weekday: \"dddd\",\n weekdayShort: \"ddd\",\n minutes: \"mm\",\n hours12h: \"hh\",\n hours24h: \"HH\",\n seconds: \"ss\",\n fullTime: \"LT\",\n fullTime12h: \"hh:mm A\",\n fullTime24h: \"HH:mm\",\n fullDate: \"ll\",\n fullDateWithWeekday: \"dddd, LL\",\n fullDateTime: \"lll\",\n fullDateTime12h: \"ll hh:mm A\",\n fullDateTime24h: \"ll HH:mm\",\n keyboardDate: \"L\",\n keyboardDateTime: \"L LT\",\n keyboardDateTime12h: \"L hh:mm A\",\n keyboardDateTime24h: \"L HH:mm\",\n systemDateTime: \"L HH:mm:ss.SSS\",\n filePathDateTime: \"L_HH-mm-ss-SSS\"\n};\n\nexport let locale = \"${\n context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale\n ? `${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale}`\n : \"en-US\"\n }\";\n\nexport const dayjs = withLocale(defaultDayjs, locale);\n\nexport const type = \"dayjs\";\n\n/**\n * Creates a date object using the provided value.\n *\n * @remarks\n * 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.\n *\n * @example\n * \\`\\`\\`ts\n * import { createDate } from \"storm:date\";\n *\n * const date = createDate(\"2023-10-01\");\n * console.log(date.format(\"YYYY-MM-DD\")); // Outputs: 2023-10-01\n * \\`\\`\\`\n *\n * @param value - The value to create the date object from.\n * @returns A date object or \\`null\\` if the value is \\`null\\`.\n */\nexport function createDate<\n TArg extends unknown = undefined,\n TResultingDate extends unknown = TArg extends null\n ? null\n : TArg extends undefined\n ? TDate\n : TDate | null\n>(value?: TArg): TResultingDate {\n if (value === null) {\n return null as TResultingDate;\n }\n\n return dayjs(value as any) as unknown as TResultingDate;\n}\n\nexport function is12HourCycleInCurrentLocale() {\n /* istanbul ignore next */\n return /A|a/.test(dayjs.Ls[dayjs.locale() || $storm.env.DEFAULT_LOCALE]?.formats?.LT ?? \"\");\n};\n\nexport function getCurrentLocaleCode() {\n return dayjs.locale() || $storm.env.DEFAULT_LOCALE;\n};\n\nexport function getFormatHelperText(format: string) {\n // @see https://github.com/iamkun/dayjs/blob/dev/src/plugin/localizedFormat/index.js\n const localFormattingTokens = /(\\[[^\\[]*\\])|(\\\\)?(LTS|LT|LL?L?L?)|./g;\n\n return (\n format\n .match(localFormattingTokens)\n ?.map((token) => {\n const firstCharacter = token[0];\n if (firstCharacter === \"L\") {\n /* istanbul ignore next */\n return (\n dayjs.Ls[dayjs.locale() || $storm.env.DEFAULT_LOCALE]?.formats[\n token as keyof ILocale[\"formats\"]\n ] ?? token\n );\n }\n return token;\n })\n .join(\"\")\n .replace(/a/gi, \"(a|p)m\")\n .toLocaleLowerCase() ?? format\n );\n};\n\nexport function parseISO(isoString: string) {\n return dayjs(isoString);\n};\n\nexport function toISO(value: Dayjs) {\n return value.toISOString();\n};\n\nexport function parse(value: any, format: string) {\n if (value === \"\") {\n return null;\n }\n\n return dayjs(value, format, dayjs.locale(), true);\n};\n\nexport function toJsDate(value: Dayjs) {\n return value.toDate();\n};\n\nexport function isValid(value: any) {\n return dayjs(value).isValid();\n};\n\nexport function isNull(date: Dayjs | null) {\n return date === null;\n};\n\nexport function getDiff(date: Dayjs, comparing: Dayjs | string, units?: Unit) {\n if (typeof comparing === \"string\") {\n comparing = dayjs(comparing);\n }\n\n if (!comparing.isValid()) {\n return 0;\n }\n\n return date.diff(comparing, units as QUnitType);\n};\n\nexport function isAfter(date: Dayjs, value: Dayjs) {\n return date.isAfter(value);\n};\n\nexport function isBefore(date: Dayjs, value: Dayjs) {\n return date.isBefore(value);\n};\n\nexport function isAfterDay(date: Dayjs, value: Dayjs) {\n return date.isAfter(value, \"day\");\n};\n\nexport function isBeforeDay(date: Dayjs, value: Dayjs) {\n return date.isBefore(value, \"day\");\n};\n\nexport function isAfterMonth(date: Dayjs, value: Dayjs) {\n return date.isAfter(value, \"month\");\n};\n\nexport function isBeforeMonth(date: Dayjs, value: Dayjs) {\n return date.isBefore(value, \"month\");\n};\n\nexport function isBeforeYear(date: Dayjs, value: Dayjs) {\n return date.isBefore(value, \"year\");\n};\n\nexport function isAfterYear(date: Dayjs, value: Dayjs) {\n return date.isAfter(value, \"year\");\n};\n\nexport function startOfDay(date: Dayjs) {\n return date.startOf(\"day\");\n};\n\nexport function endOfDay(date: Dayjs) {\n return date.endOf(\"day\");\n};\n\nexport function format(date: Dayjs, formatKey: keyof DateFormats) {\n return formatByString(date, formats[formatKey]);\n};\n\nexport function formatByString(date: Dayjs, formatString: string) {\n return dayjs(date).format(formatString);\n};\n\nexport function formatNumber(numberToFormat: string) {\n return numberToFormat;\n};\n\nexport function getHours(date: Dayjs) {\n return date.hour();\n};\n\nexport function addSeconds(date: Dayjs, count: number) {\n return count < 0\n ? (date.subtract(Math.abs(count), \"second\") as Dayjs)\n : (date.add(count, \"second\") as Dayjs);\n};\n\nexport function addMinutes(date: Dayjs, count: number) {\n return count < 0\n ? (date.subtract(Math.abs(count), \"minute\") as Dayjs)\n : (date.add(count, \"minute\") as Dayjs);\n};\n\nexport function addHours(date: Dayjs, count: number) {\n return count < 0\n ? (date.subtract(Math.abs(count), \"hour\") as Dayjs)\n : (date.add(count, \"hour\") as Dayjs);\n};\n\nexport function addDays(date: Dayjs, count: number) {\n return count < 0\n ? (date.subtract(Math.abs(count), \"day\") as Dayjs)\n : (date.add(count, \"day\") as Dayjs);\n};\n\nexport function addWeeks(date: Dayjs, count: number) {\n return count < 0\n ? (date.subtract(Math.abs(count), \"week\") as Dayjs)\n : (date.add(count, \"week\") as Dayjs);\n};\n\nexport function addMonths(date: Dayjs, count: number) {\n return count < 0\n ? (date.subtract(Math.abs(count), \"month\") as Dayjs)\n : (date.add(count, \"month\") as Dayjs);\n};\n\nexport function addYears(date: Dayjs, count: number) {\n return count < 0\n ? (date.subtract(Math.abs(count), \"year\") as Dayjs)\n : (date.add(count, \"year\") as Dayjs);\n};\n\nexport function setMonth(date: Dayjs, count: number) {\n return date.set(\"month\", count) as Dayjs;\n};\n\nexport function setHours(date: Dayjs, count: number) {\n return date.set(\"hour\", count) as Dayjs;\n};\n\nexport function getMinutes(date: Dayjs) {\n return date.minute();\n};\n\nexport function setMinutes(date: Dayjs, count: number) {\n return date.set(\"minute\", count) as Dayjs;\n};\n\nexport function getSeconds(date: Dayjs) {\n return date.second();\n};\n\nexport function setSeconds(date: Dayjs, count: number) {\n return date.set(\"second\", count) as Dayjs;\n};\n\nexport function getWeek(date: Dayjs) {\n return date.week();\n};\n\nexport function getMonth(date: Dayjs) {\n return date.month();\n};\n\nexport function getDate(date: Dayjs) {\n return date.date();\n};\n\nexport function setDate(date: Dayjs, count: number) {\n return date.set(\"date\", count) as Dayjs;\n};\n\nexport function getDaysInMonth(date: Dayjs) {\n return date.daysInMonth();\n};\n\nexport function isSameDay(date: Dayjs, comparing: Dayjs) {\n return date.isSame(comparing, \"day\");\n};\n\nexport function isSameMonth(date: Dayjs, comparing: Dayjs) {\n return date.isSame(comparing, \"month\");\n};\n\nexport function isSameYear(date: Dayjs, comparing: Dayjs) {\n return date.isSame(comparing, \"year\");\n};\n\nexport function isSameHour(date: Dayjs, comparing: Dayjs) {\n return date.isSame(comparing, \"hour\");\n};\n\nexport function getMeridiemText(meridiem: \"am\" | \"pm\") {\n return meridiem === \"am\" ? \"AM\" : \"PM\";\n};\n\nexport function startOfYear(date: Dayjs) {\n return date.startOf(\"year\") as Dayjs;\n};\n\nexport function endOfYear(date: Dayjs) {\n return date.endOf(\"year\") as Dayjs;\n};\n\nexport function startOfMonth(date: Dayjs) {\n return date.startOf(\"month\") as Dayjs;\n};\n\nexport function endOfMonth(date: Dayjs) {\n return date.endOf(\"month\") as Dayjs;\n};\n\nexport function startOfWeek(date: Dayjs) {\n return date.startOf(\"week\") as Dayjs;\n};\n\nexport function endOfWeek(date: Dayjs) {\n return date.endOf(\"week\") as Dayjs;\n};\n\nexport function getNextMonth(date: Dayjs) {\n return date.add(1, \"month\") as Dayjs;\n};\n\nexport function getPreviousMonth(date: Dayjs) {\n return date.subtract(1, \"month\") as Dayjs;\n};\n\nexport function getMonthArray(date: Dayjs) {\n const firstMonth = date.startOf(\"year\") as Dayjs;\n const monthArray = [firstMonth];\n\n while (monthArray.length < 12) {\n const prevMonth = monthArray[monthArray.length - 1];\n monthArray.push(getNextMonth(prevMonth));\n }\n\n return monthArray;\n};\n\nexport function getYear(date: Dayjs) {\n return date.year();\n};\n\nexport function setYear(date: Dayjs, year: number) {\n return date.set(\"year\", year) as Dayjs;\n};\n\nexport function mergeDateAndTime(date: Dayjs, time: Dayjs) {\n return date.hour(time.hour()).minute(time.minute()).second(time.second()) as Dayjs;\n};\n\nexport function getWeekdays() {\n const start = dayjs().startOf(\"week\");\n return [0, 1, 2, 3, 4, 5, 6].map((diff) =>\n formatByString(start.add(diff, \"day\"), \"dd\")\n );\n};\n\nexport function isEqual(value: any, comparing: any) {\n if (value === null && comparing === null) {\n return true;\n }\n\n return dayjs(value).isSame(comparing);\n};\n\nexport function getWeekArray(date: Dayjs) {\n const start = dayjs(date).startOf(\"month\").startOf(\"week\") as Dayjs;\n const end = dayjs(date).endOf(\"month\").endOf(\"week\") as Dayjs;\n\n let count = 0;\n let current = start;\n const nestedWeeks: Dayjs[][] = [];\n\n while (current.isBefore(end)) {\n const weekNumber = Math.floor(count / 7);\n nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];\n nestedWeeks[weekNumber].push(current);\n\n current = current.add(1, \"day\") as TDate;\n count += 1;\n }\n\n return nestedWeeks;\n};\n\nexport function getYearRange(start: Dayjs, end: Dayjs) {\n const startDate = start.startOf(\"year\");\n const endDate = end.endOf(\"year\");\n const years: Dayjs[] = [];\n\n let current = startDate;\n while (current.isBefore(endDate)) {\n years.push(current);\n current = current.add(1, \"year\");\n }\n\n return years;\n};\n\nexport function isWithinRange(date: Dayjs, [start, end]: [Dayjs, Dayjs]) {\n return date.isBetween(start, end, null, \"[]\");\n};\n\n\n`;\n}\n"],"mappings":";;;;;;;;;AA2BA,SAAgB,YAAY,SAA4B;AACtD,QAAO;;;;aAII,QAAQ,OAAO,UAAU;;;EAGpC,cAAc,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAmErB,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,gBAAgB,SACzD,GAAG,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,gBAAgB,WAChE,QACL"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"luxon.d.cts","names":[],"sources":["../../../src/components/luxon.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,WAAA,CAAY,OAAA,EAAS,iBAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"luxon.d.mts","names":[],"sources":["../../../src/components/luxon.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,WAAA,CAAY,OAAA,EAAS,iBAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"luxon.mjs","names":[],"sources":["../../../src/components/luxon.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getFileHeader } from \"powerlines/lib/utilities/file-header\";\nimport { DatePluginContext } from \"../types/plugin\";\n\n/**\n * Generates the Powerlines configuration file.\n *\n * @param context - The build context containing runtime information.\n * @returns A string representing the configuration file content.\n */\nexport function luxonModule(context: DatePluginContext) {\n return `\n/**\n * The Date module provides utility functions for date manipulation and formatting\n *\n * @module ${context.config.framework}:date\n */\n\n${getFileHeader(context)}\n\nimport { DateTime, Settings, Info } from \"luxon\";\nimport {\n StormDateInterface,\n DateFormats,\n TimeUnit\n} from \"@powerlines/plugin-date/types/runtime\";\n\nexport const formats: DateFormats = {\n dayOfMonth: \"d\",\n fullDate: \"DD\",\n fullDateWithWeekday: \"DDDD\",\n fullDateTime: \"ff\",\n fullDateTime12h: \"DD, hh:mm a\",\n fullDateTime24h: \"DD, T\",\n fullTime: \"t\",\n fullTime12h: \"hh:mm a\",\n fullTime24h: \"HH:mm\",\n hours12h: \"hh\",\n hours24h: \"HH\",\n keyboardDate: \"D\",\n keyboardDateTime: \"D t\",\n keyboardDateTime12h: \"D hh:mm a\",\n keyboardDateTime24h: \"D T\",\n systemDateTime: \"D HH:mm:ss.SSS\",\n filePathDateTime: \"D_HH-mm-ss-SSS\",\n minutes: \"mm\",\n seconds: \"ss\",\n month: \"LLLL\",\n monthAndDate: \"MMMM d\",\n monthAndYear: \"LLLL yyyy\",\n monthShort: \"MMM\",\n weekday: \"cccc\",\n weekdayShort: \"ccc\",\n normalDate: \"d MMMM\",\n normalDateWithWeekday: \"EEE, MMM d\",\n shortDate: \"MMM d\",\n year: \"yyyy\",\n};\n\nexport let locale = \"${\n context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale\n ? `${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale}`\n : \"en-US\"\n }\";\n\nexport const type = \"luxon\";\n\n/**\n * Creates a date object using the provided value.\n *\n * @remarks\n * 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.\n *\n * @example\n * \\`\\`\\`ts\n * import { createDate } from \"storm:date\";\n *\n * const date = createDate(\"2023-10-01\");\n * console.log(date.format(\"YYYY-MM-DD\")); // Outputs: 2023-10-01\n * \\`\\`\\`\n *\n * @param value - The value to create the date object from.\n * @returns A date object or \\`null\\` if the value is \\`null\\`.\n */\nexport function createDate<\n TArg extends unknown = undefined,\n TResultingDate extends unknown = TArg extends null\n ? null\n : TArg extends undefined\n ? DateTime\n : DateTime | null\n>(value?: TArg): TResultingDate {\n if (typeof value === \"undefined\") {\n return DateTime.local() as TResultingDate;\n }\n\n if (value === null) {\n return null as TResultingDate;\n }\n\n if (typeof value === \"string\") {\n return DateTime.fromJSDate(new Date(value), { locale }) as TResultingDate;\n }\n\n if (DateTime.isDateTime(value)) {\n return value as TResultingDate;\n }\n\n if (value instanceof Date) {\n return DateTime.fromJSDate(value, { locale }) as TResultingDate;\n }\n\n /* istanbul ignore next */\n return DateTime.local() as TResultingDate;\n}\n\nexport function toJsDate(value: DateTime) {\n return value.toJSDate();\n};\n\nexport function parseISO(isoString: string) {\n return DateTime.fromISO(isoString);\n};\n\nexport function toISO(value: DateTime) {\n return value.toISO({ format: \"extended\" });\n};\n\nexport function parse(value: string, formatString: string) {\n if (value === \"\") {\n return null;\n }\n\n return DateTime.fromFormat(value, formatString, { locale });\n};\n\n/* istanbul ignore next */\nexport function is12HourCycleInCurrentLocale() {\n if (typeof Intl === \"undefined\" || typeof Intl.DateTimeFormat === \"undefined\") {\n return true; // Luxon defaults to en-US if Intl not found\n }\n\n return Boolean(\n new Intl.DateTimeFormat(this.locale, { hour: \"numeric\" })?.resolvedOptions()?.hour12\n );\n};\n\nexport function getFormatHelperText(format: string) {\n // Unfortunately there is no way for luxon to retrieve readable formats from localized format\n return \"\";\n};\n\n/* istanbul ignore next */\nexport function getCurrentLocaleCode() {\n return this.locale || Settings.defaultLocale;\n};\n\nexport function addSeconds(date: DateTime, count: number) {\n return date.plus({ seconds: count });\n};\n\nexport function addMinutes(date: DateTime, count: number) {\n return date.plus({ minutes: count });\n};\n\nexport function addHours(date: DateTime, count: number) {\n return date.plus({ hours: count });\n};\n\nexport function addDays(date: DateTime, count: number) {\n return date.plus({ days: count });\n};\n\nexport function addWeeks(date: DateTime, count: number) {\n return date.plus({ weeks: count });\n};\n\nexport function addMonths(date: DateTime, count: number) {\n return date.plus({ months: count });\n};\n\nexport function addYears(date: DateTime, count: number) {\n return date.plus({ years: count });\n};\n\nexport function isValid(value: any) {\n if (DateTime.isDateTime(value)) {\n return value.isValid;\n }\n\n if (value === null) {\n return false;\n }\n\n return createDate(value)?.isValid ?? false;\n};\n\nexport function isEqual(value: any, comparing: any) {\n if (value === null && comparing === null) {\n return true;\n }\n\n // make sure that null will not be passed to createDate\n if (value === null || comparing === null) {\n return false;\n }\n\n if (!createDate(comparing)) {\n /* istanbul ignore next */\n return false;\n }\n\n return createDate(value)?.equals(createDate(comparing) as DateTime) ?? false;\n};\n\nexport function isSameDay(date: DateTime, comparing: DateTime) {\n return date.hasSame(comparing, \"day\");\n};\n\nexport function isSameMonth(date: DateTime, comparing: DateTime) {\n return date.hasSame(comparing, \"month\");\n};\n\nexport function isSameYear(date: DateTime, comparing: DateTime) {\n return date.hasSame(comparing, \"year\");\n};\n\nexport function isSameHour(date: DateTime, comparing: DateTime) {\n return date.hasSame(comparing, \"hour\");\n};\n\nexport function isAfter(value: DateTime, comparing: DateTime) {\n return value > comparing;\n};\n\nexport function isBefore(value: DateTime, comparing: DateTime) {\n return value < comparing;\n};\n\nexport function isBeforeDay(value: DateTime, comparing: DateTime) {\n const diff = value.diff(comparing.startOf(\"day\"), \"days\").toObject();\n return diff.days! < 0;\n};\n\nexport function isAfterDay(value: DateTime, comparing: DateTime) {\n const diff = value.diff(comparing.endOf(\"day\"), \"days\").toObject();\n return diff.days! > 0;\n};\n\nexport function isBeforeMonth(value: DateTime, comparing: DateTime) {\n const diff = value.diff(comparing.startOf(\"month\"), \"months\").toObject();\n return diff.months! < 0;\n};\n\nexport function isAfterMonth(value: DateTime, comparing: DateTime) {\n const diff = value.diff(comparing.startOf(\"month\"), \"months\").toObject();\n return diff.months! > 0;\n};\n\nexport function isBeforeYear(value: DateTime, comparing: DateTime) {\n const diff = value.diff(comparing.startOf(\"year\"), \"years\").toObject();\n return diff.years! < 0;\n};\n\nexport function isAfterYear(value: DateTime, comparing: DateTime) {\n const diff = value.diff(comparing.endOf(\"year\"), \"years\").toObject();\n return diff.years! > 0;\n};\n\nexport function getDiff(value: DateTime, comparing: DateTime | string, unit?: TimeUnit) {\n if (typeof comparing === \"string\") {\n comparing = DateTime.fromJSDate(new Date(comparing));\n }\n\n if (!comparing.isValid) {\n return 0;\n }\n\n if (unit) {\n return Math.floor(value.diff(comparing).as(unit));\n }\n\n return value.diff(comparing).as(\"millisecond\");\n};\n\nexport function startOfDay(value: DateTime) {\n return value.startOf(\"day\");\n};\n\nexport function endOfDay(value: DateTime) {\n return value.endOf(\"day\");\n};\n\nexport function format(date: DateTime, formatKey: keyof DateFormats) {\n return formatByString(date, formats[formatKey]);\n};\n\nexport function formatByString(date: DateTime, format: string) {\n return date.setLocale(locale).toFormat(format);\n};\n\nexport function formatNumber(numberToFormat: string) {\n return numberToFormat;\n};\n\nexport function getHours(value: DateTime) {\n return value.get(\"hour\");\n};\n\nexport function setHours(value: DateTime, count: number) {\n return value.set({ hour: count });\n};\n\nexport function getMinutes(value: DateTime) {\n return value.get(\"minute\");\n};\n\nexport function setMinutes(value: DateTime, count: number) {\n return value.set({ minute: count });\n};\n\nexport function getSeconds(value: DateTime) {\n return value.get(\"second\");\n};\n\nexport function setSeconds(value: DateTime, count: number) {\n return value.set({ second: count });\n};\n\nexport function getWeek(value: DateTime) {\n return value.get(\"weekNumber\");\n};\n\nexport function getMonth(value: DateTime) {\n // See https://github.com/moment/luxon/blob/master/docs/moment.md#major-functional-differences\n return value.get(\"month\") - 1;\n};\n\nexport function getDaysInMonth(value: DateTime) {\n return value.daysInMonth;\n};\n\nexport function setMonth(value: DateTime, count: number) {\n return value.set({ month: count + 1 });\n};\n\nexport function getYear(value: DateTime) {\n return value.get(\"year\");\n};\n\nexport function setYear(value: DateTime, year: number) {\n return value.set({ year });\n};\n\nexport function getDate(value: DateTime) {\n return value.get(\"day\");\n};\n\nexport function setDate(value: DateTime, day: number) {\n return value.set({ day });\n};\n\nexport function mergeDateAndTime(date: DateTime, time: DateTime) {\n return date.set({\n second: time.second,\n hour: time.hour,\n minute: time.minute,\n });\n};\n\nexport function startOfYear(value: DateTime) {\n return value.startOf(\"year\");\n};\n\nexport function endOfYear(value: DateTime) {\n return value.endOf(\"year\");\n};\n\nexport function startOfMonth(value: DateTime) {\n return value.startOf(\"month\");\n};\n\nexport function endOfMonth(value: DateTime) {\n return value.endOf(\"month\");\n};\n\nexport function startOfWeek(value: DateTime) {\n return value.startOf(\"week\");\n};\n\nexport function endOfWeek(value: DateTime) {\n return value.endOf(\"week\");\n};\n\nexport function getNextMonth(value: DateTime) {\n return value.plus({ months: 1 });\n};\n\nexport function getPreviousMonth(value: DateTime) {\n return value.minus({ months: 1 });\n};\n\nexport function getMonthArray(date: DateTime) {\n const firstMonth = date.startOf(\"year\");\n const monthArray = [firstMonth];\n\n while (monthArray.length < 12) {\n const prevMonth = monthArray[monthArray.length - 1];\n monthArray.push(this.getNextMonth(prevMonth));\n }\n\n return monthArray;\n};\n\nexport function getWeekdays() {\n return Info.weekdaysFormat(\"short\", { locale });\n};\n\nexport function getWeekArray(date: DateTime) {\n const { days } = date\n .endOf(\"month\")\n .endOf(\"week\")\n .diff(date.startOf(\"month\").startOf(\"week\"), \"days\")\n .toObject();\n\n const weeks: DateTime[][] = [];\n new Array<number>(Math.round(days!))\n .fill(0)\n .map((_, i) => i)\n .map((day) => date.startOf(\"month\").startOf(\"week\").plus({ days: day }))\n .forEach((v, i) => {\n if (i === 0 || (i % 7 === 0 && i > 6)) {\n weeks.push([v]);\n return;\n }\n\n weeks[weeks.length - 1].push(v);\n });\n\n return weeks;\n};\n\nexport function getYearRange(start: DateTime, end: DateTime) {\n const startDate = start.startOf(\"year\");\n const endDate = end.endOf(\"year\");\n\n let current = startDate;\n const years: DateTime[] = [];\n\n while (current < endDate) {\n years.push(current);\n current = current.plus({ year: 1 });\n }\n\n return years;\n};\n\nexport function getMeridiemText(meridiem: \"am\" | \"pm\") {\n return Info.meridiems({ locale }).find(\n (v) => v.toLowerCase() === meridiem.toLowerCase()\n )!;\n};\n\nexport function isNull(date: DateTime | null) {\n return date === null;\n};\n\nexport function isWithinRange(date: DateTime, [start, end]: [DateTime, DateTime]) {\n return (\n date.equals(start) ||\n date.equals(end) ||\n (isAfter(date, start) && isBefore(date, end))\n );\n};\n\n\n`;\n}\n"],"mappings":";;;;;;;;;AA2BA,SAAgB,YAAY,SAA4B;AACtD,QAAO;;;;aAII,QAAQ,OAAO,UAAU;;;EAGpC,cAAc,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA0CrB,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,gBAAgB,SACzD,GAAG,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,gBAAgB,WAChE,QACL"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"moment.d.cts","names":[],"sources":["../../../src/components/moment.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,YAAA,CAAa,OAAA,EAAS,iBAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"moment.d.mts","names":[],"sources":["../../../src/components/moment.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,YAAA,CAAa,OAAA,EAAS,iBAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"moment.mjs","names":[],"sources":["../../../src/components/moment.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getFileHeader } from \"powerlines/lib/utilities/file-header\";\nimport { DatePluginContext } from \"../types/plugin\";\n\n/**\n * Generates the Powerlines configuration file.\n *\n * @param context - The build context containing runtime information.\n * @returns A string representing the configuration file content.\n */\nexport function momentModule(context: DatePluginContext) {\n return `\n/**\n * The Date module provides utility functions for date manipulation and formatting\n *\n * @module ${context.config.framework}:date\n */\n\n${getFileHeader(context)}\n\nimport defaultMoment, { LongDateFormatKey } from \"moment\";\nimport {\n StormDateInterface,\n DateFormats,\n TimeUnit\n} from \"@powerlines/plugin-date/types/runtime\";\n\ntype Moment = defaultMoment.Moment;\n\nexport const formats: DateFormats = {\n normalDateWithWeekday: \"ddd, MMM D\",\n normalDate: \"D MMMM\",\n shortDate: \"MMM D\",\n monthAndDate: \"MMMM D\",\n dayOfMonth: \"D\",\n year: \"YYYY\",\n month: \"MMMM\",\n monthShort: \"MMM\",\n monthAndYear: \"MMMM YYYY\",\n weekday: \"dddd\",\n weekdayShort: \"ddd\",\n minutes: \"mm\",\n hours12h: \"hh\",\n hours24h: \"HH\",\n seconds: \"ss\",\n fullTime: \"LT\",\n fullTime12h: \"hh:mm A\",\n fullTime24h: \"HH:mm\",\n fullDate: \"ll\",\n fullDateWithWeekday: \"dddd, LL\",\n fullDateTime: \"lll\",\n fullDateTime12h: \"ll hh:mm A\",\n fullDateTime24h: \"ll HH:mm\",\n keyboardDate: \"L\",\n keyboardDateTime: \"L LT\",\n keyboardDateTime12h: \"L hh:mm A\",\n keyboardDateTime24h: \"L HH:mm\",\n systemDateTime: \"L HH:mm:ss.SSS\",\n filePathDateTime: \"L_HH-mm-ss-SSS\"\n};\n\nexport let locale = \"${\n context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale\n ? `${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale}`\n : \"en-US\"\n }\";\n\nexport const type = \"moment\";\n\nconst moment = defaultMoment;\n\n/**\n * Creates a date object using the provided value.\n *\n * @remarks\n * 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.\n *\n * @example\n * \\`\\`\\`ts\n * import { createDate } from \"storm:date\";\n *\n * const date = createDate(\"2023-10-01\");\n * console.log(date.format(\"YYYY-MM-DD\")); // Outputs: 2023-10-01\n * \\`\\`\\`\n *\n * @param value - The value to create the date object from.\n * @returns A date object or \\`null\\` if the value is \\`null\\`.\n */\nexport function createDate<\n TArg extends unknown = undefined,\n TResultingDate extends unknown = TArg extends null\n ? null\n : TArg extends undefined\n ? defaultMoment.Moment\n : defaultMoment.Moment | null\n>(value?: TArg): TResultingDate {\n if (value === null) {\n return null as TResultingDate;\n }\n\n const _moment = moment(value);\n if (locale) {\n _moment.locale(locale);\n }\n\n return _moment as TResultingDate;\n}\n\n\nexport function is12HourCycleInCurrentLocale(): boolean {\n return /A|a/.test(\n moment.localeData(getCurrentLocaleCode()).longDateFormat(\"LT\")\n );\n};\n\nexport function getFormatHelperText(format: string) {\n // @see https://github.com/moment/moment/blob/develop/src/lib/format/format.js#L6\n const localFormattingTokens = /(\\[[^\\[]*\\])|(\\\\)?(LTS|LT|LL?L?L?|l{1,4})|./g;\n\n return (\n format\n .match(localFormattingTokens)\n ?.map((token) => {\n const firstCharacter = token[0];\n if (firstCharacter === \"L\" || firstCharacter === \";\") {\n return moment\n .localeData(getCurrentLocaleCode())\n .longDateFormat(token as LongDateFormatKey);\n }\n\n return token;\n })\n .join(\"\")\n .replace(/a/gi, \"(a|p)m\")\n .toLocaleLowerCase() ?? format\n );\n};\n\nexport function getCurrentLocaleCode() {\n return locale || moment.locale();\n};\n\nexport function parseISO(isoString: string) {\n return moment(isoString, true);\n};\n\nexport function toISO(value: Moment) {\n return value.toISOString();\n};\n\nexport function parse(value: string, format: string) {\n if (value === \"\") {\n return null;\n }\n\n if (locale) {\n return moment(value, format, locale, true);\n }\n\n return moment(value, format, true);\n};\n\nexport function toJsDate(value: Moment) {\n return value.toDate();\n};\n\nexport function isValid(value: any) {\n return moment(value).isValid();\n};\n\nexport function isNull(date: Moment) {\n return date === null;\n};\n\nexport function getDiff(date: Moment, comparing: Moment | string, unit?: TimeUnit) {\n if (!moment(comparing).isValid()) {\n return 0;\n }\n\n return date.diff(comparing, unit);\n};\n\nexport function isAfter(date: Moment, value: Moment) {\n return date.isAfter(value);\n};\n\nexport function isBefore(date: Moment, value: Moment) {\n return date.isBefore(value);\n};\n\nexport function isAfterDay(date: Moment, value: Moment) {\n return date.isAfter(value, \"day\");\n};\n\nexport function isBeforeDay(date: Moment, value: Moment) {\n return date.isBefore(value, \"day\");\n};\n\nexport function isBeforeMonth(date: Moment, value: Moment) {\n return date.isBefore(value, \"month\");\n};\n\nexport function isAfterMonth(date: Moment, value: Moment) {\n return date.isAfter(value, \"month\");\n};\n\nexport function isBeforeYear(date: Moment, value: Moment) {\n return date.isBefore(value, \"year\");\n};\n\nexport function isAfterYear(date: Moment, value: Moment) {\n return date.isAfter(value, \"year\");\n};\n\nexport function startOfDay(date: Moment) {\n return date.clone().startOf(\"day\");\n};\n\nexport function endOfDay(date: Moment) {\n return date.clone().endOf(\"day\");\n};\n\nexport function format(date: Moment, formatKey: keyof DateFormats) {\n return formatByString(date, formats[formatKey]);\n};\n\nexport function formatByString(date: Moment, formatString: string) {\n const clonedDate = date.clone();\n if (locale) {\n clonedDate.locale(locale);\n }\n return clonedDate.format(formatString);\n};\n\nexport function formatNumber(numberToFormat: string) {\n return numberToFormat;\n};\n\nexport function getHours(date: Moment) {\n return date.get(\"hours\");\n};\n\nexport function addSeconds(date: Moment, count: number) {\n return count < 0\n ? date.clone().subtract(Math.abs(count), \"seconds\")\n : date.clone().add(count, \"seconds\");\n};\n\nexport function addMinutes(date: Moment, count: number) {\n return count < 0\n ? date.clone().subtract(Math.abs(count), \"minutes\")\n : date.clone().add(count, \"minutes\");\n};\n\nexport function addHours(date: Moment, count: number) {\n return count < 0\n ? date.clone().subtract(Math.abs(count), \"hours\")\n : date.clone().add(count, \"hours\");\n};\n\nexport function addDays(date: Moment, count: number) {\n return count < 0\n ? date.clone().subtract(Math.abs(count), \"days\")\n : date.clone().add(count, \"days\");\n};\n\nexport function addWeeks(date: Moment, count: number) {\n return count < 0\n ? date.clone().subtract(Math.abs(count), \"weeks\")\n : date.clone().add(count, \"weeks\");\n};\n\nexport function addMonths(date: Moment, count: number) {\n return count < 0\n ? date.clone().subtract(Math.abs(count), \"months\")\n : date.clone().add(count, \"months\");\n};\n\nexport function addYears(date: Moment, count: number) {\n return count < 0\n ? date.clone().subtract(Math.abs(count), \"years\")\n : date.clone().add(count, \"years\");\n};\n\nexport function setHours(date: Moment, count: number) {\n return date.clone().hours(count);\n};\n\nexport function getMinutes(date: Moment) {\n return date.get(\"minutes\");\n};\n\nexport function setMinutes(date: Moment, count: number) {\n return date.clone().minutes(count);\n};\n\nexport function getSeconds(date: Moment) {\n return date.get(\"seconds\");\n};\n\nexport function setSeconds(date: Moment, count: number) {\n return date.clone().seconds(count);\n};\n\nexport function getWeek(date: Moment) {\n return date.get(\"week\");\n};\n\nexport function getMonth(date: Moment) {\n return date.get(\"month\");\n};\n\nexport function getDaysInMonth(date: Moment) {\n return date.daysInMonth();\n};\n\nexport function isSameDay(date: Moment, comparing: Moment) {\n return date.isSame(comparing, \"day\");\n};\n\nexport function isSameMonth(date: Moment, comparing: Moment) {\n return date.isSame(comparing, \"month\");\n};\n\nexport function isSameYear(date: Moment, comparing: Moment) {\n return date.isSame(comparing, \"year\");\n};\n\nexport function isSameHour(date: Moment, comparing: Moment) {\n return date.isSame(comparing, \"hour\");\n};\n\nexport function setMonth(date: Moment, count: number) {\n return date.clone().month(count);\n};\n\nexport function getMeridiemText(meridiem: \"am\" | \"pm\") {\n if (is12HourCycleInCurrentLocale()) {\n // AM/PM translation only possible in those who have 12 hour cycle in locale.\n return moment\n .localeData(getCurrentLocaleCode())\n .meridiem(meridiem === \"am\" ? 0 : 13, 0, false);\n }\n\n return meridiem === \"am\" ? \"AM\" : \"PM\"; // fallback for de, ru, ...etc\n};\n\nexport function startOfYear(date: Moment) {\n return date.clone().startOf(\"year\");\n};\n\nexport function endOfYear(date: Moment) {\n return date.clone().endOf(\"year\");\n};\n\nexport function startOfMonth(date: Moment) {\n return date.clone().startOf(\"month\");\n};\n\nexport function endOfMonth(date: Moment) {\n return date.clone().endOf(\"month\");\n};\n\nexport function startOfWeek(date: Moment) {\n return date.clone().startOf(\"week\");\n};\n\nexport function endOfWeek(date: Moment) {\n return date.clone().endOf(\"week\");\n};\n\nexport function getNextMonth(date: Moment) {\n return date.clone().add(1, \"month\");\n};\n\nexport function getPreviousMonth(date: Moment) {\n return date.clone().subtract(1, \"month\");\n};\n\nexport function getMonthArray(date: Moment) {\n const firstMonth = date.clone().startOf(\"year\");\n const monthArray = [firstMonth];\n\n while (monthArray.length < 12) {\n const prevMonth = monthArray[monthArray.length - 1];\n monthArray.push(getNextMonth(prevMonth));\n }\n\n return monthArray;\n};\n\nexport function getYear(date: Moment) {\n return date.get(\"year\");\n};\n\nexport function setYear(date: Moment, year: number) {\n return date.clone().set(\"year\", year);\n};\n\nexport function getDate(date: Moment) {\n return date.get(\"date\");\n};\n\nexport function setDate(date: Moment, day: number) {\n return date.clone().set(\"date\", day);\n};\n\nexport function mergeDateAndTime(date: Moment, time: Moment) {\n return date.hour(time.hour()).minute(time.minute()).second(time.second());\n};\n\nexport function getWeekdays() {\n return moment.weekdaysShort(true);\n};\n\nexport function isEqual(value: any, comparing: any) {\n if (value === null && comparing === null) {\n return true;\n }\n\n return moment(value).isSame(comparing);\n};\n\nexport function getWeekArray(date: Moment) {\n const start = date.clone().startOf(\"month\").startOf(\"week\");\n const end = date.clone().endOf(\"month\").endOf(\"week\");\n\n let count = 0;\n let current = start;\n const nestedWeeks: Moment[][] = [];\n\n while (current.isBefore(end)) {\n const weekNumber = Math.floor(count / 7);\n nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];\n nestedWeeks[weekNumber].push(current);\n\n current = current.clone().add(1, \"day\");\n count += 1;\n }\n\n return nestedWeeks;\n};\n\nexport function getYearRange(start: Moment, end: Moment) {\n const startDate = moment(start).startOf(\"year\");\n const endDate = moment(end).endOf(\"year\");\n const years: Moment[] = [];\n\n let current = startDate;\n while (current.isBefore(endDate)) {\n years.push(current);\n current = current.clone().add(1, \"year\");\n }\n\n return years;\n};\n\nexport function isWithinRange(date: Moment, [start, end]: [Moment, Moment]) {\n return date.isBetween(start, end, null, \"[]\");\n};\n\n\n`;\n}\n"],"mappings":";;;;;;;;;AA2BA,SAAgB,aAAa,SAA4B;AACvD,QAAO;;;;aAII,QAAQ,OAAO,UAAU;;;EAGpC,cAAc,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA4CrB,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,gBAAgB,SACzD,GAAG,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,gBAAgB,WAChE,QACL"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes