@getmicdrop/svelte-components 5.3.12 → 5.3.13
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.
- package/dist/calendar/AboutShow/AboutShow.svelte +172 -172
- package/dist/calendar/Calendar/MiniMonthCalendar.svelte +782 -782
- package/dist/calendar/FAQs/FAQs.svelte +75 -75
- package/dist/calendar/MonthSwitcher/MonthSwitcher.svelte +126 -126
- package/dist/calendar/OrderSummary/OrderSummary.svelte +367 -367
- package/dist/calendar/PublicCard/PublicCard.svelte +145 -145
- package/dist/calendar/ShowCard/ShowCard.svelte +157 -157
- package/dist/calendar/ShowTimeCard/ShowTimeCard.svelte +61 -61
- package/dist/components/Layout/Grid.svelte +109 -109
- package/dist/components/Layout/Section.svelte +80 -80
- package/dist/components/Layout/Sidebar.svelte +108 -108
- package/dist/components/Layout/Stack.svelte +90 -90
- package/dist/constants/formOptions.js +26 -26
- package/dist/constants/validation.js +91 -91
- package/dist/constants/validation.spec.js +64 -64
- package/dist/datetime/__tests__/format.test.d.ts +2 -0
- package/dist/datetime/__tests__/format.test.d.ts.map +1 -0
- package/dist/datetime/__tests__/format.test.js +268 -0
- package/dist/datetime/__tests__/integration.test.d.ts +2 -0
- package/dist/datetime/__tests__/integration.test.d.ts.map +1 -0
- package/dist/datetime/__tests__/integration.test.js +243 -0
- package/dist/datetime/__tests__/parse.test.d.ts +2 -0
- package/dist/datetime/__tests__/parse.test.d.ts.map +1 -0
- package/dist/datetime/__tests__/parse.test.js +261 -0
- package/dist/datetime/__tests__/timezone.test.d.ts +2 -0
- package/dist/datetime/__tests__/timezone.test.d.ts.map +1 -0
- package/dist/datetime/__tests__/timezone.test.js +214 -0
- package/dist/datetime/constants.d.ts +133 -0
- package/dist/datetime/constants.d.ts.map +1 -0
- package/dist/datetime/constants.js +112 -0
- package/dist/datetime/format.d.ts +158 -0
- package/dist/datetime/format.d.ts.map +1 -0
- package/dist/datetime/format.js +315 -0
- package/dist/datetime/index.d.ts +42 -0
- package/dist/datetime/index.d.ts.map +1 -0
- package/dist/datetime/index.js +44 -0
- package/dist/datetime/parse.d.ts +149 -0
- package/dist/datetime/parse.d.ts.map +1 -0
- package/dist/datetime/parse.js +276 -0
- package/dist/datetime/timezone.d.ts +95 -0
- package/dist/datetime/timezone.d.ts.map +1 -0
- package/dist/datetime/timezone.js +241 -0
- package/dist/datetime/types.d.ts +105 -0
- package/dist/datetime/types.d.ts.map +1 -0
- package/dist/datetime/types.js +31 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +232 -218
- package/dist/patterns/data/DataGrid.svelte +45 -45
- package/dist/patterns/data/DataList.svelte +24 -24
- package/dist/patterns/data/DataTable.svelte +40 -40
- package/dist/patterns/forms/FormActions.spec.js +88 -88
- package/dist/patterns/forms/FormActions.stories.svelte +97 -97
- package/dist/patterns/forms/FormActions.svelte +46 -46
- package/dist/patterns/forms/FormGrid.svelte +33 -33
- package/dist/patterns/forms/FormSection.svelte +32 -32
- package/dist/patterns/forms/FormValidationSummary.spec.js +203 -203
- package/dist/patterns/forms/FormValidationSummary.stories.svelte +97 -97
- package/dist/patterns/forms/FormValidationSummary.svelte +67 -67
- package/dist/patterns/layout/Grid.svelte +35 -35
- package/dist/patterns/layout/Sidebar.svelte +39 -39
- package/dist/patterns/layout/Stack.svelte +45 -45
- package/dist/patterns/navigation/BottomNav.spec.js +130 -130
- package/dist/patterns/navigation/BottomNav.stories.svelte +117 -117
- package/dist/patterns/navigation/BottomNav.svelte +54 -54
- package/dist/patterns/navigation/Header.spec.js +203 -203
- package/dist/patterns/navigation/Header.stories.svelte +77 -77
- package/dist/patterns/navigation/Header.svelte +240 -240
- package/dist/patterns/page/PageHeader.svelte +36 -36
- package/dist/patterns/page/PageLayout.svelte +40 -40
- package/dist/patterns/page/PageLoader.spec.js +54 -54
- package/dist/patterns/page/PageLoader.stories.svelte +137 -137
- package/dist/patterns/page/PageLoader.svelte +41 -41
- package/dist/patterns/page/SectionHeader.svelte +41 -41
- package/dist/presets/badges.js +112 -112
- package/dist/presets/buttons.js +76 -76
- package/dist/presets/index.js +9 -9
- package/dist/primitives/Accordion/Accordion.stories.svelte +75 -75
- package/dist/primitives/Accordion/Accordion.svelte +61 -61
- package/dist/primitives/Accordion/AccordionItem.svelte +95 -95
- package/dist/primitives/Alert/Alert.spec.js +170 -170
- package/dist/primitives/Alert/Alert.stories.svelte +88 -88
- package/dist/primitives/Alert/Alert.svelte +65 -65
- package/dist/primitives/Avatar/Avatar.stories.svelte +94 -94
- package/dist/primitives/Avatar/Avatar.svelte +66 -66
- package/dist/primitives/Badges/Badge.spec.js +103 -103
- package/dist/primitives/Badges/Badge.stories.svelte +86 -86
- package/dist/primitives/Badges/Badge.svelte +142 -142
- package/dist/primitives/BottomSheet/BottomSheet.spec.js +127 -127
- package/dist/primitives/BottomSheet/BottomSheet.stories.svelte +83 -83
- package/dist/primitives/BottomSheet/BottomSheet.svelte +100 -100
- package/dist/primitives/Breadcrumb/Breadcrumb.spec.js +120 -120
- package/dist/primitives/Breadcrumb/Breadcrumb.stories.svelte +23 -23
- package/dist/primitives/Breadcrumb/Breadcrumb.svelte +89 -89
- package/dist/primitives/Button/Button.spec.js +211 -211
- package/dist/primitives/Button/Button.stories.svelte +76 -76
- package/dist/primitives/Button/Button.svelte +301 -301
- package/dist/primitives/Button/ButtonSaveDemo.spec.js +48 -48
- package/dist/primitives/Button/ButtonSaveDemo.svelte +25 -25
- package/dist/primitives/Button/ButtonVariantShowcase.svelte +129 -129
- package/dist/primitives/Card.spec.js +49 -49
- package/dist/primitives/Card.stories.svelte +22 -22
- package/dist/primitives/Card.svelte +28 -28
- package/dist/primitives/Checkbox/Checkbox.stories.svelte +84 -84
- package/dist/primitives/Checkbox/Checkbox.svelte +88 -88
- package/dist/primitives/DarkModeToggle.spec.js +357 -357
- package/dist/primitives/DarkModeToggle.stories.svelte +57 -57
- package/dist/primitives/DarkModeToggle.svelte +136 -136
- package/dist/primitives/Drawer/Drawer.stories.svelte +100 -100
- package/dist/primitives/Drawer/Drawer.svelte +214 -214
- package/dist/primitives/Dropdown/Dropdown.stories.svelte +137 -137
- package/dist/primitives/Dropdown/Dropdown.svelte +148 -148
- package/dist/primitives/Dropdown/DropdownItem.svelte +80 -80
- package/dist/primitives/Icons/ArrowLeft.svelte +20 -20
- package/dist/primitives/Icons/ArrowRight.svelte +20 -20
- package/dist/primitives/Icons/Availability.svelte +26 -26
- package/dist/primitives/Icons/Back.svelte +26 -26
- package/dist/primitives/Icons/CheckCircle.svelte +18 -18
- package/dist/primitives/Icons/CheckCircleOutline.svelte +27 -27
- package/dist/primitives/Icons/ChevronLeft.svelte +16 -16
- package/dist/primitives/Icons/ChevronRight.svelte +16 -16
- package/dist/primitives/Icons/Copy.svelte +27 -27
- package/dist/primitives/Icons/Cross.svelte +17 -17
- package/dist/primitives/Icons/DownArrow.svelte +20 -20
- package/dist/primitives/Icons/ErrorCircle.svelte +18 -18
- package/dist/primitives/Icons/FacebookIcon.svelte +13 -13
- package/dist/primitives/Icons/Home.svelte +27 -27
- package/dist/primitives/Icons/Icon.spec.js +175 -175
- package/dist/primitives/Icons/Icon.stories.svelte +100 -100
- package/dist/primitives/Icons/Icon.svelte +63 -63
- package/dist/primitives/Icons/IconGallery.stories.svelte +235 -235
- package/dist/primitives/Icons/ImageOutline.svelte +19 -19
- package/dist/primitives/Icons/Info.svelte +19 -19
- package/dist/primitives/Icons/InstagramIcon.svelte +19 -19
- package/dist/primitives/Icons/LogoInstagram.svelte +15 -15
- package/dist/primitives/Icons/Message.svelte +27 -27
- package/dist/primitives/Icons/MoonIcon.svelte +16 -16
- package/dist/primitives/Icons/More.svelte +33 -33
- package/dist/primitives/Icons/MoreHori.spec.js +67 -67
- package/dist/primitives/Icons/MoreHori.svelte +34 -34
- package/dist/primitives/Icons/Notification.svelte +26 -26
- package/dist/primitives/Icons/Payment.svelte +26 -26
- package/dist/primitives/Icons/Profile.svelte +33 -33
- package/dist/primitives/Icons/Reload.svelte +41 -41
- package/dist/primitives/Icons/Shows.svelte +33 -33
- package/dist/primitives/Icons/Signout.svelte +33 -33
- package/dist/primitives/Icons/SunIcon.svelte +19 -19
- package/dist/primitives/Icons/TiktokIcon.svelte +13 -13
- package/dist/primitives/Icons/TrashBinOutline.svelte +19 -19
- package/dist/primitives/Icons/TwitterIcon.svelte +13 -13
- package/dist/primitives/Icons/WarningIcon.spec.js +30 -30
- package/dist/primitives/Icons/WarningIcon.svelte +24 -24
- package/dist/primitives/Input/Input.spec.js +573 -573
- package/dist/primitives/Input/Input.stories.svelte +139 -139
- package/dist/primitives/Input/Input.svelte +444 -444
- package/dist/primitives/Input/Select.spec.js +218 -218
- package/dist/primitives/Input/Select.stories.svelte +112 -112
- package/dist/primitives/Input/Select.svelte +232 -232
- package/dist/primitives/Input/Textarea.stories.svelte +137 -137
- package/dist/primitives/Input/Textarea.svelte +79 -79
- package/dist/primitives/Label/Label.svelte +37 -37
- package/dist/primitives/Modal/Modal.spec.js +95 -95
- package/dist/primitives/Modal/Modal.stories.svelte +86 -86
- package/dist/primitives/Modal/Modal.svelte +158 -158
- package/dist/primitives/Pagination/Pagination.stories.svelte +76 -76
- package/dist/primitives/Pagination/Pagination.svelte +261 -261
- package/dist/primitives/Radio/Radio.stories.svelte +80 -80
- package/dist/primitives/Radio/Radio.svelte +67 -67
- package/dist/primitives/Skeleton/CardPlaceholder.svelte +87 -87
- package/dist/primitives/Skeleton/ImagePlaceholder.svelte +59 -59
- package/dist/primitives/Skeleton/ListPlaceholder.svelte +76 -76
- package/dist/primitives/Skeleton/Skeleton.stories.svelte +151 -151
- package/dist/primitives/Skeleton/Skeleton.svelte +52 -52
- package/dist/primitives/Spinner/Spinner.spec.js +75 -75
- package/dist/primitives/Spinner/Spinner.stories.svelte +29 -29
- package/dist/primitives/Spinner/Spinner.svelte +57 -57
- package/dist/primitives/Tabs/TabItem.svelte +51 -51
- package/dist/primitives/Tabs/Tabs.stories.svelte +112 -112
- package/dist/primitives/Tabs/Tabs.svelte +128 -128
- package/dist/primitives/Toggle.spec.js +127 -127
- package/dist/primitives/Toggle.stories.svelte +92 -92
- package/dist/primitives/Toggle.svelte +71 -71
- package/dist/primitives/Typography/Typography.svelte +53 -53
- package/dist/primitives/ValidationError.spec.js +103 -103
- package/dist/primitives/ValidationError.stories.svelte +111 -111
- package/dist/primitives/ValidationError.svelte +29 -29
- package/dist/recipes/CropImage/CropImage.spec.js +216 -216
- package/dist/recipes/CropImage/CropImage.stories.svelte +104 -104
- package/dist/recipes/CropImage/CropImage.svelte +238 -238
- package/dist/recipes/ImageUploader/ImageUploader.stories.svelte +125 -125
- package/dist/recipes/ImageUploader/ImageUploader.svelte +980 -980
- package/dist/recipes/Toaster/Toaster.stories.svelte +62 -62
- package/dist/recipes/feedback/EmptyState/EmptyState.svelte +47 -47
- package/dist/recipes/feedback/ErrorDisplay.spec.js +69 -69
- package/dist/recipes/feedback/ErrorDisplay.stories.svelte +112 -112
- package/dist/recipes/feedback/ErrorDisplay.svelte +38 -38
- package/dist/recipes/feedback/StatusIndicator/StatusIndicator.spec.js +129 -129
- package/dist/recipes/feedback/StatusIndicator/StatusIndicator.svelte +167 -167
- package/dist/recipes/fields/CheckboxField.svelte +85 -85
- package/dist/recipes/fields/FormField.svelte +58 -58
- package/dist/recipes/fields/RadioGroup.svelte +95 -95
- package/dist/recipes/fields/SelectField.svelte +82 -82
- package/dist/recipes/fields/TextareaField.svelte +101 -101
- package/dist/recipes/fields/ToggleField.svelte +60 -60
- package/dist/recipes/fields/index.js +7 -7
- package/dist/recipes/inputs/MultiSelect.spec.js +257 -257
- package/dist/recipes/inputs/MultiSelect.stories.svelte +133 -133
- package/dist/recipes/inputs/MultiSelect.svelte +244 -244
- package/dist/recipes/inputs/OTPInput.spec.js +238 -238
- package/dist/recipes/inputs/OTPInput.stories.svelte +162 -162
- package/dist/recipes/inputs/OTPInput.svelte +102 -102
- package/dist/recipes/inputs/PasswordInput.svelte +100 -100
- package/dist/recipes/inputs/PasswordStrengthIndicator/PasswordStrengthIndicator.spec.js +173 -173
- package/dist/recipes/inputs/PasswordStrengthIndicator/PasswordStrengthIndicator.svelte +108 -108
- package/dist/recipes/inputs/PlaceAutocomplete/PlaceAutocomplete.spec.js +300 -300
- package/dist/recipes/inputs/PlaceAutocomplete/PlaceAutocomplete.stories.svelte +165 -165
- package/dist/recipes/inputs/PlaceAutocomplete/PlaceAutocomplete.svelte +337 -337
- package/dist/recipes/inputs/Search.svelte +85 -85
- package/dist/recipes/inputs/SelectDropdown.svelte +161 -161
- package/dist/recipes/modals/AlertModal.svelte +130 -130
- package/dist/recipes/modals/ConfirmationModal.spec.js +191 -191
- package/dist/recipes/modals/ConfirmationModal.stories.svelte +119 -119
- package/dist/recipes/modals/ConfirmationModal.svelte +152 -152
- package/dist/recipes/modals/InputModal.svelte +182 -182
- package/dist/recipes/modals/ModalStateManager.spec.js +100 -100
- package/dist/recipes/modals/ModalStateManager.svelte +77 -77
- package/dist/recipes/modals/ModalTestWrapper.svelte +65 -65
- package/dist/recipes/modals/StatusModal.svelte +206 -206
- package/dist/services/EventService.js +75 -75
- package/dist/services/EventService.spec.js +217 -217
- package/dist/services/ShowService.spec.js +342 -342
- package/dist/stores/auth.js +93 -6
- package/dist/stores/auth.spec.js +310 -2
- package/dist/stores/toaster.js +13 -13
- package/dist/stories/ButtonAuditReview.stories.svelte +14 -14
- package/dist/stories/ButtonAuditReview.svelte +427 -427
- package/dist/stories/PatternsGallery.stories.svelte +19 -19
- package/dist/stories/PatternsGallery.svelte +388 -388
- package/dist/stories/PrimitivesGallery.stories.svelte +19 -19
- package/dist/stories/PrimitivesGallery.svelte +752 -752
- package/dist/stories/RecipesGallery.stories.svelte +19 -19
- package/dist/stories/RecipesGallery.svelte +441 -441
- package/dist/stories/button-audit-manifest.json +11186 -11186
- package/dist/tailwind/preset.cjs +82 -82
- package/dist/telemetry.js +357 -357
- package/dist/tokens/tokens.css +87 -87
- package/dist/utils/apiConfig.js +49 -49
- package/dist/utils/utils.js +9 -1
- package/package.json +233 -191
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DateTime Parsing Functions
|
|
3
|
+
*
|
|
4
|
+
* Functions for parsing and converting between local and UTC times.
|
|
5
|
+
* All functions require explicit timezone parameters.
|
|
6
|
+
*
|
|
7
|
+
* @module datetime/parse
|
|
8
|
+
*/
|
|
9
|
+
import type { ISODateString, LocalDateString, LocalDateTimeString, LocalTimeString, TimezoneId } from './types';
|
|
10
|
+
/**
|
|
11
|
+
* Converts a local datetime string to UTC ISO string.
|
|
12
|
+
*
|
|
13
|
+
* @param localDateTime - Local datetime string (e.g., '2023-12-25T19:00:00')
|
|
14
|
+
* @param timezone - IANA timezone ID
|
|
15
|
+
* @returns UTC ISO string (e.g., '2023-12-26T03:00:00Z')
|
|
16
|
+
* @throws {DateTimeError} If timezone or datetime is invalid
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* parseLocalToUTC('2023-12-25T19:00:00', 'America/Los_Angeles')
|
|
20
|
+
* // '2023-12-26T03:00:00Z' (7 PM LA = 3 AM next day UTC)
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseLocalToUTC(localDateTime: LocalDateTimeString, timezone: TimezoneId): ISODateString;
|
|
23
|
+
/**
|
|
24
|
+
* Converts a UTC ISO string to local datetime string.
|
|
25
|
+
*
|
|
26
|
+
* @param utcIso - UTC ISO string (e.g., '2023-12-26T03:00:00Z')
|
|
27
|
+
* @param timezone - IANA timezone ID
|
|
28
|
+
* @returns Local datetime string without timezone (e.g., '2023-12-25T19:00:00')
|
|
29
|
+
* @throws {DateTimeError} If timezone or ISO string is invalid
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* parseUTCToLocal('2023-12-26T03:00:00Z', 'America/Los_Angeles')
|
|
33
|
+
* // '2023-12-25T19:00:00' (3 AM UTC = 7 PM previous day LA)
|
|
34
|
+
*/
|
|
35
|
+
export declare function parseUTCToLocal(utcIso: ISODateString, timezone: TimezoneId): LocalDateTimeString;
|
|
36
|
+
/**
|
|
37
|
+
* Combines a date string and time string into a UTC ISO string.
|
|
38
|
+
*
|
|
39
|
+
* @param date - Date string in YYYY-MM-DD format
|
|
40
|
+
* @param time - Time string in HH:mm or HH:mm:ss format
|
|
41
|
+
* @param timezone - IANA timezone ID
|
|
42
|
+
* @returns UTC ISO string
|
|
43
|
+
* @throws {DateTimeError} If any input is invalid
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* combineDateAndTime('2023-12-25', '19:00', 'America/Los_Angeles')
|
|
47
|
+
* // '2023-12-26T03:00:00Z'
|
|
48
|
+
*/
|
|
49
|
+
export declare function combineDateAndTime(date: LocalDateString, time: LocalTimeString, timezone: TimezoneId): ISODateString;
|
|
50
|
+
/**
|
|
51
|
+
* Parses a UTC ISO string into separate date and time components.
|
|
52
|
+
*
|
|
53
|
+
* @param utcIso - UTC ISO string
|
|
54
|
+
* @param timezone - IANA timezone ID
|
|
55
|
+
* @returns Object with date (YYYY-MM-DD) and time (HH:mm) strings in local timezone
|
|
56
|
+
* @throws {DateTimeError} If inputs are invalid
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* parseDateTimeFromAPI('2023-12-26T03:00:00Z', 'America/Los_Angeles')
|
|
60
|
+
* // { date: '2023-12-25', time: '19:00' }
|
|
61
|
+
*/
|
|
62
|
+
export declare function parseDateTimeFromAPI(utcIso: ISODateString, timezone: TimezoneId): {
|
|
63
|
+
date: LocalDateString;
|
|
64
|
+
time: LocalTimeString;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Formats a Date object for API submission (UTC ISO string).
|
|
68
|
+
*
|
|
69
|
+
* @param date - JavaScript Date object
|
|
70
|
+
* @returns UTC ISO string
|
|
71
|
+
* @throws {DateTimeError} If date is invalid
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* formatDateTimeForAPI(new Date('2023-12-25T19:00:00-08:00'))
|
|
75
|
+
* // '2023-12-26T03:00:00Z'
|
|
76
|
+
*/
|
|
77
|
+
export declare function formatDateTimeForAPI(date: Date): ISODateString;
|
|
78
|
+
/**
|
|
79
|
+
* Parses a date-only string and returns start of day in UTC.
|
|
80
|
+
*
|
|
81
|
+
* @param dateStr - Date string in YYYY-MM-DD format
|
|
82
|
+
* @param timezone - IANA timezone ID
|
|
83
|
+
* @returns UTC ISO string for start of day
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* parseStartOfDay('2023-12-25', 'America/Los_Angeles')
|
|
87
|
+
* // '2023-12-25T08:00:00Z' (midnight LA = 8 AM UTC)
|
|
88
|
+
*/
|
|
89
|
+
export declare function parseStartOfDay(dateStr: LocalDateString, timezone: TimezoneId): ISODateString;
|
|
90
|
+
/**
|
|
91
|
+
* Parses a date-only string and returns end of day in UTC.
|
|
92
|
+
*
|
|
93
|
+
* @param dateStr - Date string in YYYY-MM-DD format
|
|
94
|
+
* @param timezone - IANA timezone ID
|
|
95
|
+
* @returns UTC ISO string for end of day (23:59:59)
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* parseEndOfDay('2023-12-25', 'America/Los_Angeles')
|
|
99
|
+
* // '2023-12-26T07:59:59Z' (11:59:59 PM LA = 7:59:59 AM next day UTC)
|
|
100
|
+
*/
|
|
101
|
+
export declare function parseEndOfDay(dateStr: LocalDateString, timezone: TimezoneId): ISODateString;
|
|
102
|
+
/**
|
|
103
|
+
* Checks if a time string indicates next-day time (has +1_ prefix).
|
|
104
|
+
* This is a MicDrop convention for overnight events.
|
|
105
|
+
*
|
|
106
|
+
* @param timeStr - Time string that may have +1_ prefix
|
|
107
|
+
* @returns true if it's a next-day time
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* isNextDayTime('+1_02:00') // true
|
|
111
|
+
* isNextDayTime('14:00') // false
|
|
112
|
+
*/
|
|
113
|
+
export declare function isNextDayTime(timeStr: string): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Strips the next-day prefix from a time string.
|
|
116
|
+
*
|
|
117
|
+
* @param timeStr - Time string that may have +1_ prefix
|
|
118
|
+
* @returns Time string without prefix
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* stripNextDayPrefix('+1_02:00') // '02:00'
|
|
122
|
+
* stripNextDayPrefix('14:00') // '14:00'
|
|
123
|
+
*/
|
|
124
|
+
export declare function stripNextDayPrefix(timeStr: string): LocalTimeString;
|
|
125
|
+
/**
|
|
126
|
+
* Converts a time string to minutes since midnight.
|
|
127
|
+
*
|
|
128
|
+
* @param timeStr - Time string in HH:mm format (may have +1_ prefix)
|
|
129
|
+
* @returns Minutes since midnight (0-1439 for same day, 1440+ for next day)
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* parseTimeToMinutes('14:30') // 870
|
|
133
|
+
* parseTimeToMinutes('+1_02:00') // 1560 (26 hours = 1560 minutes)
|
|
134
|
+
*/
|
|
135
|
+
export declare function parseTimeToMinutes(timeStr: string): number;
|
|
136
|
+
/**
|
|
137
|
+
* Converts minutes since midnight to a time string.
|
|
138
|
+
*
|
|
139
|
+
* @param minutes - Minutes since midnight
|
|
140
|
+
* @param includeNextDayPrefix - If true and minutes >= 1440, adds +1_ prefix
|
|
141
|
+
* @returns Time string in HH:mm format
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* minutesToTimeString(870) // '14:30'
|
|
145
|
+
* minutesToTimeString(1560, true) // '+1_02:00'
|
|
146
|
+
* minutesToTimeString(1560, false) // '02:00'
|
|
147
|
+
*/
|
|
148
|
+
export declare function minutesToTimeString(minutes: number, includeNextDayPrefix?: boolean): LocalTimeString;
|
|
149
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/lib/datetime/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,UAAU,EACX,MAAM,SAAS,CAAC;AA6EjB;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,aAAa,EAAE,mBAAmB,EAClC,QAAQ,EAAE,UAAU,GACnB,aAAa,CAwBf;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,UAAU,GACnB,mBAAmB,CAyBrB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE,eAAe,EACrB,QAAQ,EAAE,UAAU,GACnB,aAAa,CAUf;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,UAAU,GACnB;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,IAAI,EAAE,eAAe,CAAA;CAAE,CA0BlD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,GAAG,aAAa,CAU9D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,UAAU,GACnB,aAAa,CAEf;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,UAAU,GACnB,aAAa,CAEf;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAKnE;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAc1D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,oBAAoB,GAAE,OAAe,GACpC,eAAe,CAcjB"}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DateTime Parsing Functions
|
|
3
|
+
*
|
|
4
|
+
* Functions for parsing and converting between local and UTC times.
|
|
5
|
+
* All functions require explicit timezone parameters.
|
|
6
|
+
*
|
|
7
|
+
* @module datetime/parse
|
|
8
|
+
*/
|
|
9
|
+
import { format, parse } from 'date-fns';
|
|
10
|
+
import { fromZonedTime, toZonedTime } from 'date-fns-tz';
|
|
11
|
+
import { DATE_FORMATS } from './constants';
|
|
12
|
+
import { isValidTimezone } from './timezone';
|
|
13
|
+
import { DateTimeError, DateTimeErrorCode } from './types';
|
|
14
|
+
/**
|
|
15
|
+
* Validates and ensures timezone is valid.
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
function validateTimezone(timezone) {
|
|
19
|
+
if (!isValidTimezone(timezone)) {
|
|
20
|
+
throw new DateTimeError(`Invalid timezone: ${timezone}`, DateTimeErrorCode.INVALID_TIMEZONE, { timezone });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Validates a date string in YYYY-MM-DD format.
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
function validateDateString(dateStr) {
|
|
28
|
+
if (!dateStr || typeof dateStr !== 'string') {
|
|
29
|
+
throw new DateTimeError('Date string is required', DateTimeErrorCode.INVALID_DATE, { value: dateStr });
|
|
30
|
+
}
|
|
31
|
+
const dateRegex = /^\d{4}-\d{2}-\d{2}$/;
|
|
32
|
+
if (!dateRegex.test(dateStr)) {
|
|
33
|
+
throw new DateTimeError(`Invalid date format: ${dateStr}. Expected YYYY-MM-DD`, DateTimeErrorCode.INVALID_DATE, { value: dateStr });
|
|
34
|
+
}
|
|
35
|
+
// Verify it's a valid date
|
|
36
|
+
const [year, month, day] = dateStr.split('-').map(Number);
|
|
37
|
+
const date = new Date(year, month - 1, day);
|
|
38
|
+
if (date.getFullYear() !== year ||
|
|
39
|
+
date.getMonth() !== month - 1 ||
|
|
40
|
+
date.getDate() !== day) {
|
|
41
|
+
throw new DateTimeError(`Invalid date: ${dateStr}`, DateTimeErrorCode.INVALID_DATE, { value: dateStr });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Validates a time string in HH:mm or HH:mm:ss format.
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
function validateTimeString(timeStr) {
|
|
49
|
+
if (!timeStr || typeof timeStr !== 'string') {
|
|
50
|
+
throw new DateTimeError('Time string is required', DateTimeErrorCode.INVALID_TIME, { value: timeStr });
|
|
51
|
+
}
|
|
52
|
+
const timeRegex = /^([01]\d|2[0-3]):([0-5]\d)(:[0-5]\d)?$/;
|
|
53
|
+
if (!timeRegex.test(timeStr)) {
|
|
54
|
+
throw new DateTimeError(`Invalid time format: ${timeStr}. Expected HH:mm or HH:mm:ss`, DateTimeErrorCode.INVALID_TIME, { value: timeStr });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Converts a local datetime string to UTC ISO string.
|
|
59
|
+
*
|
|
60
|
+
* @param localDateTime - Local datetime string (e.g., '2023-12-25T19:00:00')
|
|
61
|
+
* @param timezone - IANA timezone ID
|
|
62
|
+
* @returns UTC ISO string (e.g., '2023-12-26T03:00:00Z')
|
|
63
|
+
* @throws {DateTimeError} If timezone or datetime is invalid
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* parseLocalToUTC('2023-12-25T19:00:00', 'America/Los_Angeles')
|
|
67
|
+
* // '2023-12-26T03:00:00Z' (7 PM LA = 3 AM next day UTC)
|
|
68
|
+
*/
|
|
69
|
+
export function parseLocalToUTC(localDateTime, timezone) {
|
|
70
|
+
validateTimezone(timezone);
|
|
71
|
+
if (!localDateTime || typeof localDateTime !== 'string') {
|
|
72
|
+
throw new DateTimeError('Local datetime is required', DateTimeErrorCode.PARSE_ERROR, { value: localDateTime });
|
|
73
|
+
}
|
|
74
|
+
// Parse the local datetime string
|
|
75
|
+
const localDate = new Date(localDateTime);
|
|
76
|
+
if (isNaN(localDate.getTime())) {
|
|
77
|
+
throw new DateTimeError(`Invalid local datetime: ${localDateTime}`, DateTimeErrorCode.PARSE_ERROR, { value: localDateTime });
|
|
78
|
+
}
|
|
79
|
+
// Convert from zoned time to UTC
|
|
80
|
+
const utcDate = fromZonedTime(localDate, timezone);
|
|
81
|
+
return utcDate.toISOString();
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Converts a UTC ISO string to local datetime string.
|
|
85
|
+
*
|
|
86
|
+
* @param utcIso - UTC ISO string (e.g., '2023-12-26T03:00:00Z')
|
|
87
|
+
* @param timezone - IANA timezone ID
|
|
88
|
+
* @returns Local datetime string without timezone (e.g., '2023-12-25T19:00:00')
|
|
89
|
+
* @throws {DateTimeError} If timezone or ISO string is invalid
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* parseUTCToLocal('2023-12-26T03:00:00Z', 'America/Los_Angeles')
|
|
93
|
+
* // '2023-12-25T19:00:00' (3 AM UTC = 7 PM previous day LA)
|
|
94
|
+
*/
|
|
95
|
+
export function parseUTCToLocal(utcIso, timezone) {
|
|
96
|
+
validateTimezone(timezone);
|
|
97
|
+
if (!utcIso || typeof utcIso !== 'string') {
|
|
98
|
+
throw new DateTimeError('UTC ISO string is required', DateTimeErrorCode.INVALID_ISO_STRING, { value: utcIso });
|
|
99
|
+
}
|
|
100
|
+
const date = new Date(utcIso);
|
|
101
|
+
if (isNaN(date.getTime())) {
|
|
102
|
+
throw new DateTimeError(`Invalid UTC ISO string: ${utcIso}`, DateTimeErrorCode.INVALID_ISO_STRING, { value: utcIso });
|
|
103
|
+
}
|
|
104
|
+
// Convert to zoned time
|
|
105
|
+
const zonedDate = toZonedTime(date, timezone);
|
|
106
|
+
// Format as local datetime string (without timezone info)
|
|
107
|
+
return format(zonedDate, "yyyy-MM-dd'T'HH:mm:ss");
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Combines a date string and time string into a UTC ISO string.
|
|
111
|
+
*
|
|
112
|
+
* @param date - Date string in YYYY-MM-DD format
|
|
113
|
+
* @param time - Time string in HH:mm or HH:mm:ss format
|
|
114
|
+
* @param timezone - IANA timezone ID
|
|
115
|
+
* @returns UTC ISO string
|
|
116
|
+
* @throws {DateTimeError} If any input is invalid
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* combineDateAndTime('2023-12-25', '19:00', 'America/Los_Angeles')
|
|
120
|
+
* // '2023-12-26T03:00:00Z'
|
|
121
|
+
*/
|
|
122
|
+
export function combineDateAndTime(date, time, timezone) {
|
|
123
|
+
validateTimezone(timezone);
|
|
124
|
+
validateDateString(date);
|
|
125
|
+
validateTimeString(time);
|
|
126
|
+
// Ensure time has seconds
|
|
127
|
+
const normalizedTime = time.length === 5 ? `${time}:00` : time;
|
|
128
|
+
const localDateTime = `${date}T${normalizedTime}`;
|
|
129
|
+
return parseLocalToUTC(localDateTime, timezone);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Parses a UTC ISO string into separate date and time components.
|
|
133
|
+
*
|
|
134
|
+
* @param utcIso - UTC ISO string
|
|
135
|
+
* @param timezone - IANA timezone ID
|
|
136
|
+
* @returns Object with date (YYYY-MM-DD) and time (HH:mm) strings in local timezone
|
|
137
|
+
* @throws {DateTimeError} If inputs are invalid
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* parseDateTimeFromAPI('2023-12-26T03:00:00Z', 'America/Los_Angeles')
|
|
141
|
+
* // { date: '2023-12-25', time: '19:00' }
|
|
142
|
+
*/
|
|
143
|
+
export function parseDateTimeFromAPI(utcIso, timezone) {
|
|
144
|
+
validateTimezone(timezone);
|
|
145
|
+
if (!utcIso || typeof utcIso !== 'string') {
|
|
146
|
+
throw new DateTimeError('UTC ISO string is required', DateTimeErrorCode.INVALID_ISO_STRING, { value: utcIso });
|
|
147
|
+
}
|
|
148
|
+
const date = new Date(utcIso);
|
|
149
|
+
if (isNaN(date.getTime())) {
|
|
150
|
+
throw new DateTimeError(`Invalid UTC ISO string: ${utcIso}`, DateTimeErrorCode.INVALID_ISO_STRING, { value: utcIso });
|
|
151
|
+
}
|
|
152
|
+
const zonedDate = toZonedTime(date, timezone);
|
|
153
|
+
return {
|
|
154
|
+
date: format(zonedDate, DATE_FORMATS.API_DATE),
|
|
155
|
+
time: format(zonedDate, DATE_FORMATS.TIME_24H),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Formats a Date object for API submission (UTC ISO string).
|
|
160
|
+
*
|
|
161
|
+
* @param date - JavaScript Date object
|
|
162
|
+
* @returns UTC ISO string
|
|
163
|
+
* @throws {DateTimeError} If date is invalid
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* formatDateTimeForAPI(new Date('2023-12-25T19:00:00-08:00'))
|
|
167
|
+
* // '2023-12-26T03:00:00Z'
|
|
168
|
+
*/
|
|
169
|
+
export function formatDateTimeForAPI(date) {
|
|
170
|
+
if (!(date instanceof Date) || isNaN(date.getTime())) {
|
|
171
|
+
throw new DateTimeError('Valid Date object is required', DateTimeErrorCode.INVALID_DATE, { value: date });
|
|
172
|
+
}
|
|
173
|
+
return date.toISOString();
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Parses a date-only string and returns start of day in UTC.
|
|
177
|
+
*
|
|
178
|
+
* @param dateStr - Date string in YYYY-MM-DD format
|
|
179
|
+
* @param timezone - IANA timezone ID
|
|
180
|
+
* @returns UTC ISO string for start of day
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* parseStartOfDay('2023-12-25', 'America/Los_Angeles')
|
|
184
|
+
* // '2023-12-25T08:00:00Z' (midnight LA = 8 AM UTC)
|
|
185
|
+
*/
|
|
186
|
+
export function parseStartOfDay(dateStr, timezone) {
|
|
187
|
+
return combineDateAndTime(dateStr, '00:00', timezone);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Parses a date-only string and returns end of day in UTC.
|
|
191
|
+
*
|
|
192
|
+
* @param dateStr - Date string in YYYY-MM-DD format
|
|
193
|
+
* @param timezone - IANA timezone ID
|
|
194
|
+
* @returns UTC ISO string for end of day (23:59:59)
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* parseEndOfDay('2023-12-25', 'America/Los_Angeles')
|
|
198
|
+
* // '2023-12-26T07:59:59Z' (11:59:59 PM LA = 7:59:59 AM next day UTC)
|
|
199
|
+
*/
|
|
200
|
+
export function parseEndOfDay(dateStr, timezone) {
|
|
201
|
+
return combineDateAndTime(dateStr, '23:59:59', timezone);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Checks if a time string indicates next-day time (has +1_ prefix).
|
|
205
|
+
* This is a MicDrop convention for overnight events.
|
|
206
|
+
*
|
|
207
|
+
* @param timeStr - Time string that may have +1_ prefix
|
|
208
|
+
* @returns true if it's a next-day time
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* isNextDayTime('+1_02:00') // true
|
|
212
|
+
* isNextDayTime('14:00') // false
|
|
213
|
+
*/
|
|
214
|
+
export function isNextDayTime(timeStr) {
|
|
215
|
+
return timeStr?.startsWith('+1_') || false;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Strips the next-day prefix from a time string.
|
|
219
|
+
*
|
|
220
|
+
* @param timeStr - Time string that may have +1_ prefix
|
|
221
|
+
* @returns Time string without prefix
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* stripNextDayPrefix('+1_02:00') // '02:00'
|
|
225
|
+
* stripNextDayPrefix('14:00') // '14:00'
|
|
226
|
+
*/
|
|
227
|
+
export function stripNextDayPrefix(timeStr) {
|
|
228
|
+
if (isNextDayTime(timeStr)) {
|
|
229
|
+
return timeStr.slice(3);
|
|
230
|
+
}
|
|
231
|
+
return timeStr;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Converts a time string to minutes since midnight.
|
|
235
|
+
*
|
|
236
|
+
* @param timeStr - Time string in HH:mm format (may have +1_ prefix)
|
|
237
|
+
* @returns Minutes since midnight (0-1439 for same day, 1440+ for next day)
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* parseTimeToMinutes('14:30') // 870
|
|
241
|
+
* parseTimeToMinutes('+1_02:00') // 1560 (26 hours = 1560 minutes)
|
|
242
|
+
*/
|
|
243
|
+
export function parseTimeToMinutes(timeStr) {
|
|
244
|
+
const isNextDay = isNextDayTime(timeStr);
|
|
245
|
+
const cleanTime = stripNextDayPrefix(timeStr);
|
|
246
|
+
validateTimeString(cleanTime);
|
|
247
|
+
const [hours, minutes] = cleanTime.split(':').map(Number);
|
|
248
|
+
let totalMinutes = hours * 60 + minutes;
|
|
249
|
+
if (isNextDay) {
|
|
250
|
+
totalMinutes += 24 * 60;
|
|
251
|
+
}
|
|
252
|
+
return totalMinutes;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Converts minutes since midnight to a time string.
|
|
256
|
+
*
|
|
257
|
+
* @param minutes - Minutes since midnight
|
|
258
|
+
* @param includeNextDayPrefix - If true and minutes >= 1440, adds +1_ prefix
|
|
259
|
+
* @returns Time string in HH:mm format
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* minutesToTimeString(870) // '14:30'
|
|
263
|
+
* minutesToTimeString(1560, true) // '+1_02:00'
|
|
264
|
+
* minutesToTimeString(1560, false) // '02:00'
|
|
265
|
+
*/
|
|
266
|
+
export function minutesToTimeString(minutes, includeNextDayPrefix = false) {
|
|
267
|
+
const isNextDay = minutes >= 24 * 60;
|
|
268
|
+
const normalizedMinutes = minutes % (24 * 60);
|
|
269
|
+
const hours = Math.floor(normalizedMinutes / 60);
|
|
270
|
+
const mins = normalizedMinutes % 60;
|
|
271
|
+
const timeStr = `${hours.toString().padStart(2, '0')}:${mins.toString().padStart(2, '0')}`;
|
|
272
|
+
if (isNextDay && includeNextDayPrefix) {
|
|
273
|
+
return `+1_${timeStr}`;
|
|
274
|
+
}
|
|
275
|
+
return timeStr;
|
|
276
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timezone Utilities
|
|
3
|
+
*
|
|
4
|
+
* Functions for working with IANA timezones.
|
|
5
|
+
* All timezone operations require explicit timezone IDs - no defaults.
|
|
6
|
+
*
|
|
7
|
+
* @module datetime/timezone
|
|
8
|
+
*/
|
|
9
|
+
import type { TimezoneId, VenueWithTimezone } from './types';
|
|
10
|
+
/**
|
|
11
|
+
* Validates whether a string is a valid IANA timezone identifier.
|
|
12
|
+
* Rejects common abbreviations like PST, EST, etc. even if the runtime accepts them.
|
|
13
|
+
*
|
|
14
|
+
* @param timezone - The timezone string to validate
|
|
15
|
+
* @returns true if valid IANA timezone, false otherwise
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* isValidTimezone('America/Los_Angeles') // true
|
|
19
|
+
* isValidTimezone('PST') // false (abbreviations not valid)
|
|
20
|
+
* isValidTimezone('Invalid/Zone') // false
|
|
21
|
+
*/
|
|
22
|
+
export declare function isValidTimezone(timezone: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Extracts the timezone from a venue object.
|
|
25
|
+
* Throws if the venue doesn't have a valid timezone.
|
|
26
|
+
*
|
|
27
|
+
* @param venue - Venue object with optional timezone property
|
|
28
|
+
* @returns The venue's timezone ID
|
|
29
|
+
* @throws {DateTimeError} If venue timezone is missing or invalid
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* const tz = getVenueTimezone({ timezone: 'America/Los_Angeles' });
|
|
33
|
+
* // tz === 'America/Los_Angeles'
|
|
34
|
+
*
|
|
35
|
+
* getVenueTimezone({}) // throws DateTimeError
|
|
36
|
+
*/
|
|
37
|
+
export declare function getVenueTimezone(venue: VenueWithTimezone): TimezoneId;
|
|
38
|
+
/**
|
|
39
|
+
* Gets the user's browser/system timezone.
|
|
40
|
+
*
|
|
41
|
+
* @returns The user's IANA timezone ID
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* const userTz = getUserTimezone();
|
|
45
|
+
* // e.g., 'America/Los_Angeles'
|
|
46
|
+
*/
|
|
47
|
+
export declare function getUserTimezone(): TimezoneId;
|
|
48
|
+
/**
|
|
49
|
+
* Gets a human-readable timezone offset string.
|
|
50
|
+
*
|
|
51
|
+
* @param timezone - IANA timezone ID
|
|
52
|
+
* @param date - Optional date for DST-aware offset (defaults to now)
|
|
53
|
+
* @returns Formatted offset string (e.g., "PST (UTC-8)" or "PDT (UTC-7)")
|
|
54
|
+
* @throws {DateTimeError} If timezone is invalid
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* getTimezoneOffset('America/Los_Angeles')
|
|
58
|
+
* // "PST (UTC-8)" in winter, "PDT (UTC-7)" in summer
|
|
59
|
+
*/
|
|
60
|
+
export declare function getTimezoneOffset(timezone: TimezoneId, date?: Date): string;
|
|
61
|
+
/**
|
|
62
|
+
* Gets the display name for a timezone.
|
|
63
|
+
*
|
|
64
|
+
* @param timezone - IANA timezone ID
|
|
65
|
+
* @returns Human-readable timezone name
|
|
66
|
+
* @throws {DateTimeError} If timezone is invalid
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* getTimezoneDisplayName('America/Los_Angeles')
|
|
70
|
+
* // "Pacific Time"
|
|
71
|
+
*/
|
|
72
|
+
export declare function getTimezoneDisplayName(timezone: TimezoneId): string;
|
|
73
|
+
/**
|
|
74
|
+
* Normalizes legacy or non-standard timezone strings to valid IANA IDs.
|
|
75
|
+
* This is useful for handling user input or legacy data.
|
|
76
|
+
*
|
|
77
|
+
* @param timezone - Timezone string that may be non-standard
|
|
78
|
+
* @returns Valid IANA timezone ID
|
|
79
|
+
* @throws {DateTimeError} If timezone cannot be normalized
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* normalizeTimezone('PST') // might return 'America/Los_Angeles'
|
|
83
|
+
* normalizeTimezone('Eastern') // might return 'America/New_York'
|
|
84
|
+
*/
|
|
85
|
+
export declare function normalizeTimezone(timezone: string): TimezoneId;
|
|
86
|
+
/**
|
|
87
|
+
* Checks if a timezone is currently observing Daylight Saving Time.
|
|
88
|
+
*
|
|
89
|
+
* @param timezone - IANA timezone ID
|
|
90
|
+
* @param date - Date to check (defaults to now)
|
|
91
|
+
* @returns true if DST is in effect
|
|
92
|
+
* @throws {DateTimeError} If timezone is invalid
|
|
93
|
+
*/
|
|
94
|
+
export declare function isDST(timezone: TimezoneId, date?: Date): boolean;
|
|
95
|
+
//# sourceMappingURL=timezone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timezone.d.ts","sourceRoot":"","sources":["../../src/lib/datetime/timezone.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAiC7D;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CA0BzD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,GAAG,UAAU,CAoBrE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,IAAI,UAAU,CAE5C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,UAAU,EACpB,IAAI,GAAE,IAAiB,GACtB,MAAM,CA2BR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,UAAU,GAAG,MAAM,CAiBnE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CA+C9D;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,GAAE,IAAiB,GAAG,OAAO,CA0B5E"}
|