@powerlines/plugin-date 0.12.475 → 0.12.477

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.
@@ -61,7 +61,7 @@ import { isSameYear as dateFnsIsSameYear } from "date-fns/isSameYear";
61
61
  import { isValid as dateFnsIsValid } from "date-fns/isValid";
62
62
  import { isWithinInterval } from "date-fns/isWithinInterval";
63
63
  import { Locale } from "date-fns/locale";
64
- import { ${context.env.parsed.DEFAULT_LOCALE?.replaceAll("-", "") || "enUS"} as defaultLocale } from "date-fns/locale/${context.env.parsed.DEFAULT_LOCALE || "en-US"}";
64
+ import { ${context.config.date.defaultLocale?.replaceAll("-", "") || "enUS"} as defaultLocale } from "date-fns/locale/${context.config.date.defaultLocale || "en-US"}";
65
65
  import { parse as dateFnsParse } from "date-fns/parse";
66
66
  import { parseISO as dateFnsParseISO } from "date-fns/parseISO";
67
67
  import { setDate as dateFnsSetDate } from "date-fns/setDate";
@@ -60,7 +60,7 @@ import { isSameYear as dateFnsIsSameYear } from "date-fns/isSameYear";
60
60
  import { isValid as dateFnsIsValid } from "date-fns/isValid";
61
61
  import { isWithinInterval } from "date-fns/isWithinInterval";
62
62
  import { Locale } from "date-fns/locale";
63
- import { ${context.env.parsed.DEFAULT_LOCALE?.replaceAll("-", "") || "enUS"} as defaultLocale } from "date-fns/locale/${context.env.parsed.DEFAULT_LOCALE || "en-US"}";
63
+ import { ${context.config.date.defaultLocale?.replaceAll("-", "") || "enUS"} as defaultLocale } from "date-fns/locale/${context.config.date.defaultLocale || "en-US"}";
64
64
  import { parse as dateFnsParse } from "date-fns/parse";
65
65
  import { parseISO as dateFnsParseISO } from "date-fns/parseISO";
66
66
  import { setDate as dateFnsSetDate } from "date-fns/setDate";
@@ -1 +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 { getTypescriptFileHeader } from \"powerlines/utils\";\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${getTypescriptFileHeader(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,wBAAwB,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA8C/B,QAAQ,IAAI,OAAO,gBAAgB,WAAW,KAAK,GAAG,IAAI,OAC3D,4CACC,QAAQ,IAAI,OAAO,kBAAkB,QACtC"}
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 { getTypescriptFileHeader } from \"powerlines/utils\";\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${getTypescriptFileHeader(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.config.date.defaultLocale?.replaceAll(\"-\", \"\") || \"enUS\"\n } as defaultLocale } from \"date-fns/locale/${\n context.config.date.defaultLocale || \"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,wBAAwB,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA8C/B,QAAQ,OAAO,KAAK,eAAe,WAAW,KAAK,GAAG,IAAI,OAC3D,4CACC,QAAQ,OAAO,KAAK,iBAAiB,QACtC"}
@@ -24,10 +24,11 @@ import localizedFormatPlugin from "dayjs/plugin/localizedFormat";
24
24
  import isBetweenPlugin from "dayjs/plugin/isBetween";
25
25
  import weekOfYear from "dayjs/plugin/weekOfYear";
26
26
  import {
27
- StormDateInterface,
27
+ PowerlinesDateInterface,
28
28
  DateFormats,
29
29
  TimeUnit
30
30
  } from "@powerlines/plugin-date/types/runtime";
31
+ import { env } from "${context.config.framework}:env";
31
32
 
32
33
  defaultDayjs.extend(customParseFormatPlugin);
33
34
  defaultDayjs.extend(localizedFormatPlugin);
@@ -82,7 +83,7 @@ export const formats: DateFormats = {
82
83
  filePathDateTime: "L_HH-mm-ss-SSS"
83
84
  };
84
85
 
85
- export let locale = "${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale ? `${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale}` : "en-US"}";
86
+ export let locale = env.LOCALE || "${context.config.date.defaultLocale}";
86
87
 
87
88
  export const dayjs = withLocale(defaultDayjs, locale);
88
89
 
@@ -122,11 +123,11 @@ export function createDate<
122
123
 
123
124
  export function is12HourCycleInCurrentLocale() {
124
125
  /* istanbul ignore next */
125
- return /A|a/.test(dayjs.Ls[dayjs.locale() || $storm.env.DEFAULT_LOCALE]?.formats?.LT ?? "");
126
+ return /A|a/.test(dayjs.Ls[dayjs.locale() || locale]?.formats?.LT ?? "");
126
127
  };
127
128
 
128
129
  export function getCurrentLocaleCode() {
129
- return dayjs.locale() || $storm.env.DEFAULT_LOCALE;
130
+ return dayjs.locale() || locale;
130
131
  };
131
132
 
