@zimyo/ui 1.0.2 → 1.1.0
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/package.json +78 -83
- package/dist/components/index.d.ts +0 -60
- package/dist/components/ui/accordion.d.ts +0 -10
- package/dist/components/ui/accordion.js +0 -58
- package/dist/components/ui/alert-dialog.d.ts +0 -17
- package/dist/components/ui/alert-dialog.js +0 -108
- package/dist/components/ui/alert.d.ts +0 -13
- package/dist/components/ui/alert.js +0 -52
- package/dist/components/ui/aspect-ratio.d.ts +0 -6
- package/dist/components/ui/aspect-ratio.js +0 -12
- package/dist/components/ui/avatar.d.ts +0 -9
- package/dist/components/ui/avatar.js +0 -37
- package/dist/components/ui/badge.d.ts +0 -13
- package/dist/components/ui/badge.js +0 -36
- package/dist/components/ui/breadcrumb.d.ts +0 -14
- package/dist/components/ui/breadcrumb.js +0 -94
- package/dist/components/ui/button.d.ts +0 -14
- package/dist/components/ui/button.js +0 -48
- package/dist/components/ui/calendar.d.ts +0 -13
- package/dist/components/ui/calendar.js +0 -137
- package/dist/components/ui/card.d.ts +0 -12
- package/dist/components/ui/card.js +0 -76
- package/dist/components/ui/carousel.d.ts +0 -25
- package/dist/components/ui/carousel.js +0 -173
- package/dist/components/ui/chart.d.ts +0 -44
- package/dist/components/ui/chart.js +0 -203
- package/dist/components/ui/checkbox.d.ts +0 -7
- package/dist/components/ui/checkbox.js +0 -26
- package/dist/components/ui/collapsible.d.ts +0 -8
- package/dist/components/ui/collapsible.js +0 -24
- package/dist/components/ui/command.d.ts +0 -22
- package/dist/components/ui/command.js +0 -119
- package/dist/components/ui/context-menu.d.ts +0 -28
- package/dist/components/ui/context-menu.js +0 -171
- package/dist/components/ui/dialog.d.ts +0 -18
- package/dist/components/ui/dialog.js +0 -106
- package/dist/components/ui/drawer.d.ts +0 -16
- package/dist/components/ui/drawer.js +0 -99
- package/dist/components/ui/dropdown-menu.d.ts +0 -28
- package/dist/components/ui/dropdown-menu.js +0 -173
- package/dist/components/ui/form.d.ts +0 -27
- package/dist/components/ui/form.js +0 -129
- package/dist/components/ui/hover-card.d.ts +0 -9
- package/dist/components/ui/hover-card.js +0 -36
- package/dist/components/ui/input-otp.d.ts +0 -14
- package/dist/components/ui/input-otp.js +0 -66
- package/dist/components/ui/input.d.ts +0 -6
- package/dist/components/ui/input.js +0 -18
- package/dist/components/ui/label.d.ts +0 -7
- package/dist/components/ui/label.js +0 -17
- package/dist/components/ui/menubar.d.ts +0 -29
- package/dist/components/ui/menubar.js +0 -191
- package/dist/components/ui/navigation-menu.d.ts +0 -18
- package/dist/components/ui/navigation-menu.js +0 -108
- package/dist/components/ui/pagination.d.ts +0 -18
- package/dist/components/ui/pagination.js +0 -103
- package/dist/components/ui/popover.d.ts +0 -10
- package/dist/components/ui/popover.js +0 -41
- package/dist/components/ui/progress.d.ts +0 -7
- package/dist/components/ui/progress.js +0 -26
- package/dist/components/ui/radio-group.d.ts +0 -8
- package/dist/components/ui/radio-group.js +0 -36
- package/dist/components/ui/resizable.d.ts +0 -11
- package/dist/components/ui/resizable.js +0 -42
- package/dist/components/ui/scroll-area.d.ts +0 -8
- package/dist/components/ui/scroll-area.js +0 -41
- package/dist/components/ui/select.d.ts +0 -18
- package/dist/components/ui/select.js +0 -136
- package/dist/components/ui/separator.d.ts +0 -7
- package/dist/components/ui/separator.js +0 -21
- package/dist/components/ui/sheet.d.ts +0 -16
- package/dist/components/ui/sheet.js +0 -106
- package/dist/components/ui/sidebar.d.ts +0 -74
- package/dist/components/ui/sidebar.js +0 -511
- package/dist/components/ui/skeleton.d.ts +0 -5
- package/dist/components/ui/skeleton.js +0 -16
- package/dist/components/ui/slider.d.ts +0 -7
- package/dist/components/ui/slider.js +0 -41
- package/dist/components/ui/sonner.d.ts +0 -6
- package/dist/components/ui/sonner.js +0 -18
- package/dist/components/ui/switch.d.ts +0 -7
- package/dist/components/ui/switch.js +0 -22
- package/dist/components/ui/table.d.ts +0 -13
- package/dist/components/ui/table.js +0 -90
- package/dist/components/ui/tabs.d.ts +0 -10
- package/dist/components/ui/tabs.js +0 -47
- package/dist/components/ui/textarea.d.ts +0 -6
- package/dist/components/ui/textarea.js +0 -16
- package/dist/components/ui/toggle-group.d.ts +0 -11
- package/dist/components/ui/toggle-group.js +0 -57
- package/dist/components/ui/toggle.d.ts +0 -13
- package/dist/components/ui/toggle.js +0 -41
- package/dist/components/ui/tooltip.d.ts +0 -10
- package/dist/components/ui/tooltip.js +0 -50
- package/dist/index.d.ts +0 -63
- package/dist/index.js +0 -48
- package/dist/lib/utils.d.ts +0 -5
- package/dist/lib/utils.js +0 -8
- package/dist/node_modules/@date-fns/tz/date/index.js +0 -101
- package/dist/node_modules/@date-fns/tz/date/mini.js +0 -207
- package/dist/node_modules/@date-fns/tz/tzOffset/index.js +0 -43
- package/dist/node_modules/@radix-ui/primitive/dist/index.js +0 -11
- package/dist/node_modules/@radix-ui/react-compose-refs/dist/index.js +0 -39
- package/dist/node_modules/@radix-ui/react-context/dist/index.js +0 -79
- package/dist/node_modules/@radix-ui/react-dialog/dist/index.js +0 -321
- package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +0 -211
- package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.js +0 -29
- package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.js +0 -207
- package/dist/node_modules/@radix-ui/react-id/dist/index.js +0 -15
- package/dist/node_modules/@radix-ui/react-portal/dist/index.js +0 -17
- package/dist/node_modules/@radix-ui/react-presence/dist/index.js +0 -130
- package/dist/node_modules/@radix-ui/react-primitive/dist/index.js +0 -43
- package/dist/node_modules/@radix-ui/react-slot/dist/index.js +0 -89
- package/dist/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +0 -12
- package/dist/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +0 -70
- package/dist/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +0 -18
- package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +0 -7
- package/dist/node_modules/aria-hidden/dist/es2015/index.js +0 -137
- package/dist/node_modules/class-variance-authority/dist/index.js +0 -44
- package/dist/node_modules/clsx/dist/clsx.js +0 -3
- package/dist/node_modules/cmdk/dist/chunk-NZJY6EH4.js +0 -3
- package/dist/node_modules/cmdk/dist/index.js +0 -10
- package/dist/node_modules/date-fns/_lib/addLeadingZeros.js +0 -7
- package/dist/node_modules/date-fns/_lib/defaultOptions.js +0 -7
- package/dist/node_modules/date-fns/_lib/format/formatters.js +0 -775
- package/dist/node_modules/date-fns/_lib/format/lightFormatters.js +0 -94
- package/dist/node_modules/date-fns/_lib/format/longFormatters.js +0 -66
- package/dist/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js +0 -31
- package/dist/node_modules/date-fns/_lib/normalizeDates.js +0 -11
- package/dist/node_modules/date-fns/_lib/normalizeInterval.js +0 -8
- package/dist/node_modules/date-fns/_lib/protectedTokens.js +0 -25
- package/dist/node_modules/date-fns/addDays.js +0 -41
- package/dist/node_modules/date-fns/addMonths.js +0 -75
- package/dist/node_modules/date-fns/addWeeks.js +0 -33
- package/dist/node_modules/date-fns/addYears.js +0 -33
- package/dist/node_modules/date-fns/constants.js +0 -46
- package/dist/node_modules/date-fns/constructFrom.js +0 -49
- package/dist/node_modules/date-fns/differenceInCalendarDays.js +0 -62
- package/dist/node_modules/date-fns/differenceInCalendarMonths.js +0 -42
- package/dist/node_modules/date-fns/eachMonthOfInterval.js +0 -65
- package/dist/node_modules/date-fns/endOfISOWeek.js +0 -35
- package/dist/node_modules/date-fns/endOfMonth.js +0 -37
- package/dist/node_modules/date-fns/endOfWeek.js +0 -53
- package/dist/node_modules/date-fns/endOfYear.js +0 -37
- package/dist/node_modules/date-fns/format.js +0 -423
- package/dist/node_modules/date-fns/getDayOfYear.js +0 -34
- package/dist/node_modules/date-fns/getDaysInMonth.js +0 -36
- package/dist/node_modules/date-fns/getISOWeek.js +0 -40
- package/dist/node_modules/date-fns/getISOWeekYear.js +0 -52
- package/dist/node_modules/date-fns/getMonth.js +0 -29
- package/dist/node_modules/date-fns/getWeek.js +0 -54
- package/dist/node_modules/date-fns/getWeekYear.js +0 -75
- package/dist/node_modules/date-fns/getYear.js +0 -29
- package/dist/node_modules/date-fns/isAfter.js +0 -25
- package/dist/node_modules/date-fns/isBefore.js +0 -25
- package/dist/node_modules/date-fns/isDate.js +0 -41
- package/dist/node_modules/date-fns/isSameDay.js +0 -46
- package/dist/node_modules/date-fns/isSameMonth.js +0 -43
- package/dist/node_modules/date-fns/isSameYear.js +0 -35
- package/dist/node_modules/date-fns/isValid.js +0 -39
- package/dist/node_modules/date-fns/locale/_lib/buildFormatLongFn.js +0 -10
- package/dist/node_modules/date-fns/locale/_lib/buildLocalizeFn.js +0 -64
- package/dist/node_modules/date-fns/locale/_lib/buildMatchFn.js +0 -59
- package/dist/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js +0 -22
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatDistance.js +0 -103
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatLong.js +0 -41
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatRelative.js +0 -13
- package/dist/node_modules/date-fns/locale/en-US/_lib/localize.js +0 -189
- package/dist/node_modules/date-fns/locale/en-US/_lib/match.js +0 -134
- package/dist/node_modules/date-fns/locale/en-US.js +0 -28
- package/dist/node_modules/date-fns/max.js +0 -49
- package/dist/node_modules/date-fns/min.js +0 -49
- package/dist/node_modules/date-fns/setMonth.js +0 -46
- package/dist/node_modules/date-fns/setYear.js +0 -40
- package/dist/node_modules/date-fns/startOfDay.js +0 -35
- package/dist/node_modules/date-fns/startOfISOWeek.js +0 -35
- package/dist/node_modules/date-fns/startOfISOWeekYear.js +0 -42
- package/dist/node_modules/date-fns/startOfMonth.js +0 -37
- package/dist/node_modules/date-fns/startOfWeek.js +0 -53
- package/dist/node_modules/date-fns/startOfWeekYear.js +0 -64
- package/dist/node_modules/date-fns/startOfYear.js +0 -36
- package/dist/node_modules/date-fns/toDate.js +0 -46
- package/dist/node_modules/embla-carousel/esm/embla-carousel.esm.js +0 -1669
- package/dist/node_modules/embla-carousel-react/esm/embla-carousel-react.esm.js +0 -37
- package/dist/node_modules/embla-carousel-reactive-utils/esm/embla-carousel-reactive-utils.esm.js +0 -38
- package/dist/node_modules/get-nonce/dist/es2015/index.js +0 -8
- package/dist/node_modules/input-otp/dist/index.js +0 -24
- package/dist/node_modules/react-day-picker/dist/esm/DayPicker.js +0 -285
- package/dist/node_modules/react-day-picker/dist/esm/UI.js +0 -122
- package/dist/node_modules/react-day-picker/dist/esm/classes/CalendarDay.js +0 -30
- package/dist/node_modules/react-day-picker/dist/esm/classes/CalendarMonth.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/classes/CalendarWeek.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/classes/DateLib.js +0 -522
- package/dist/node_modules/react-day-picker/dist/esm/components/Button.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/CaptionLabel.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/Chevron.js +0 -18
- package/dist/node_modules/react-day-picker/dist/esm/components/Day.js +0 -18
- package/dist/node_modules/react-day-picker/dist/esm/components/DayButton.js +0 -19
- package/dist/node_modules/react-day-picker/dist/esm/components/Dropdown.js +0 -21
- package/dist/node_modules/react-day-picker/dist/esm/components/DropdownNav.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/Footer.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/Month.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/components/MonthCaption.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/components/MonthGrid.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/Months.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/MonthsDropdown.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/components/Nav.js +0 -31
- package/dist/node_modules/react-day-picker/dist/esm/components/NextMonthButton.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/components/Option.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/PreviousMonthButton.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/components/Root.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/components/Select.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/Week.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/components/WeekNumber.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/components/WeekNumberHeader.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/Weekday.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/Weekdays.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/components/Weeks.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/YearsDropdown.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/components/custom-components.js +0 -26
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatCaption.js +0 -25
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatDay.js +0 -19
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatMonthDropdown.js +0 -18
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatWeekNumber.js +0 -21
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatWeekNumberHeader.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatWeekdayName.js +0 -19
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatYearDropdown.js +0 -23
- package/dist/node_modules/react-day-picker/dist/esm/formatters/index.js +0 -7
- package/dist/node_modules/react-day-picker/dist/esm/helpers/calculateFocusTarget.js +0 -73
- package/dist/node_modules/react-day-picker/dist/esm/helpers/createGetModifiers.js +0 -95
- package/dist/node_modules/react-day-picker/dist/esm/helpers/endOfBroadcastWeek.js +0 -22
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getBroadcastWeeksInMonth.js +0 -28
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getClassNamesForModifiers.js +0 -33
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getComponents.js +0 -20
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getDataAttributes.js +0 -27
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getDates.js +0 -51
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getDays.js +0 -19
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getDefaultClassNames.js +0 -33
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getDisplayMonths.js +0 -24
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getFocusableDate.js +0 -46
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getFormatters.js +0 -24
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getInitialMonth.js +0 -28
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getMonthOptions.js +0 -33
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getMonths.js +0 -69
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getNavMonth.js +0 -51
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getNextFocus.js +0 -39
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getNextMonth.js +0 -36
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getPreviousMonth.js +0 -37
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getStyleForModifiers.js +0 -27
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getWeekdays.js +0 -24
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getWeeks.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getYearOptions.js +0 -38
- package/dist/node_modules/react-day-picker/dist/esm/helpers/startOfBroadcastWeek.js +0 -27
- package/dist/node_modules/react-day-picker/dist/esm/helpers/useControlledValue.js +0 -31
- package/dist/node_modules/react-day-picker/dist/esm/labels/index.js +0 -11
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelDayButton.js +0 -32
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelGrid.js +0 -24
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelGridcell.js +0 -22
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelMonthDropdown.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelNav.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelNext.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelPrevious.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelWeekNumber.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelWeekNumberHeader.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelWeekday.js +0 -18
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelYearDropdown.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/selection/useMulti.js +0 -57
- package/dist/node_modules/react-day-picker/dist/esm/selection/useRange.js +0 -45
- package/dist/node_modules/react-day-picker/dist/esm/selection/useSingle.js +0 -44
- package/dist/node_modules/react-day-picker/dist/esm/useAnimation.js +0 -175
- package/dist/node_modules/react-day-picker/dist/esm/useCalendar.js +0 -85
- package/dist/node_modules/react-day-picker/dist/esm/useDayPicker.js +0 -25
- package/dist/node_modules/react-day-picker/dist/esm/useFocus.js +0 -50
- package/dist/node_modules/react-day-picker/dist/esm/useSelection.js +0 -31
- package/dist/node_modules/react-day-picker/dist/esm/utils/addToRange.js +0 -92
- package/dist/node_modules/react-day-picker/dist/esm/utils/dateMatchModifiers.js +0 -62
- package/dist/node_modules/react-day-picker/dist/esm/utils/rangeContainsDayOfWeek.js +0 -30
- package/dist/node_modules/react-day-picker/dist/esm/utils/rangeContainsModifiers.js +0 -74
- package/dist/node_modules/react-day-picker/dist/esm/utils/rangeIncludesDate.js +0 -35
- package/dist/node_modules/react-day-picker/dist/esm/utils/rangeOverlaps.js +0 -21
- package/dist/node_modules/react-day-picker/dist/esm/utils/typeguards.js +0 -66
- package/dist/node_modules/react-hook-form/dist/index.esm.js +0 -507
- package/dist/node_modules/react-remove-scroll/dist/es2015/Combination.js +0 -9
- package/dist/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +0 -160
- package/dist/node_modules/react-remove-scroll/dist/es2015/UI.js +0 -38
- package/dist/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +0 -21
- package/dist/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +0 -110
- package/dist/node_modules/react-remove-scroll/dist/es2015/medium.js +0 -5
- package/dist/node_modules/react-remove-scroll/dist/es2015/sidecar.js +0 -7
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/component.js +0 -56
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/constants.js +0 -10
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/utils.js +0 -31
- package/dist/node_modules/react-resizable-panels/dist/react-resizable-panels.js +0 -2407
- package/dist/node_modules/react-style-singleton/dist/es2015/component.js +0 -19
- package/dist/node_modules/react-style-singleton/dist/es2015/hook.js +0 -25
- package/dist/node_modules/react-style-singleton/dist/es2015/singleton.js +0 -51
- package/dist/node_modules/sonner/dist/index.js +0 -1125
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js +0 -2956
- package/dist/node_modules/tslib/tslib.es6.js +0 -56
- package/dist/node_modules/use-callback-ref/dist/es2015/assignRef.js +0 -24
- package/dist/node_modules/use-callback-ref/dist/es2015/useMergeRef.js +0 -48
- package/dist/node_modules/use-callback-ref/dist/es2015/useRef.js +0 -42
- package/dist/node_modules/use-sidecar/dist/es2015/exports.js +0 -21
- package/dist/node_modules/use-sidecar/dist/es2015/medium.js +0 -77
- package/dist/node_modules/vaul/dist/index.js +0 -1627
- package/dist/providers/ThemeProvider.d.ts +0 -12
- package/dist/providers/ThemeProvider.js +0 -27
- package/dist/providers/index.d.ts +0 -3
- package/dist/styles.css +0 -1
|
@@ -1,775 +0,0 @@
|
|
|
1
|
-
import { getDayOfYear } from '../../getDayOfYear.js';
|
|
2
|
-
import { getISOWeek } from '../../getISOWeek.js';
|
|
3
|
-
import { getISOWeekYear } from '../../getISOWeekYear.js';
|
|
4
|
-
import { getWeek } from '../../getWeek.js';
|
|
5
|
-
import { getWeekYear } from '../../getWeekYear.js';
|
|
6
|
-
import { addLeadingZeros } from '../addLeadingZeros.js';
|
|
7
|
-
import { lightFormatters } from './lightFormatters.js';
|
|
8
|
-
|
|
9
|
-
const dayPeriodEnum = {
|
|
10
|
-
midnight: "midnight",
|
|
11
|
-
noon: "noon",
|
|
12
|
-
morning: "morning",
|
|
13
|
-
afternoon: "afternoon",
|
|
14
|
-
evening: "evening",
|
|
15
|
-
night: "night",
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/*
|
|
19
|
-
* | | Unit | | Unit |
|
|
20
|
-
* |-----|--------------------------------|-----|--------------------------------|
|
|
21
|
-
* | a | AM, PM | A* | Milliseconds in day |
|
|
22
|
-
* | b | AM, PM, noon, midnight | B | Flexible day period |
|
|
23
|
-
* | c | Stand-alone local day of week | C* | Localized hour w/ day period |
|
|
24
|
-
* | d | Day of month | D | Day of year |
|
|
25
|
-
* | e | Local day of week | E | Day of week |
|
|
26
|
-
* | f | | F* | Day of week in month |
|
|
27
|
-
* | g* | Modified Julian day | G | Era |
|
|
28
|
-
* | h | Hour [1-12] | H | Hour [0-23] |
|
|
29
|
-
* | i! | ISO day of week | I! | ISO week of year |
|
|
30
|
-
* | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
|
|
31
|
-
* | k | Hour [1-24] | K | Hour [0-11] |
|
|
32
|
-
* | l* | (deprecated) | L | Stand-alone month |
|
|
33
|
-
* | m | Minute | M | Month |
|
|
34
|
-
* | n | | N | |
|
|
35
|
-
* | o! | Ordinal number modifier | O | Timezone (GMT) |
|
|
36
|
-
* | p! | Long localized time | P! | Long localized date |
|
|
37
|
-
* | q | Stand-alone quarter | Q | Quarter |
|
|
38
|
-
* | r* | Related Gregorian year | R! | ISO week-numbering year |
|
|
39
|
-
* | s | Second | S | Fraction of second |
|
|
40
|
-
* | t! | Seconds timestamp | T! | Milliseconds timestamp |
|
|
41
|
-
* | u | Extended year | U* | Cyclic year |
|
|
42
|
-
* | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
|
|
43
|
-
* | w | Local week of year | W* | Week of month |
|
|
44
|
-
* | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
|
|
45
|
-
* | y | Year (abs) | Y | Local week-numbering year |
|
|
46
|
-
* | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
|
|
47
|
-
*
|
|
48
|
-
* Letters marked by * are not implemented but reserved by Unicode standard.
|
|
49
|
-
*
|
|
50
|
-
* Letters marked by ! are non-standard, but implemented by date-fns:
|
|
51
|
-
* - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
|
|
52
|
-
* - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
|
|
53
|
-
* i.e. 7 for Sunday, 1 for Monday, etc.
|
|
54
|
-
* - `I` is ISO week of year, as opposed to `w` which is local week of year.
|
|
55
|
-
* - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
|
|
56
|
-
* `R` is supposed to be used in conjunction with `I` and `i`
|
|
57
|
-
* for universal ISO week-numbering date, whereas
|
|
58
|
-
* `Y` is supposed to be used in conjunction with `w` and `e`
|
|
59
|
-
* for week-numbering date specific to the locale.
|
|
60
|
-
* - `P` is long localized date format
|
|
61
|
-
* - `p` is long localized time format
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
const formatters = {
|
|
65
|
-
// Era
|
|
66
|
-
G: function (date, token, localize) {
|
|
67
|
-
const era = date.getFullYear() > 0 ? 1 : 0;
|
|
68
|
-
switch (token) {
|
|
69
|
-
// AD, BC
|
|
70
|
-
case "G":
|
|
71
|
-
case "GG":
|
|
72
|
-
case "GGG":
|
|
73
|
-
return localize.era(era, { width: "abbreviated" });
|
|
74
|
-
// A, B
|
|
75
|
-
case "GGGGG":
|
|
76
|
-
return localize.era(era, { width: "narrow" });
|
|
77
|
-
// Anno Domini, Before Christ
|
|
78
|
-
case "GGGG":
|
|
79
|
-
default:
|
|
80
|
-
return localize.era(era, { width: "wide" });
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
// Year
|
|
85
|
-
y: function (date, token, localize) {
|
|
86
|
-
// Ordinal number
|
|
87
|
-
if (token === "yo") {
|
|
88
|
-
const signedYear = date.getFullYear();
|
|
89
|
-
// Returns 1 for 1 BC (which is year 0 in JavaScript)
|
|
90
|
-
const year = signedYear > 0 ? signedYear : 1 - signedYear;
|
|
91
|
-
return localize.ordinalNumber(year, { unit: "year" });
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return lightFormatters.y(date, token);
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
// Local week-numbering year
|
|
98
|
-
Y: function (date, token, localize, options) {
|
|
99
|
-
const signedWeekYear = getWeekYear(date, options);
|
|
100
|
-
// Returns 1 for 1 BC (which is year 0 in JavaScript)
|
|
101
|
-
const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
|
|
102
|
-
|
|
103
|
-
// Two digit year
|
|
104
|
-
if (token === "YY") {
|
|
105
|
-
const twoDigitYear = weekYear % 100;
|
|
106
|
-
return addLeadingZeros(twoDigitYear, 2);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Ordinal number
|
|
110
|
-
if (token === "Yo") {
|
|
111
|
-
return localize.ordinalNumber(weekYear, { unit: "year" });
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Padding
|
|
115
|
-
return addLeadingZeros(weekYear, token.length);
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
// ISO week-numbering year
|
|
119
|
-
R: function (date, token) {
|
|
120
|
-
const isoWeekYear = getISOWeekYear(date);
|
|
121
|
-
|
|
122
|
-
// Padding
|
|
123
|
-
return addLeadingZeros(isoWeekYear, token.length);
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
// Extended year. This is a single number designating the year of this calendar system.
|
|
127
|
-
// The main difference between `y` and `u` localizers are B.C. years:
|
|
128
|
-
// | Year | `y` | `u` |
|
|
129
|
-
// |------|-----|-----|
|
|
130
|
-
// | AC 1 | 1 | 1 |
|
|
131
|
-
// | BC 1 | 1 | 0 |
|
|
132
|
-
// | BC 2 | 2 | -1 |
|
|
133
|
-
// Also `yy` always returns the last two digits of a year,
|
|
134
|
-
// while `uu` pads single digit years to 2 characters and returns other years unchanged.
|
|
135
|
-
u: function (date, token) {
|
|
136
|
-
const year = date.getFullYear();
|
|
137
|
-
return addLeadingZeros(year, token.length);
|
|
138
|
-
},
|
|
139
|
-
|
|
140
|
-
// Quarter
|
|
141
|
-
Q: function (date, token, localize) {
|
|
142
|
-
const quarter = Math.ceil((date.getMonth() + 1) / 3);
|
|
143
|
-
switch (token) {
|
|
144
|
-
// 1, 2, 3, 4
|
|
145
|
-
case "Q":
|
|
146
|
-
return String(quarter);
|
|
147
|
-
// 01, 02, 03, 04
|
|
148
|
-
case "QQ":
|
|
149
|
-
return addLeadingZeros(quarter, 2);
|
|
150
|
-
// 1st, 2nd, 3rd, 4th
|
|
151
|
-
case "Qo":
|
|
152
|
-
return localize.ordinalNumber(quarter, { unit: "quarter" });
|
|
153
|
-
// Q1, Q2, Q3, Q4
|
|
154
|
-
case "QQQ":
|
|
155
|
-
return localize.quarter(quarter, {
|
|
156
|
-
width: "abbreviated",
|
|
157
|
-
context: "formatting",
|
|
158
|
-
});
|
|
159
|
-
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
|
|
160
|
-
case "QQQQQ":
|
|
161
|
-
return localize.quarter(quarter, {
|
|
162
|
-
width: "narrow",
|
|
163
|
-
context: "formatting",
|
|
164
|
-
});
|
|
165
|
-
// 1st quarter, 2nd quarter, ...
|
|
166
|
-
case "QQQQ":
|
|
167
|
-
default:
|
|
168
|
-
return localize.quarter(quarter, {
|
|
169
|
-
width: "wide",
|
|
170
|
-
context: "formatting",
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
// Stand-alone quarter
|
|
176
|
-
q: function (date, token, localize) {
|
|
177
|
-
const quarter = Math.ceil((date.getMonth() + 1) / 3);
|
|
178
|
-
switch (token) {
|
|
179
|
-
// 1, 2, 3, 4
|
|
180
|
-
case "q":
|
|
181
|
-
return String(quarter);
|
|
182
|
-
// 01, 02, 03, 04
|
|
183
|
-
case "qq":
|
|
184
|
-
return addLeadingZeros(quarter, 2);
|
|
185
|
-
// 1st, 2nd, 3rd, 4th
|
|
186
|
-
case "qo":
|
|
187
|
-
return localize.ordinalNumber(quarter, { unit: "quarter" });
|
|
188
|
-
// Q1, Q2, Q3, Q4
|
|
189
|
-
case "qqq":
|
|
190
|
-
return localize.quarter(quarter, {
|
|
191
|
-
width: "abbreviated",
|
|
192
|
-
context: "standalone",
|
|
193
|
-
});
|
|
194
|
-
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
|
|
195
|
-
case "qqqqq":
|
|
196
|
-
return localize.quarter(quarter, {
|
|
197
|
-
width: "narrow",
|
|
198
|
-
context: "standalone",
|
|
199
|
-
});
|
|
200
|
-
// 1st quarter, 2nd quarter, ...
|
|
201
|
-
case "qqqq":
|
|
202
|
-
default:
|
|
203
|
-
return localize.quarter(quarter, {
|
|
204
|
-
width: "wide",
|
|
205
|
-
context: "standalone",
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
},
|
|
209
|
-
|
|
210
|
-
// Month
|
|
211
|
-
M: function (date, token, localize) {
|
|
212
|
-
const month = date.getMonth();
|
|
213
|
-
switch (token) {
|
|
214
|
-
case "M":
|
|
215
|
-
case "MM":
|
|
216
|
-
return lightFormatters.M(date, token);
|
|
217
|
-
// 1st, 2nd, ..., 12th
|
|
218
|
-
case "Mo":
|
|
219
|
-
return localize.ordinalNumber(month + 1, { unit: "month" });
|
|
220
|
-
// Jan, Feb, ..., Dec
|
|
221
|
-
case "MMM":
|
|
222
|
-
return localize.month(month, {
|
|
223
|
-
width: "abbreviated",
|
|
224
|
-
context: "formatting",
|
|
225
|
-
});
|
|
226
|
-
// J, F, ..., D
|
|
227
|
-
case "MMMMM":
|
|
228
|
-
return localize.month(month, {
|
|
229
|
-
width: "narrow",
|
|
230
|
-
context: "formatting",
|
|
231
|
-
});
|
|
232
|
-
// January, February, ..., December
|
|
233
|
-
case "MMMM":
|
|
234
|
-
default:
|
|
235
|
-
return localize.month(month, { width: "wide", context: "formatting" });
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
|
|
239
|
-
// Stand-alone month
|
|
240
|
-
L: function (date, token, localize) {
|
|
241
|
-
const month = date.getMonth();
|
|
242
|
-
switch (token) {
|
|
243
|
-
// 1, 2, ..., 12
|
|
244
|
-
case "L":
|
|
245
|
-
return String(month + 1);
|
|
246
|
-
// 01, 02, ..., 12
|
|
247
|
-
case "LL":
|
|
248
|
-
return addLeadingZeros(month + 1, 2);
|
|
249
|
-
// 1st, 2nd, ..., 12th
|
|
250
|
-
case "Lo":
|
|
251
|
-
return localize.ordinalNumber(month + 1, { unit: "month" });
|
|
252
|
-
// Jan, Feb, ..., Dec
|
|
253
|
-
case "LLL":
|
|
254
|
-
return localize.month(month, {
|
|
255
|
-
width: "abbreviated",
|
|
256
|
-
context: "standalone",
|
|
257
|
-
});
|
|
258
|
-
// J, F, ..., D
|
|
259
|
-
case "LLLLL":
|
|
260
|
-
return localize.month(month, {
|
|
261
|
-
width: "narrow",
|
|
262
|
-
context: "standalone",
|
|
263
|
-
});
|
|
264
|
-
// January, February, ..., December
|
|
265
|
-
case "LLLL":
|
|
266
|
-
default:
|
|
267
|
-
return localize.month(month, { width: "wide", context: "standalone" });
|
|
268
|
-
}
|
|
269
|
-
},
|
|
270
|
-
|
|
271
|
-
// Local week of year
|
|
272
|
-
w: function (date, token, localize, options) {
|
|
273
|
-
const week = getWeek(date, options);
|
|
274
|
-
|
|
275
|
-
if (token === "wo") {
|
|
276
|
-
return localize.ordinalNumber(week, { unit: "week" });
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
return addLeadingZeros(week, token.length);
|
|
280
|
-
},
|
|
281
|
-
|
|
282
|
-
// ISO week of year
|
|
283
|
-
I: function (date, token, localize) {
|
|
284
|
-
const isoWeek = getISOWeek(date);
|
|
285
|
-
|
|
286
|
-
if (token === "Io") {
|
|
287
|
-
return localize.ordinalNumber(isoWeek, { unit: "week" });
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
return addLeadingZeros(isoWeek, token.length);
|
|
291
|
-
},
|
|
292
|
-
|
|
293
|
-
// Day of the month
|
|
294
|
-
d: function (date, token, localize) {
|
|
295
|
-
if (token === "do") {
|
|
296
|
-
return localize.ordinalNumber(date.getDate(), { unit: "date" });
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
return lightFormatters.d(date, token);
|
|
300
|
-
},
|
|
301
|
-
|
|
302
|
-
// Day of year
|
|
303
|
-
D: function (date, token, localize) {
|
|
304
|
-
const dayOfYear = getDayOfYear(date);
|
|
305
|
-
|
|
306
|
-
if (token === "Do") {
|
|
307
|
-
return localize.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
return addLeadingZeros(dayOfYear, token.length);
|
|
311
|
-
},
|
|
312
|
-
|
|
313
|
-
// Day of week
|
|
314
|
-
E: function (date, token, localize) {
|
|
315
|
-
const dayOfWeek = date.getDay();
|
|
316
|
-
switch (token) {
|
|
317
|
-
// Tue
|
|
318
|
-
case "E":
|
|
319
|
-
case "EE":
|
|
320
|
-
case "EEE":
|
|
321
|
-
return localize.day(dayOfWeek, {
|
|
322
|
-
width: "abbreviated",
|
|
323
|
-
context: "formatting",
|
|
324
|
-
});
|
|
325
|
-
// T
|
|
326
|
-
case "EEEEE":
|
|
327
|
-
return localize.day(dayOfWeek, {
|
|
328
|
-
width: "narrow",
|
|
329
|
-
context: "formatting",
|
|
330
|
-
});
|
|
331
|
-
// Tu
|
|
332
|
-
case "EEEEEE":
|
|
333
|
-
return localize.day(dayOfWeek, {
|
|
334
|
-
width: "short",
|
|
335
|
-
context: "formatting",
|
|
336
|
-
});
|
|
337
|
-
// Tuesday
|
|
338
|
-
case "EEEE":
|
|
339
|
-
default:
|
|
340
|
-
return localize.day(dayOfWeek, {
|
|
341
|
-
width: "wide",
|
|
342
|
-
context: "formatting",
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
},
|
|
346
|
-
|
|
347
|
-
// Local day of week
|
|
348
|
-
e: function (date, token, localize, options) {
|
|
349
|
-
const dayOfWeek = date.getDay();
|
|
350
|
-
const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
|
|
351
|
-
switch (token) {
|
|
352
|
-
// Numerical value (Nth day of week with current locale or weekStartsOn)
|
|
353
|
-
case "e":
|
|
354
|
-
return String(localDayOfWeek);
|
|
355
|
-
// Padded numerical value
|
|
356
|
-
case "ee":
|
|
357
|
-
return addLeadingZeros(localDayOfWeek, 2);
|
|
358
|
-
// 1st, 2nd, ..., 7th
|
|
359
|
-
case "eo":
|
|
360
|
-
return localize.ordinalNumber(localDayOfWeek, { unit: "day" });
|
|
361
|
-
case "eee":
|
|
362
|
-
return localize.day(dayOfWeek, {
|
|
363
|
-
width: "abbreviated",
|
|
364
|
-
context: "formatting",
|
|
365
|
-
});
|
|
366
|
-
// T
|
|
367
|
-
case "eeeee":
|
|
368
|
-
return localize.day(dayOfWeek, {
|
|
369
|
-
width: "narrow",
|
|
370
|
-
context: "formatting",
|
|
371
|
-
});
|
|
372
|
-
// Tu
|
|
373
|
-
case "eeeeee":
|
|
374
|
-
return localize.day(dayOfWeek, {
|
|
375
|
-
width: "short",
|
|
376
|
-
context: "formatting",
|
|
377
|
-
});
|
|
378
|
-
// Tuesday
|
|
379
|
-
case "eeee":
|
|
380
|
-
default:
|
|
381
|
-
return localize.day(dayOfWeek, {
|
|
382
|
-
width: "wide",
|
|
383
|
-
context: "formatting",
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
},
|
|
387
|
-
|
|
388
|
-
// Stand-alone local day of week
|
|
389
|
-
c: function (date, token, localize, options) {
|
|
390
|
-
const dayOfWeek = date.getDay();
|
|
391
|
-
const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
|
|
392
|
-
switch (token) {
|
|
393
|
-
// Numerical value (same as in `e`)
|
|
394
|
-
case "c":
|
|
395
|
-
return String(localDayOfWeek);
|
|
396
|
-
// Padded numerical value
|
|
397
|
-
case "cc":
|
|
398
|
-
return addLeadingZeros(localDayOfWeek, token.length);
|
|
399
|
-
// 1st, 2nd, ..., 7th
|
|
400
|
-
case "co":
|
|
401
|
-
return localize.ordinalNumber(localDayOfWeek, { unit: "day" });
|
|
402
|
-
case "ccc":
|
|
403
|
-
return localize.day(dayOfWeek, {
|
|
404
|
-
width: "abbreviated",
|
|
405
|
-
context: "standalone",
|
|
406
|
-
});
|
|
407
|
-
// T
|
|
408
|
-
case "ccccc":
|
|
409
|
-
return localize.day(dayOfWeek, {
|
|
410
|
-
width: "narrow",
|
|
411
|
-
context: "standalone",
|
|
412
|
-
});
|
|
413
|
-
// Tu
|
|
414
|
-
case "cccccc":
|
|
415
|
-
return localize.day(dayOfWeek, {
|
|
416
|
-
width: "short",
|
|
417
|
-
context: "standalone",
|
|
418
|
-
});
|
|
419
|
-
// Tuesday
|
|
420
|
-
case "cccc":
|
|
421
|
-
default:
|
|
422
|
-
return localize.day(dayOfWeek, {
|
|
423
|
-
width: "wide",
|
|
424
|
-
context: "standalone",
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
},
|
|
428
|
-
|
|
429
|
-
// ISO day of week
|
|
430
|
-
i: function (date, token, localize) {
|
|
431
|
-
const dayOfWeek = date.getDay();
|
|
432
|
-
const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
|
|
433
|
-
switch (token) {
|
|
434
|
-
// 2
|
|
435
|
-
case "i":
|
|
436
|
-
return String(isoDayOfWeek);
|
|
437
|
-
// 02
|
|
438
|
-
case "ii":
|
|
439
|
-
return addLeadingZeros(isoDayOfWeek, token.length);
|
|
440
|
-
// 2nd
|
|
441
|
-
case "io":
|
|
442
|
-
return localize.ordinalNumber(isoDayOfWeek, { unit: "day" });
|
|
443
|
-
// Tue
|
|
444
|
-
case "iii":
|
|
445
|
-
return localize.day(dayOfWeek, {
|
|
446
|
-
width: "abbreviated",
|
|
447
|
-
context: "formatting",
|
|
448
|
-
});
|
|
449
|
-
// T
|
|
450
|
-
case "iiiii":
|
|
451
|
-
return localize.day(dayOfWeek, {
|
|
452
|
-
width: "narrow",
|
|
453
|
-
context: "formatting",
|
|
454
|
-
});
|
|
455
|
-
// Tu
|
|
456
|
-
case "iiiiii":
|
|
457
|
-
return localize.day(dayOfWeek, {
|
|
458
|
-
width: "short",
|
|
459
|
-
context: "formatting",
|
|
460
|
-
});
|
|
461
|
-
// Tuesday
|
|
462
|
-
case "iiii":
|
|
463
|
-
default:
|
|
464
|
-
return localize.day(dayOfWeek, {
|
|
465
|
-
width: "wide",
|
|
466
|
-
context: "formatting",
|
|
467
|
-
});
|
|
468
|
-
}
|
|
469
|
-
},
|
|
470
|
-
|
|
471
|
-
// AM or PM
|
|
472
|
-
a: function (date, token, localize) {
|
|
473
|
-
const hours = date.getHours();
|
|
474
|
-
const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
|
|
475
|
-
|
|
476
|
-
switch (token) {
|
|
477
|
-
case "a":
|
|
478
|
-
case "aa":
|
|
479
|
-
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
480
|
-
width: "abbreviated",
|
|
481
|
-
context: "formatting",
|
|
482
|
-
});
|
|
483
|
-
case "aaa":
|
|
484
|
-
return localize
|
|
485
|
-
.dayPeriod(dayPeriodEnumValue, {
|
|
486
|
-
width: "abbreviated",
|
|
487
|
-
context: "formatting",
|
|
488
|
-
})
|
|
489
|
-
.toLowerCase();
|
|
490
|
-
case "aaaaa":
|
|
491
|
-
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
492
|
-
width: "narrow",
|
|
493
|
-
context: "formatting",
|
|
494
|
-
});
|
|
495
|
-
case "aaaa":
|
|
496
|
-
default:
|
|
497
|
-
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
498
|
-
width: "wide",
|
|
499
|
-
context: "formatting",
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
},
|
|
503
|
-
|
|
504
|
-
// AM, PM, midnight, noon
|
|
505
|
-
b: function (date, token, localize) {
|
|
506
|
-
const hours = date.getHours();
|
|
507
|
-
let dayPeriodEnumValue;
|
|
508
|
-
if (hours === 12) {
|
|
509
|
-
dayPeriodEnumValue = dayPeriodEnum.noon;
|
|
510
|
-
} else if (hours === 0) {
|
|
511
|
-
dayPeriodEnumValue = dayPeriodEnum.midnight;
|
|
512
|
-
} else {
|
|
513
|
-
dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
switch (token) {
|
|
517
|
-
case "b":
|
|
518
|
-
case "bb":
|
|
519
|
-
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
520
|
-
width: "abbreviated",
|
|
521
|
-
context: "formatting",
|
|
522
|
-
});
|
|
523
|
-
case "bbb":
|
|
524
|
-
return localize
|
|
525
|
-
.dayPeriod(dayPeriodEnumValue, {
|
|
526
|
-
width: "abbreviated",
|
|
527
|
-
context: "formatting",
|
|
528
|
-
})
|
|
529
|
-
.toLowerCase();
|
|
530
|
-
case "bbbbb":
|
|
531
|
-
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
532
|
-
width: "narrow",
|
|
533
|
-
context: "formatting",
|
|
534
|
-
});
|
|
535
|
-
case "bbbb":
|
|
536
|
-
default:
|
|
537
|
-
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
538
|
-
width: "wide",
|
|
539
|
-
context: "formatting",
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
},
|
|
543
|
-
|
|
544
|
-
// in the morning, in the afternoon, in the evening, at night
|
|
545
|
-
B: function (date, token, localize) {
|
|
546
|
-
const hours = date.getHours();
|
|
547
|
-
let dayPeriodEnumValue;
|
|
548
|
-
if (hours >= 17) {
|
|
549
|
-
dayPeriodEnumValue = dayPeriodEnum.evening;
|
|
550
|
-
} else if (hours >= 12) {
|
|
551
|
-
dayPeriodEnumValue = dayPeriodEnum.afternoon;
|
|
552
|
-
} else if (hours >= 4) {
|
|
553
|
-
dayPeriodEnumValue = dayPeriodEnum.morning;
|
|
554
|
-
} else {
|
|
555
|
-
dayPeriodEnumValue = dayPeriodEnum.night;
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
switch (token) {
|
|
559
|
-
case "B":
|
|
560
|
-
case "BB":
|
|
561
|
-
case "BBB":
|
|
562
|
-
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
563
|
-
width: "abbreviated",
|
|
564
|
-
context: "formatting",
|
|
565
|
-
});
|
|
566
|
-
case "BBBBB":
|
|
567
|
-
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
568
|
-
width: "narrow",
|
|
569
|
-
context: "formatting",
|
|
570
|
-
});
|
|
571
|
-
case "BBBB":
|
|
572
|
-
default:
|
|
573
|
-
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
574
|
-
width: "wide",
|
|
575
|
-
context: "formatting",
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
},
|
|
579
|
-
|
|
580
|
-
// Hour [1-12]
|
|
581
|
-
h: function (date, token, localize) {
|
|
582
|
-
if (token === "ho") {
|
|
583
|
-
let hours = date.getHours() % 12;
|
|
584
|
-
if (hours === 0) hours = 12;
|
|
585
|
-
return localize.ordinalNumber(hours, { unit: "hour" });
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
return lightFormatters.h(date, token);
|
|
589
|
-
},
|
|
590
|
-
|
|
591
|
-
// Hour [0-23]
|
|
592
|
-
H: function (date, token, localize) {
|
|
593
|
-
if (token === "Ho") {
|
|
594
|
-
return localize.ordinalNumber(date.getHours(), { unit: "hour" });
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
return lightFormatters.H(date, token);
|
|
598
|
-
},
|
|
599
|
-
|
|
600
|
-
// Hour [0-11]
|
|
601
|
-
K: function (date, token, localize) {
|
|
602
|
-
const hours = date.getHours() % 12;
|
|
603
|
-
|
|
604
|
-
if (token === "Ko") {
|
|
605
|
-
return localize.ordinalNumber(hours, { unit: "hour" });
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
return addLeadingZeros(hours, token.length);
|
|
609
|
-
},
|
|
610
|
-
|
|
611
|
-
// Hour [1-24]
|
|
612
|
-
k: function (date, token, localize) {
|
|
613
|
-
let hours = date.getHours();
|
|
614
|
-
if (hours === 0) hours = 24;
|
|
615
|
-
|
|
616
|
-
if (token === "ko") {
|
|
617
|
-
return localize.ordinalNumber(hours, { unit: "hour" });
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
return addLeadingZeros(hours, token.length);
|
|
621
|
-
},
|
|
622
|
-
|
|
623
|
-
// Minute
|
|
624
|
-
m: function (date, token, localize) {
|
|
625
|
-
if (token === "mo") {
|
|
626
|
-
return localize.ordinalNumber(date.getMinutes(), { unit: "minute" });
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
return lightFormatters.m(date, token);
|
|
630
|
-
},
|
|
631
|
-
|
|
632
|
-
// Second
|
|
633
|
-
s: function (date, token, localize) {
|
|
634
|
-
if (token === "so") {
|
|
635
|
-
return localize.ordinalNumber(date.getSeconds(), { unit: "second" });
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
return lightFormatters.s(date, token);
|
|
639
|
-
},
|
|
640
|
-
|
|
641
|
-
// Fraction of second
|
|
642
|
-
S: function (date, token) {
|
|
643
|
-
return lightFormatters.S(date, token);
|
|
644
|
-
},
|
|
645
|
-
|
|
646
|
-
// Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
|
|
647
|
-
X: function (date, token, _localize) {
|
|
648
|
-
const timezoneOffset = date.getTimezoneOffset();
|
|
649
|
-
|
|
650
|
-
if (timezoneOffset === 0) {
|
|
651
|
-
return "Z";
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
switch (token) {
|
|
655
|
-
// Hours and optional minutes
|
|
656
|
-
case "X":
|
|
657
|
-
return formatTimezoneWithOptionalMinutes(timezoneOffset);
|
|
658
|
-
|
|
659
|
-
// Hours, minutes and optional seconds without `:` delimiter
|
|
660
|
-
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
|
661
|
-
// so this token always has the same output as `XX`
|
|
662
|
-
case "XXXX":
|
|
663
|
-
case "XX": // Hours and minutes without `:` delimiter
|
|
664
|
-
return formatTimezone(timezoneOffset);
|
|
665
|
-
|
|
666
|
-
// Hours, minutes and optional seconds with `:` delimiter
|
|
667
|
-
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
|
668
|
-
// so this token always has the same output as `XXX`
|
|
669
|
-
case "XXXXX":
|
|
670
|
-
case "XXX": // Hours and minutes with `:` delimiter
|
|
671
|
-
default:
|
|
672
|
-
return formatTimezone(timezoneOffset, ":");
|
|
673
|
-
}
|
|
674
|
-
},
|
|
675
|
-
|
|
676
|
-
// Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
|
|
677
|
-
x: function (date, token, _localize) {
|
|
678
|
-
const timezoneOffset = date.getTimezoneOffset();
|
|
679
|
-
|
|
680
|
-
switch (token) {
|
|
681
|
-
// Hours and optional minutes
|
|
682
|
-
case "x":
|
|
683
|
-
return formatTimezoneWithOptionalMinutes(timezoneOffset);
|
|
684
|
-
|
|
685
|
-
// Hours, minutes and optional seconds without `:` delimiter
|
|
686
|
-
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
|
687
|
-
// so this token always has the same output as `xx`
|
|
688
|
-
case "xxxx":
|
|
689
|
-
case "xx": // Hours and minutes without `:` delimiter
|
|
690
|
-
return formatTimezone(timezoneOffset);
|
|
691
|
-
|
|
692
|
-
// Hours, minutes and optional seconds with `:` delimiter
|
|
693
|
-
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
|
694
|
-
// so this token always has the same output as `xxx`
|
|
695
|
-
case "xxxxx":
|
|
696
|
-
case "xxx": // Hours and minutes with `:` delimiter
|
|
697
|
-
default:
|
|
698
|
-
return formatTimezone(timezoneOffset, ":");
|
|
699
|
-
}
|
|
700
|
-
},
|
|
701
|
-
|
|
702
|
-
// Timezone (GMT)
|
|
703
|
-
O: function (date, token, _localize) {
|
|
704
|
-
const timezoneOffset = date.getTimezoneOffset();
|
|
705
|
-
|
|
706
|
-
switch (token) {
|
|
707
|
-
// Short
|
|
708
|
-
case "O":
|
|
709
|
-
case "OO":
|
|
710
|
-
case "OOO":
|
|
711
|
-
return "GMT" + formatTimezoneShort(timezoneOffset, ":");
|
|
712
|
-
// Long
|
|
713
|
-
case "OOOO":
|
|
714
|
-
default:
|
|
715
|
-
return "GMT" + formatTimezone(timezoneOffset, ":");
|
|
716
|
-
}
|
|
717
|
-
},
|
|
718
|
-
|
|
719
|
-
// Timezone (specific non-location)
|
|
720
|
-
z: function (date, token, _localize) {
|
|
721
|
-
const timezoneOffset = date.getTimezoneOffset();
|
|
722
|
-
|
|
723
|
-
switch (token) {
|
|
724
|
-
// Short
|
|
725
|
-
case "z":
|
|
726
|
-
case "zz":
|
|
727
|
-
case "zzz":
|
|
728
|
-
return "GMT" + formatTimezoneShort(timezoneOffset, ":");
|
|
729
|
-
// Long
|
|
730
|
-
case "zzzz":
|
|
731
|
-
default:
|
|
732
|
-
return "GMT" + formatTimezone(timezoneOffset, ":");
|
|
733
|
-
}
|
|
734
|
-
},
|
|
735
|
-
|
|
736
|
-
// Seconds timestamp
|
|
737
|
-
t: function (date, token, _localize) {
|
|
738
|
-
const timestamp = Math.trunc(+date / 1000);
|
|
739
|
-
return addLeadingZeros(timestamp, token.length);
|
|
740
|
-
},
|
|
741
|
-
|
|
742
|
-
// Milliseconds timestamp
|
|
743
|
-
T: function (date, token, _localize) {
|
|
744
|
-
return addLeadingZeros(+date, token.length);
|
|
745
|
-
},
|
|
746
|
-
};
|
|
747
|
-
|
|
748
|
-
function formatTimezoneShort(offset, delimiter = "") {
|
|
749
|
-
const sign = offset > 0 ? "-" : "+";
|
|
750
|
-
const absOffset = Math.abs(offset);
|
|
751
|
-
const hours = Math.trunc(absOffset / 60);
|
|
752
|
-
const minutes = absOffset % 60;
|
|
753
|
-
if (minutes === 0) {
|
|
754
|
-
return sign + String(hours);
|
|
755
|
-
}
|
|
756
|
-
return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
function formatTimezoneWithOptionalMinutes(offset, delimiter) {
|
|
760
|
-
if (offset % 60 === 0) {
|
|
761
|
-
const sign = offset > 0 ? "-" : "+";
|
|
762
|
-
return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
|
|
763
|
-
}
|
|
764
|
-
return formatTimezone(offset, delimiter);
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
function formatTimezone(offset, delimiter = "") {
|
|
768
|
-
const sign = offset > 0 ? "-" : "+";
|
|
769
|
-
const absOffset = Math.abs(offset);
|
|
770
|
-
const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
|
|
771
|
-
const minutes = addLeadingZeros(absOffset % 60, 2);
|
|
772
|
-
return sign + hours + delimiter + minutes;
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
export { formatters };
|