132
133
  export function getFormatHelperText(format: string) {
@@ -141,7 +142,7 @@ export function getFormatHelperText(format: string) {
141
142
  if (firstCharacter === "L") {
142
143
  /* istanbul ignore next */
143
144
  return (
144
- dayjs.Ls[dayjs.locale() || $storm.env.DEFAULT_LOCALE]?.formats[
145
+ dayjs.Ls[dayjs.locale() || locale]?.formats[
145
146
  token as keyof ILocale["formats"]
146
147
  ] ?? token
147
148
  );
@@ -23,10 +23,11 @@ import localizedFormatPlugin from "dayjs/plugin/localizedFormat";
23
23
  import isBetweenPlugin from "dayjs/plugin/isBetween";
24
24
  import weekOfYear from "dayjs/plugin/weekOfYear";
25
25
  import {
26
- StormDateInterface,
26
+ PowerlinesDateInterface,
27
27
  DateFormats,
28
28
  TimeUnit
29
29
  } from "@powerlines/plugin-date/types/runtime";
30
+ import { env } from "${context.config.framework}:env";
30
31
 
31
32
  defaultDayjs.extend(customParseFormatPlugin);
32
33
  defaultDayjs.extend(localizedFormatPlugin);
@@ -81,7 +82,7 @@ export const formats: DateFormats = {
81
82
  filePathDateTime: "L_HH-mm-ss-SSS"
82
83
  };
83
84
 
84
- export let locale = "${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale ? `${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale}` : "en-US"}";
85
+ export let locale = env.LOCALE || "${context.config.date.defaultLocale}";
85
86
 
86
87
  export const dayjs = withLocale(defaultDayjs, locale);
87
88
 
@@ -121,11 +122,11 @@ export function createDate<
121
122
 
122
123
  export function is12HourCycleInCurrentLocale() {
123
124
  /* istanbul ignore next */
124
- return /A|a/.test(dayjs.Ls[dayjs.locale() || $storm.env.DEFAULT_LOCALE]?.formats?.LT ?? "");
125
+ return /A|a/.test(dayjs.Ls[dayjs.locale() || locale]?.formats?.LT ?? "");
125
126
  };
126
127
 
127
128
  export function getCurrentLocaleCode() {
128
- return dayjs.locale() || $storm.env.DEFAULT_LOCALE;
129
+ return dayjs.locale() || locale;
129
130
  };
130
131
 
131
132
  export function getFormatHelperText(format: string) {
@@ -140,7 +141,7 @@ export function getFormatHelperText(format: string) {
140
141
  if (firstCharacter === "L") {
141
142
  /* istanbul ignore next */
142
143
  return (
143
- dayjs.Ls[dayjs.locale() || $storm.env.DEFAULT_LOCALE]?.formats[
144
+ dayjs.Ls[dayjs.locale() || locale]?.formats[
144
145
  token as keyof ILocale["formats"]
145
146
  ] ?? token
146
147
  );
@@ -1 +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 { getTypescriptFileHeader } from \"powerlines/utils\";\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${getTypescriptFileHeader(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,wBAAwB,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAmE/B,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,gBAAgB,SACzD,GAAG,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,gBAAgB,WAChE,QACL"}
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 { getTypescriptFileHeader } from \"powerlines/utils\";\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${getTypescriptFileHeader(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 PowerlinesDateInterface,\n DateFormats,\n TimeUnit\n} from \"@powerlines/plugin-date/types/runtime\";\nimport { env } from \"${context.config.framework}:env\";\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 = env.LOCALE || \"${context.config.date.defaultLocale}\";\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() || locale]?.formats?.LT ?? \"\");\n};\n\nexport function getCurrentLocaleCode() {\n return dayjs.locale() || 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() || 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,wBAAwB,QAAQ,CAAC;;;;;;;;;;;;uBAYZ,QAAQ,OAAO,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCAuDX,QAAQ,OAAO,KAAK,cAAc"}
@@ -20,10 +20,11 @@ ${(0, powerlines_utils.getTypescriptFileHeader)(context)}
20
20
 
21
21
  import { DateTime, Settings, Info } from "luxon";
22
22
  import {
23
- StormDateInterface,
23
+ PowerlinesDateInterface,
24
24
  DateFormats,
25
25
  TimeUnit
26
26
  } from "@powerlines/plugin-date/types/runtime";
27
+ import { env } from "${context.config.framework}:env";
27
28
 
28
29
  export const formats: DateFormats = {
29
30
  dayOfMonth: "d",
@@ -57,7 +58,7 @@ export const formats: DateFormats = {
57
58
  year: "yyyy",
58
59
  };
59
60
 
60
- export let locale = "${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale ? `${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale}` : "en-US"}";
61
+ export let locale = env.LOCALE || "${context.config.date.defaultLocale}";
61
62
 
62
63
  export const type = "luxon";
63
64
 
@@ -19,10 +19,11 @@ ${getTypescriptFileHeader(context)}
19
19
 
20
20
  import { DateTime, Settings, Info } from "luxon";
21
21
  import {
22
- StormDateInterface,
22
+ PowerlinesDateInterface,
23
23
  DateFormats,
24
24
  TimeUnit
25
25
  } from "@powerlines/plugin-date/types/runtime";
26
+ import { env } from "${context.config.framework}:env";
26
27
 
27
28
  export const formats: DateFormats = {
28
29
  dayOfMonth: "d",
@@ -56,7 +57,7 @@ export const formats: DateFormats = {
56
57
  year: "yyyy",
57
58
  };
58
59
 
59
- export let locale = "${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale ? `${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale}` : "en-US"}";
60
+ export let locale = env.LOCALE || "${context.config.date.defaultLocale}";
60
61
 
61
62
  export const type = "luxon";
62
63
 
@@ -1 +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 { getTypescriptFileHeader } from \"powerlines/utils\";\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${getTypescriptFileHeader(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,wBAAwB,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA0C/B,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,gBAAgB,SACzD,GAAG,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,gBAAgB,WAChE,QACL"}
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 { getTypescriptFileHeader } from \"powerlines/utils\";\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${getTypescriptFileHeader(context)}\n\nimport { DateTime, Settings, Info } from \"luxon\";\nimport {\n PowerlinesDateInterface,\n DateFormats,\n TimeUnit\n} from \"@powerlines/plugin-date/types/runtime\";\nimport { env } from \"${context.config.framework}:env\";\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 = env.LOCALE || \"${context.config.date.defaultLocale}\";\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,wBAAwB,QAAQ,CAAC;;;;;;;;uBAQZ,QAAQ,OAAO,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCAkCX,QAAQ,OAAO,KAAK,cAAc"}
@@ -20,10 +20,11 @@ ${(0, powerlines_utils.getTypescriptFileHeader)(context)}
20
20
 
21
21
  import defaultMoment, { LongDateFormatKey } from "moment";
22
22
  import {
23
- StormDateInterface,
23
+ PowerlinesDateInterface,
24
24
  DateFormats,
25
25
  TimeUnit
26
26
  } from "@powerlines/plugin-date/types/runtime";
27
+ import { env } from "${context.config.framework}:env";
27
28
 
28
29
  type Moment = defaultMoment.Moment;
29
30
 
@@ -59,7 +60,7 @@ export const formats: DateFormats = {
59
60
  filePathDateTime: "L_HH-mm-ss-SSS"
60
61
  };
61
62
 
62
- export let locale = "${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale ? `${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale}` : "en-US"}";
63
+ export let locale = env.LOCALE || "${context.config.date.defaultLocale}";
63
64
 
64
65
  export const type = "moment";
65
66
 
@@ -19,10 +19,11 @@ ${getTypescriptFileHeader(context)}
19
19
 
20
20
  import defaultMoment, { LongDateFormatKey } from "moment";
21
21
  import {
22
- StormDateInterface,
22
+ PowerlinesDateInterface,
23
23
  DateFormats,
24
24
  TimeUnit
25
25
  } from "@powerlines/plugin-date/types/runtime";
26
+ import { env } from "${context.config.framework}:env";
26
27
 
27
28
  type Moment = defaultMoment.Moment;
28
29
 
@@ -58,7 +59,7 @@ export const formats: DateFormats = {
58
59
  filePathDateTime: "L_HH-mm-ss-SSS"
59
60
  };
60
61
 
61
- export let locale = "${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale ? `${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale}` : "en-US"}";
62
+ export let locale = env.LOCALE || "${context.config.date.defaultLocale}";
62
63
 
63
64
  export const type = "moment";
64
65
 
@@ -1 +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 { getTypescriptFileHeader } from \"powerlines/utils\";\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${getTypescriptFileHeader(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,wBAAwB,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA4C/B,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,gBAAgB,SACzD,GAAG,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,gBAAgB,WAChE,QACL"}
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 { getTypescriptFileHeader } from \"powerlines/utils\";\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${getTypescriptFileHeader(context)}\n\nimport defaultMoment, { LongDateFormatKey } from \"moment\";\nimport {\n PowerlinesDateInterface,\n DateFormats,\n TimeUnit\n} from \"@powerlines/plugin-date/types/runtime\";\nimport { env } from \"${context.config.framework}:env\";\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 = env.LOCALE || \"${context.config.date.defaultLocale}\";\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,wBAAwB,QAAQ,CAAC;;;;;;;;uBAQZ,QAAQ,OAAO,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCAoCX,QAAQ,OAAO,KAAK,cAAc"}
package/dist/index.cjs CHANGED
@@ -7,8 +7,6 @@ const require_moment = require('./components/moment.cjs');
7
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, 1);
10
- let defu = require("defu");
11
- defu = require_runtime.__toESM(defu, 1);
12
10
 
13
11
  //#region src/index.ts
14
12
  /**
@@ -19,22 +17,24 @@ function plugin(options = {}) {
19
17
  name: "date",
20
18
  async config() {
21
19
  this.debug("Providing default configuration for the Powerlines `date` build plugin.");
22
- const config = { date: (0, defu.default)(options, { type: "date-fns" }) };
23
- if (!config.date.type || ![
20
+ const config = { date: options };
21
+ if (!options.type || ![
24
22
  "date-fns",
25
23
  "dayjs",
26
24
  "luxon",
27
25
  "moment"
28
- ].includes(config.date.type)) {
29
- if (config.date.type) this.warn(`Invalid date library type "${config.date.type}" specified. Defaulting to "date-fns".`);
26
+ ].includes(options.type)) {
27
+ if (options.type) this.warn(`Invalid date library type "${options.type}" specified. Defaulting to "date-fns".`);
30
28
  config.date.type = "date-fns";
31
29
  }
30
+ if (!options.defaultLocale) config.date.defaultLocale = "en-US";
32
31
  this.debug(`Using date library: ${config.date.type}`);
33
32
  return config;
34
33
  },
35
34
  async configResolved() {
36
35
  this.debug(`Environment plugin configuration has been resolved for the Powerlines project.`);
37
36
  this.dependencies[this.config.date.type] = "latest";
37
+ if (!options.defaultLocale && this.env.parsed.DEFAULT_LOCALE) this.config.date.defaultLocale = this.env.parsed.DEFAULT_LOCALE;
38
38
  },
39
39
  async prepare() {
40
40
  this.debug(`Preparing the Date runtime artifacts for the Powerlines project.`);
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@ import { dateFnsModule } from "./components/date-fns.cjs";
3
3
  import { dayjsModule } from "./components/dayjs.cjs";
4
4
  import { luxonModule } from "./components/luxon.cjs";
5
5
  import { momentModule } from "./components/moment.cjs";
6
- import { DateFormats, StormDateInterface, TimeUnit, __ΩDateFormats, __ΩStormDateInterface, __ΩTimeUnit } from "./types/runtime.cjs";
6
+ import { DateEnvInterface, DateFormats, PowerlinesDateInterface, TimeUnit, __ΩDateEnvInterface, __ΩDateFormats, __ΩPowerlinesDateInterface, __ΩTimeUnit } from "./types/runtime.cjs";
7
7
  import { Plugin } from "powerlines";
8
8
 
9
9
  //#region src/index.d.ts
@@ -17,5 +17,5 @@ declare module "powerlines" {
17
17
  */
18
18
  declare function plugin<TContext extends DatePluginContext = DatePluginContext>(options?: DatePluginOptions): Plugin<TContext>[];
19
19
  //#endregion
20
- export { DateFormats, DateLibraryType, DatePluginContext, DatePluginOptions, DatePluginResolvedConfig, DatePluginUserConfig, StormDateInterface, TimeUnit, __ΩDateFormats, __ΩDateLibraryType, __ΩDatePluginContext, __ΩDatePluginOptions, __ΩDatePluginResolvedConfig, __ΩDatePluginUserConfig, __ΩStormDateInterface, __ΩTimeUnit, dateFnsModule, dayjsModule, plugin as default, plugin, luxonModule, momentModule };
20
+ export { DateEnvInterface, DateFormats, DateLibraryType, DatePluginContext, DatePluginOptions, DatePluginResolvedConfig, DatePluginUserConfig, PowerlinesDateInterface, TimeUnit, __ΩDateEnvInterface, __ΩDateFormats, __ΩDateLibraryType, __ΩDatePluginContext, __ΩDatePluginOptions, __ΩDatePluginResolvedConfig, __ΩDatePluginUserConfig, __ΩPowerlinesDateInterface, __ΩTimeUnit, dateFnsModule, dayjsModule, plugin as default, plugin, luxonModule, momentModule };
21
21
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;YAmCY,MAAA;IACR,IAAA,GAAO,iBAAA;EAAA;AAAA;;;AAJa;iBAWR,MAAA,kBAAwB,iBAAA,GAAoB,iBAAA,CAAA,CAC1D,OAAA,GAAS,iBAAA,GAmEJ,MAAA,CAAO,QAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;YAkCY,MAAA;IACR,IAAA,GAAO,iBAAA;EAAA;AAAA;;;AAJa;iBAWR,MAAA,kBAAwB,iBAAA,GAAoB,iBAAA,CAAA,CAC1D,OAAA,GAAS,iBAAA,GAyEJ,MAAA,CAAO,QAAA"}
package/dist/index.d.mts CHANGED
@@ -3,7 +3,7 @@ import { dateFnsModule } from "./components/date-fns.mjs";
3
3
  import { dayjsModule } from "./components/dayjs.mjs";
4
4
  import { luxonModule } from "./components/luxon.mjs";
5
5
  import { momentModule } from "./components/moment.mjs";
6
- import { DateFormats, StormDateInterface, TimeUnit, __ΩDateFormats, __ΩStormDateInterface, __ΩTimeUnit } from "./types/runtime.mjs";
6
+ import { DateEnvInterface, DateFormats, PowerlinesDateInterface, TimeUnit, __ΩDateEnvInterface, __ΩDateFormats, __ΩPowerlinesDateInterface, __ΩTimeUnit } from "./types/runtime.mjs";
7
7
  import { Plugin } from "powerlines";
8
8
 
9
9
  //#region src/index.d.ts
@@ -17,5 +17,5 @@ declare module "powerlines" {
17
17
  */
18
18
  declare function plugin<TContext extends DatePluginContext = DatePluginContext>(options?: DatePluginOptions): Plugin<TContext>[];
19
19
  //#endregion
20
- export { DateFormats, DateLibraryType, DatePluginContext, DatePluginOptions, DatePluginResolvedConfig, DatePluginUserConfig, StormDateInterface, TimeUnit, __ΩDateFormats, __ΩDateLibraryType, __ΩDatePluginContext, __ΩDatePluginOptions, __ΩDatePluginResolvedConfig, __ΩDatePluginUserConfig, __ΩStormDateInterface, __ΩTimeUnit, dateFnsModule, dayjsModule, plugin as default, plugin, luxonModule, momentModule };
20
+ export { DateEnvInterface, DateFormats, DateLibraryType, DatePluginContext, DatePluginOptions, DatePluginResolvedConfig, DatePluginUserConfig, PowerlinesDateInterface, TimeUnit, __ΩDateEnvInterface, __ΩDateFormats, __ΩDateLibraryType, __ΩDatePluginContext, __ΩDatePluginOptions, __ΩDatePluginResolvedConfig, __ΩDatePluginUserConfig, __ΩPowerlinesDateInterface, __ΩTimeUnit, dateFnsModule, dayjsModule, plugin as default, plugin, luxonModule, momentModule };
21
21
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;YAmCY,MAAA;IACR,IAAA,GAAO,iBAAA;EAAA;AAAA;;;AAJa;iBAWR,MAAA,kBAAwB,iBAAA,GAAoB,iBAAA,CAAA,CAC1D,OAAA,GAAS,iBAAA,GAmEJ,MAAA,CAAO,QAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;YAkCY,MAAA;IACR,IAAA,GAAO,iBAAA;EAAA;AAAA;;;AAJa;iBAWR,MAAA,kBAAwB,iBAAA,GAAoB,iBAAA,CAAA,CAC1D,OAAA,GAAS,iBAAA,GAyEJ,MAAA,CAAO,QAAA"}
package/dist/index.mjs CHANGED
@@ -4,7 +4,6 @@ import { luxonModule } from "./components/luxon.mjs";
4
4
  import { momentModule } from "./components/moment.mjs";
5
5
  import "./components/index.mjs";
6
6
  import env from "@powerlines/plugin-env";
7
- import defu from "defu";
8
7
 
9
8
  //#region src/index.ts
10
9
  /**
@@ -15,22 +14,24 @@ function plugin(options = {}) {
15
14
  name: "date",
16
15
  async config() {
17
16
  this.debug("Providing default configuration for the Powerlines `date` build plugin.");
18
- const config = { date: defu(options, { type: "date-fns" }) };
19
- if (!config.date.type || ![
17
+ const config = { date: options };
18
+ if (!options.type || ![
20
19
  "date-fns",
21
20
  "dayjs",
22
21
  "luxon",
23
22
  "moment"
24
- ].includes(config.date.type)) {
25
- if (config.date.type) this.warn(`Invalid date library type "${config.date.type}" specified. Defaulting to "date-fns".`);
23
+ ].includes(options.type)) {
24
+ if (options.type) this.warn(`Invalid date library type "${options.type}" specified. Defaulting to "date-fns".`);
26
25
  config.date.type = "date-fns";
27
26
  }
27
+ if (!options.defaultLocale) config.date.defaultLocale = "en-US";
28
28
  this.debug(`Using date library: ${config.date.type}`);
29
29
  return config;
30
30
  },
31
31
  async configResolved() {
32
32
  this.debug(`Environment plugin configuration has been resolved for the Powerlines project.`);
33
33
  this.dependencies[this.config.date.type] = "latest";
34
+ if (!options.defaultLocale && this.env.parsed.DEFAULT_LOCALE) this.config.date.defaultLocale = this.env.parsed.DEFAULT_LOCALE;
34
35
  },
35
36
  async prepare() {
36
37
  this.debug(`Preparing the Date runtime artifacts for the Powerlines project.`);
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.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 env from \"@powerlines/plugin-env\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport { dateFnsModule } from \"./components/date-fns\";\nimport { dayjsModule } from \"./components/dayjs\";\nimport { luxonModule } from \"./components/luxon\";\nimport { momentModule } from \"./components/moment\";\nimport {\n DatePluginContext,\n DatePluginOptions,\n DatePluginUserConfig\n} from \"./types/plugin\";\n\nexport * from \"./components\";\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n date?: DatePluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to assist in developing other Powerlines plugins.\n */\nexport function plugin<TContext extends DatePluginContext = DatePluginContext>(\n options: DatePluginOptions = {}\n) {\n return [\n env(options.env),\n {\n name: \"date\",\n async config() {\n this.debug(\n \"Providing default configuration for the Powerlines `date` build plugin.\"\n );\n\n const config = {\n date: defu(options, {\n type: \"date-fns\"\n })\n } as DatePluginUserConfig;\n\n if (\n !config.date!.type ||\n ![\"date-fns\", \"dayjs\", \"luxon\", \"moment\"].includes(config.date!.type)\n ) {\n if (config.date!.type) {\n this.warn(\n `Invalid date library type \"${config.date!.type}\" specified. Defaulting to \"date-fns\".`\n );\n }\n\n config.date!.type = \"date-fns\";\n }\n\n this.debug(`Using date library: ${config.date!.type}`);\n\n return config;\n },\n async configResolved() {\n this.debug(\n `Environment plugin configuration has been resolved for the Powerlines project.`\n );\n\n this.dependencies[this.config.date.type] = \"latest\";\n },\n async prepare() {\n this.debug(\n `Preparing the Date runtime artifacts for the Powerlines project.`\n );\n\n let dateModule!: (context: DatePluginContext) => string;\n switch (this.config.date.type) {\n case \"dayjs\":\n dateModule = dayjsModule;\n break;\n case \"luxon\":\n dateModule = luxonModule;\n break;\n case \"moment\":\n dateModule = momentModule;\n break;\n case \"date-fns\":\n default:\n // Default to date-fns if no type is specified or if the type is not recognized\n dateModule = dateFnsModule;\n break;\n }\n\n await this.emitBuiltin(await Promise.resolve(dateModule(this)), \"date\");\n }\n }\n ] as Plugin<TContext>[];\n}\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;AA2CA,SAAgB,OACd,UAA6B,EAAE,EAC/B;AACA,QAAO,CACL,IAAI,QAAQ,IAAI,EAChB;EACE,MAAM;EACN,MAAM,SAAS;AACb,QAAK,MACH,0EACD;GAED,MAAM,SAAS,EACb,MAAM,KAAK,SAAS,EAClB,MAAM,YACP,CAAC,EACH;AAED,OACE,CAAC,OAAO,KAAM,QACd,CAAC;IAAC;IAAY;IAAS;IAAS;IAAS,CAAC,SAAS,OAAO,KAAM,KAAK,EACrE;AACA,QAAI,OAAO,KAAM,KACf,MAAK,KACH,8BAA8B,OAAO,KAAM,KAAK,wCACjD;AAGH,WAAO,KAAM,OAAO;;AAGtB,QAAK,MAAM,uBAAuB,OAAO,KAAM,OAAO;AAEtD,UAAO;;EAET,MAAM,iBAAiB;AACrB,QAAK,MACH,iFACD;AAED,QAAK,aAAa,KAAK,OAAO,KAAK,QAAQ;;EAE7C,MAAM,UAAU;AACd,QAAK,MACH,mEACD;GAED,IAAI;AACJ,WAAQ,KAAK,OAAO,KAAK,MAAzB;IACE,KAAK;AACH,kBAAa;AACb;IACF,KAAK;AACH,kBAAa;AACb;IACF,KAAK;AACH,kBAAa;AACb;IAEF;AAEE,kBAAa;AACb;;AAGJ,SAAM,KAAK,YAAY,MAAM,QAAQ,QAAQ,WAAW,KAAK,CAAC,EAAE,OAAO;;EAE1E,CACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.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 env from \"@powerlines/plugin-env\";\nimport { Plugin } from \"powerlines\";\nimport { dateFnsModule } from \"./components/date-fns\";\nimport { dayjsModule } from \"./components/dayjs\";\nimport { luxonModule } from \"./components/luxon\";\nimport { momentModule } from \"./components/moment\";\nimport {\n DatePluginContext,\n DatePluginOptions,\n DatePluginResolvedConfig\n} from \"./types/plugin\";\n\nexport * from \"./components\";\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n date?: DatePluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to assist in developing other Powerlines plugins.\n */\nexport function plugin<TContext extends DatePluginContext = DatePluginContext>(\n options: DatePluginOptions = {}\n) {\n return [\n env(options.env),\n {\n name: \"date\",\n async config() {\n this.debug(\n \"Providing default configuration for the Powerlines `date` build plugin.\"\n );\n\n const config = {\n date: options\n } as DatePluginResolvedConfig;\n\n if (\n !options.type ||\n ![\"date-fns\", \"dayjs\", \"luxon\", \"moment\"].includes(options.type)\n ) {\n if (options.type) {\n this.warn(\n `Invalid date library type \"${options.type}\" specified. Defaulting to \"date-fns\".`\n );\n }\n\n config.date.type = \"date-fns\";\n }\n\n if (!options.defaultLocale) {\n config.date.defaultLocale = \"en-US\";\n }\n\n this.debug(`Using date library: ${config.date.type}`);\n\n return config;\n },\n async configResolved() {\n this.debug(\n `Environment plugin configuration has been resolved for the Powerlines project.`\n );\n\n this.dependencies[this.config.date.type] = \"latest\";\n\n if (!options.defaultLocale && this.env.parsed.DEFAULT_LOCALE) {\n this.config.date.defaultLocale = this.env.parsed.DEFAULT_LOCALE;\n }\n },\n async prepare() {\n this.debug(\n `Preparing the Date runtime artifacts for the Powerlines project.`\n );\n\n let dateModule!: (context: DatePluginContext) => string;\n switch (this.config.date.type) {\n case \"dayjs\":\n dateModule = dayjsModule;\n break;\n case \"luxon\":\n dateModule = luxonModule;\n break;\n case \"moment\":\n dateModule = momentModule;\n break;\n case \"date-fns\":\n default:\n // Default to date-fns if no type is specified or if the type is not recognized\n dateModule = dateFnsModule;\n break;\n }\n\n await this.emitBuiltin(await Promise.resolve(dateModule(this)), \"date\");\n }\n }\n ] as Plugin<TContext>[];\n}\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;AA0CA,SAAgB,OACd,UAA6B,EAAE,EAC/B;AACA,QAAO,CACL,IAAI,QAAQ,IAAI,EAChB;EACE,MAAM;EACN,MAAM,SAAS;AACb,QAAK,MACH,0EACD;GAED,MAAM,SAAS,EACb,MAAM,SACP;AAED,OACE,CAAC,QAAQ,QACT,CAAC;IAAC;IAAY;IAAS;IAAS;IAAS,CAAC,SAAS,QAAQ,KAAK,EAChE;AACA,QAAI,QAAQ,KACV,MAAK,KACH,8BAA8B,QAAQ,KAAK,wCAC5C;AAGH,WAAO,KAAK,OAAO;;AAGrB,OAAI,CAAC,QAAQ,cACX,QAAO,KAAK,gBAAgB;AAG9B,QAAK,MAAM,uBAAuB,OAAO,KAAK,OAAO;AAErD,UAAO;;EAET,MAAM,iBAAiB;AACrB,QAAK,MACH,iFACD;AAED,QAAK,aAAa,KAAK,OAAO,KAAK,QAAQ;AAE3C,OAAI,CAAC,QAAQ,iBAAiB,KAAK,IAAI,OAAO,eAC5C,MAAK,OAAO,KAAK,gBAAgB,KAAK,IAAI,OAAO;;EAGrD,MAAM,UAAU;AACd,QAAK,MACH,mEACD;GAED,IAAI;AACJ,WAAQ,KAAK,OAAO,KAAK,MAAzB;IACE,KAAK;AACH,kBAAa;AACb;IACF,KAAK;AACH,kBAAa;AACb;IACF,KAAK;AACH,kBAAa;AACb;IAEF;AAEE,kBAAa;AACb;;AAGJ,SAAM,KAAK,YAAY,MAAM,QAAQ,QAAQ,WAAW,KAAK,CAAC,EAAE,OAAO;;EAE1E,CACF"}
@@ -1,3 +1,3 @@
1
1
  import { DateLibraryType, DatePluginContext, DatePluginOptions, DatePluginResolvedConfig, DatePluginUserConfig, __ΩDateLibraryType, __ΩDatePluginContext, __ΩDatePluginOptions, __ΩDatePluginResolvedConfig, __ΩDatePluginUserConfig } from "./plugin.cjs";
2
- import { DateFormats, StormDateInterface, TimeUnit, __ΩDateFormats, __ΩStormDateInterface, __ΩTimeUnit } from "./runtime.cjs";
3
- export { DateFormats, DateLibraryType, DatePluginContext, DatePluginOptions, DatePluginResolvedConfig, DatePluginUserConfig, StormDateInterface, TimeUnit, __ΩDateFormats, __ΩDateLibraryType, __ΩDatePluginContext, __ΩDatePluginOptions, __ΩDatePluginResolvedConfig, __ΩDatePluginUserConfig, __ΩStormDateInterface, __ΩTimeUnit };
2
+ import { DateEnvInterface, DateFormats, PowerlinesDateInterface, TimeUnit, __ΩDateEnvInterface, __ΩDateFormats, __ΩPowerlinesDateInterface, __ΩTimeUnit } from "./runtime.cjs";
3
+ export { DateEnvInterface, DateFormats, DateLibraryType, DatePluginContext, DatePluginOptions, DatePluginResolvedConfig, DatePluginUserConfig, PowerlinesDateInterface, TimeUnit, __ΩDateEnvInterface, __ΩDateFormats, __ΩDateLibraryType, __ΩDatePluginContext, __ΩDatePluginOptions, __ΩDatePluginResolvedConfig, __ΩDatePluginUserConfig, __ΩPowerlinesDateInterface, __ΩTimeUnit };
@@ -1,3 +1,3 @@
1
1
  import { DateLibraryType, DatePluginContext, DatePluginOptions, DatePluginResolvedConfig, DatePluginUserConfig, __ΩDateLibraryType, __ΩDatePluginContext, __ΩDatePluginOptions, __ΩDatePluginResolvedConfig, __ΩDatePluginUserConfig } from "./plugin.mjs";
2
- import { DateFormats, StormDateInterface, TimeUnit, __ΩDateFormats, __ΩStormDateInterface, __ΩTimeUnit } from "./runtime.mjs";
3
- export { DateFormats, DateLibraryType, DatePluginContext, DatePluginOptions, DatePluginResolvedConfig, DatePluginUserConfig, StormDateInterface, TimeUnit, __ΩDateFormats, __ΩDateLibraryType, __ΩDatePluginContext, __ΩDatePluginOptions, __ΩDatePluginResolvedConfig, __ΩDatePluginUserConfig, __ΩStormDateInterface, __ΩTimeUnit };
2
+ import { DateEnvInterface, DateFormats, PowerlinesDateInterface, TimeUnit, __ΩDateEnvInterface, __ΩDateFormats, __ΩPowerlinesDateInterface, __ΩTimeUnit } from "./runtime.mjs";
3
+ export { DateEnvInterface, DateFormats, DateLibraryType, DatePluginContext, DatePluginOptions, DatePluginResolvedConfig, DatePluginUserConfig, PowerlinesDateInterface, TimeUnit, __ΩDateEnvInterface, __ΩDateFormats, __ΩDateLibraryType, __ΩDatePluginContext, __ΩDatePluginOptions, __ΩDatePluginResolvedConfig, __ΩDatePluginUserConfig, __ΩPowerlinesDateInterface, __ΩTimeUnit };
@@ -20,6 +20,15 @@ interface DatePluginOptions {
20
20
  * Options for the Env plugin.
21
21
  */
22
22
  env?: EnvPluginOptions;
23
+ /**
24
+ * The default locale to use for date formatting and parsing.
25
+ *
26
+ * @remarks
27
+ * This value is used as the default locale for date formatting and parsing. It can be overridden by the `LOCALE` environment variable or the `DEFAULT_LOCALE` environment variable.
28
+ *
29
+ * @defaultValue "en-US"
30
+ */
31
+ defaultLocale?: string;
23
32
  }
24
33
  interface DatePluginUserConfig extends EnvPluginUserConfig {
25
34
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;KAyBY,eAAA;AAAA,UAEK,iBAAA;EAFL;;;;;AAEZ;;;;;;;EAaE,IAAA,GAAO,eAAA;EAKe;;AAGxB;EAHE,GAAA,GAAM,gBAAA;AAAA;AAAA,UAGS,oBAAA,SAA6B,mBAAA;EAIrC;;;EAAP,IAAA,GAAO,IAAA,CAAK,iBAAA;AAAA;AAAA,UAGG,wBAAA,SAAiC,uBAAA;EAHzC;;;EAOP,IAAA,EAAM,QAAA,CAAS,IAAA,CAAK,iBAAA;AAAA;AAAA,KAGV,iBAAA,yBACc,wBAAA,GAA2B,wBAAA,IACjD,gBAAA,CAAiB,eAAA;AAAA"}
1
+ {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;KAyBY,eAAA;AAAA,UAEK,iBAAA;EAFL;;;;;AAEZ;;;;;;;EAaE,IAAA,GAAO,eAAA;EAeP;;;EAVA,GAAA,GAAM,gBAAA;EAa8B;;;;;;;;EAHpC,aAAA;AAAA;AAAA,UAGe,oBAAA,SAA6B,mBAAA;EAIf;;AAG/B;EAHE,IAAA,GAAO,IAAA,CAAK,iBAAA;AAAA;AAAA,UAGG,wBAAA,SAAiC,uBAAA;EAIjC;;;EAAf,IAAA,EAAM,QAAA,CAAS,IAAA,CAAK,iBAAA;AAAA;AAAA,KAGV,iBAAA,yBACc,wBAAA,GAA2B,wBAAA,IACjD,gBAAA,CAAiB,eAAA;AAAA"}
@@ -20,6 +20,15 @@ interface DatePluginOptions {
20
20
  * Options for the Env plugin.
21
21
  */
22
22
  env?: EnvPluginOptions;
23
+ /**
24
+ * The default locale to use for date formatting and parsing.
25
+ *
26
+ * @remarks
27
+ * This value is used as the default locale for date formatting and parsing. It can be overridden by the `LOCALE` environment variable or the `DEFAULT_LOCALE` environment variable.
28
+ *
29
+ * @defaultValue "en-US"
30
+ */
31
+ defaultLocale?: string;
23
32
  }
24
33
  interface DatePluginUserConfig extends EnvPluginUserConfig {
25
34
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;KAyBY,eAAA;AAAA,UAEK,iBAAA;EAFL;;;;;AAEZ;;;;;;;EAaE,IAAA,GAAO,eAAA;EAKe;;AAGxB;EAHE,GAAA,GAAM,gBAAA;AAAA;AAAA,UAGS,oBAAA,SAA6B,mBAAA;EAIrC;;;EAAP,IAAA,GAAO,IAAA,CAAK,iBAAA;AAAA;AAAA,UAGG,wBAAA,SAAiC,uBAAA;EAHzC;;;EAOP,IAAA,EAAM,QAAA,CAAS,IAAA,CAAK,iBAAA;AAAA;AAAA,KAGV,iBAAA,yBACc,wBAAA,GAA2B,wBAAA,IACjD,gBAAA,CAAiB,eAAA;AAAA"}
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;KAyBY,eAAA;AAAA,UAEK,iBAAA;EAFL;;;;;AAEZ;;;;;;;EAaE,IAAA,GAAO,eAAA;EAeP;;;EAVA,GAAA,GAAM,gBAAA;EAa8B;;;;;;;;EAHpC,aAAA;AAAA;AAAA,UAGe,oBAAA,SAA6B,mBAAA;EAIf;;AAG/B;EAHE,IAAA,GAAO,IAAA,CAAK,iBAAA;AAAA;AAAA,UAGG,wBAAA,SAAiC,uBAAA;EAIjC;;;EAAf,IAAA,EAAM,QAAA,CAAS,IAAA,CAAK,iBAAA;AAAA;AAAA,KAGV,iBAAA,yBACc,wBAAA,GAA2B,wBAAA,IACjD,gBAAA,CAAiB,eAAA;AAAA"}
@@ -1,3 +1,5 @@
1
+ import { EnvInterface } from "@powerlines/plugin-env/types/runtime";
2
+
1
3
  //#region src/types/runtime.d.ts
2
4
  /**
3
5
  * The various types of date formats used in Storm Stack applications.
@@ -194,7 +196,7 @@ type TimeUnit = "years" | "quarters" | "months" | "weeks" | "days" | "hours" | "
194
196
  * @remarks
195
197
  * This interface defines a contract for date manipulation and formatting utilities, abstracting over different date libraries (such as [Moment.js](https://momentjs.com/), [Day.js](https://day.js.org/), etc.). It provides methods for creating, parsing, comparing, and formatting dates, as well as manipulating date components and handling localization.
196
198
  */
197
- interface StormDateInterface<TDate, TLocale> {
199
+ interface PowerlinesDateInterface<TDate, TLocale> {
198
200
  /**
199
201
  * The set of date formats supported by the utility.
200
202
  */
@@ -704,9 +706,18 @@ interface StormDateInterface<TDate, TLocale> {
704
706
  */
705
707
  getMeridiemText: (meridiem: "am" | "pm") => string;
706
708
  }
709
+ interface DateEnvInterface extends EnvInterface {
710
+ /**
711
+ * The locale to use for date formatting and parsing. This can be set via the `LOCALE` environment variable or the `DEFAULT_LOCALE` environment variable, with `LOCALE` taking precedence if both are set. If neither is set, it will default to "en-US".
712
+ *
713
+ * @runtime
714
+ */
715
+ LOCALE?: string;
716
+ }
707
717
  declare type __ΩDateFormats = any[];
708
718
  declare type __ΩTimeUnit = any[];
709
- declare type __ΩStormDateInterface = any[];
719
+ declare type __ΩPowerlinesDateInterface = any[];
720
+ declare type __ΩDateEnvInterface = any[];
710
721
  //#endregion
711
- export { DateFormats, StormDateInterface, TimeUnit, __ΩDateFormats, __ΩStormDateInterface, __ΩTimeUnit };
722
+ export { DateEnvInterface, DateFormats, PowerlinesDateInterface, TimeUnit, __ΩDateEnvInterface, __ΩDateFormats, __ΩPowerlinesDateInterface, __ΩTimeUnit };
712
723
  //# sourceMappingURL=runtime.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.cts","names":[],"sources":["../../src/types/runtime.ts"],"mappings":";;AAqBA;;UAAiB,WAAA;EAML;;;;;EAAV,QAAA,EAAU,YAAA;EA0CH;;;;;EAnCP,mBAAA,EAAqB,YAAA;EA6ET;;;;;EAtEZ,UAAA,EAAY,YAAA;EAgHC;;;;;EAzGb,qBAAA,EAAuB,YAAA;EAmJL;;;;;EA5IlB,SAAA,EAAW,YAAA;EAwKmB;;;;;EAjK9B,IAAA,EAAM,YAAA;EArBN;;;;;EA4BA,KAAA,EAAO,YAAA;EAPP;;;;;EAcA,UAAA,EAAY,YAAA;EAOZ;;;;;EAAA,YAAA,EAAc,YAAA;EAqBd;;;;;EAdA,YAAA,EAAc,YAAA;EAmCd;;;;;EA5BA,OAAA,EAAS,YAAA;EAiDT;;;;;EA1CA,YAAA,EAAc,YAAA;EA+Dd;;;;;EAxDA,UAAA,EAAY,YAAA;EA6EZ;;;;;EAtEA,QAAA,EAAU,YAAA;EA2FV;;;;;EApFA,QAAA,EAAU,YAAA;EAkGoB;;AAShC;;;EApGE,OAAA,EAAS,YAAA;EAoGS;AA0BpB;;;;EAvHE,OAAA,EAAS,YAAA;EA4JU;;;;;EArJnB,QAAA,EAAU,YAAA;EAoKQ;;;;;EA7JlB,WAAA,EAAa,YAAA;EAqOI;;;;;EA9NjB,WAAA,EAAa,YAAA;EAyP0B;;;;;EAlPvC,YAAA,EAAc,YAAA;EA6QqB;;;;;EAtQnC,eAAA,EAAiB,YAAA;EAiSsB;;;;;EA1RvC,eAAA,EAAiB,YAAA;EAqTwB;;;;;EA9SzC,YAAA,EAAc,YAAA;EAwUO;;;;;EAjUrB,gBAAA,EAAkB,YAAA;EAyVE;;;;;EAlVpB,mBAAA,EAAqB,YAAA;EA2WD;;;;;EApWpB,mBAAA,EAAqB,YAAA;E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;;;EAQA,YAAA,GAAe,IAAA,EAAM,KAAA,KAAU,KAAA;;;;;;;;EAS/B,YAAA,GAAe,KAAA,EAAO,KAAA,EAAO,GAAA,EAAK,KAAA,KAAU,KAAA;;;;;;;EAQ5C,eAAA,GAAkB,QAAA;AAAA;AAAA,UAGH,gBAAA,SAAyB,YAAA;;;;;;EAMxC,MAAA;AAAA;AAAA"}
@@ -1,3 +1,5 @@
1
+ import { EnvInterface } from "@powerlines/plugin-env/types/runtime";
2
+
1
3
  //#region src/types/runtime.d.ts
2
4
  /**
3
5
  * The various types of date formats used in Storm Stack applications.
@@ -194,7 +196,7 @@ type TimeUnit = "years" | "quarters" | "months" | "weeks" | "days" | "hours" | "
194
196
  * @remarks
195
197
  * This interface defines a contract for date manipulation and formatting utilities, abstracting over different date libraries (such as [Moment.js](https://momentjs.com/), [Day.js](https://day.js.org/), etc.). It provides methods for creating, parsing, comparing, and formatting dates, as well as manipulating date components and handling localization.
196
198
  */
197
- interface StormDateInterface<TDate, TLocale> {
199
+ interface PowerlinesDateInterface<TDate, TLocale> {
198
200
  /**
199
201
  * The set of date formats supported by the utility.
200
202
  */
@@ -704,9 +706,18 @@ interface StormDateInterface<TDate, TLocale> {
704
706
  */
705
707
  getMeridiemText: (meridiem: "am" | "pm") => string;
706
708
  }
709
+ interface DateEnvInterface extends EnvInterface {
710
+ /**
711
+ * The locale to use for date formatting and parsing. This can be set via the `LOCALE` environment variable or the `DEFAULT_LOCALE` environment variable, with `LOCALE` taking precedence if both are set. If neither is set, it will default to "en-US".
712
+ *
713
+ * @runtime
714
+ */
715
+ LOCALE?: string;
716
+ }
707
717
  declare type __ΩDateFormats = any[];
708
718
  declare type __ΩTimeUnit = any[];
709
- declare type __ΩStormDateInterface = any[];
719
+ declare type __ΩPowerlinesDateInterface = any[];
720
+ declare type __ΩDateEnvInterface = any[];
710
721
  //#endregion
711
- export { DateFormats, StormDateInterface, TimeUnit, __ΩDateFormats, __ΩStormDateInterface, __ΩTimeUnit };
722
+ export { DateEnvInterface, DateFormats, PowerlinesDateInterface, TimeUnit, __ΩDateEnvInterface, __ΩDateFormats, __ΩPowerlinesDateInterface, __ΩTimeUnit };
712
723
  //# sourceMappingURL=runtime.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.mts","names":[],"sources":["../../src/types/runtime.ts"],"mappings":";;AAqBA;;UAAiB,WAAA;EAML;;;;;EAAV,QAAA,EAAU,YAAA;EA0CH;;;;;EAnCP,mBAAA,EAAqB,YAAA;EA6ET;;;;;EAtEZ,UAAA,EAAY,YAAA;EAgHC;;;;;EAzGb,qBAAA,EAAuB,YAAA;EAmJL;;;;;EA5IlB,SAAA,EAAW,YAAA;EAwKmB;;;;;EAjK9B,IAAA,EAAM,YAAA;EArBN;;;;;EA4BA,KAAA,EAAO,YAAA;EAPP;;;;;EAcA,UAAA,EAAY,YAAA;EAOZ;;;;;EAAA,YAAA,EAAc,YAAA;EAqBd;;;;;EAdA,YAAA,EAAc,YAAA;EAmCd;;;;;EA5BA,OAAA,EAAS,YAAA;EAiDT;;;;;EA1CA,YAAA,EAAc,YAAA;EA+Dd;;;;;EAxDA,UAAA,EAAY,YAAA;EA6EZ;;;;;EAtEA,QAAA,EAAU,YAAA;EA2FV;;;;;EApFA,QAAA,EAAU,YAAA;EAkGoB;;AAShC;;;EApGE,OAAA,EAAS,YAAA;EAoGS;AA0BpB;;;;EAvHE,OAAA,EAAS,YAAA;EA4JU;;;;;EArJnB,QAAA,EAAU,YAAA;EAoKQ;;;;;EA7JlB,WAAA,EAAa,YAAA;EAqOI;;;;;EA9NjB,WAAA,EAAa,YAAA;EAyP0B;;;;;EAlPvC,YAAA,EAAc,YAAA;EA6QqB;;;;;EAtQnC,eAAA,EAAiB,YAAA;EAiSsB;;;;;EA1RvC,eAAA,EAAiB,YAAA;EAqTwB;;;;;EA9SzC,YAAA,EAAc,YAAA;EAwUO;;;;;EAjUrB,gBAAA,EAAkB,YAAA;EAyVE;;;;;EAlVpB,mBAAA,E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IAAA,EAAM,KAAA,KAAU,KAAA;;;;;;EAOhD,WAAA;;;;;;;EAQA,YAAA,GAAe,IAAA,EAAM,KAAA,KAAU,KAAA;;;;;;;;EAS/B,YAAA,GAAe,KAAA,EAAO,KAAA,EAAO,GAAA,EAAK,KAAA,KAAU,KAAA;;;;;;;EAQ5C,eAAA,GAAkB,QAAA;AAAA;AAAA,UAGH,gBAAA,SAAyB,YAAA;;;;;;EAMxC,MAAA;AAAA;AAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-date",
3
- "version": "0.12.475",
3
+ "version": "0.12.477",
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.131",
106
+ "@powerlines/plugin-env": "^0.16.133",
107
107
  "@storm-software/config-tools": "^1.189.77",
108
108
  "@stryke/path": "^0.27.4",
109
109
  "defu": "^6.1.7",
110
- "powerlines": "^0.43.5"
110
+ "powerlines": "^0.43.7"
111
111
  },
112
112
  "devDependencies": {
113
- "@powerlines/plugin-plugin": "^0.12.357",
113
+ "@powerlines/plugin-plugin": "^0.12.359",
114
114
  "@types/node": "^25.6.0"
115
115
  },
116
116
  "publishConfig": { "access": "public" },
117
- "gitHead": "20f2c6b5e4a07b06620c8c98d83bb3b31503c426"
117
+ "gitHead": "b7dcad6bc06c093b3a839ab89438129c56f72813"
118
118
  }