- {
- setTitle(manualTimezoneSelected ? t.titleManual : t.titleAuto)
+ onManualTimeZoneSelected={(manualTimeZoneSelected) => {
+ setTitle(manualTimeZoneSelected ? t.titleManual : t.titleAuto)
}}
/>
@@ -36,5 +36,5 @@ const t = {
titleAuto: 'Time Zone (automatic)',
titleManual: 'Time Zone (manual)',
utc: 'UTC',
- setTimezoneManuallyLabel: 'Use local time zone',
+ setTimeZoneManuallyLabel: 'Use local time zone',
}
diff --git a/src/lib/ui/AccessCodeForm/AccessCodeFormTimes.tsx b/src/lib/ui/AccessCodeForm/AccessCodeFormTimes.tsx
index 7831b5741..3e39585d8 100644
--- a/src/lib/ui/AccessCodeForm/AccessCodeFormTimes.tsx
+++ b/src/lib/ui/AccessCodeForm/AccessCodeFormTimes.tsx
@@ -1,10 +1,11 @@
-import { formatDateTimeReadable } from 'lib/dates.js'
+import { DateTime } from 'luxon'
+
import { EditIcon } from 'lib/icons/Edit.js'
import { IconButton } from 'lib/ui/IconButton.js'
interface AccessCodeFormTimesProps {
- startDate: string
- endDate: string
+ startDate: DateTime
+ endDate: DateTime
onEdit: () => void
}
@@ -17,9 +18,9 @@ export function AccessCodeFormTimes({
{t.startTimeLabel}
- {formatDateTimeReadable(startDate)}
+ {formatDateTime(startDate)}
{t.endTimeLabel}
- {formatDateTimeReadable(endDate)}
+ {formatDateTime(endDate)}
@@ -28,6 +29,9 @@ export function AccessCodeFormTimes({
)
}
+const formatDateTime = (dateTime: DateTime): string =>
+ dateTime.toLocaleString(DateTime.DATETIME_FULL_WITH_SECONDS)
+
const t = {
startTimeLabel: 'Start',
endTimeLabel: 'End',
diff --git a/src/lib/ui/ClimateSettingForm/ClimateSettingScheduleForm.tsx b/src/lib/ui/ClimateSettingForm/ClimateSettingScheduleForm.tsx
index db3f298a3..4ba8ef686 100644
--- a/src/lib/ui/ClimateSettingForm/ClimateSettingScheduleForm.tsx
+++ b/src/lib/ui/ClimateSettingForm/ClimateSettingScheduleForm.tsx
@@ -3,17 +3,17 @@ import { useState } from 'react'
import { useForm } from 'react-hook-form'
import type { ClimateSetting } from 'seamapi'
-import { getBrowserTimezone } from 'lib/dates.js'
+import { getSystemTimeZone } from 'lib/dates.js'
import { ClimateSettingScheduleFormDeviceSelect } from 'lib/ui/ClimateSettingForm/ClimateSettingScheduleFormDeviceSelect.js'
import { ClimateSettingScheduleFormNameAndSchedule } from 'lib/ui/ClimateSettingForm/ClimateSettingScheduleFormNameAndSchedule.js'
-import { ClimateSettingScheduleFormTimezonePicker } from 'lib/ui/ClimateSettingForm/ClimateSettingScheduleFormTimezonePicker.js'
+import { ClimateSettingScheduleFormTimeZonePicker } from 'lib/ui/ClimateSettingForm/ClimateSettingScheduleFormTimeZonePicker.js'
export interface ClimateSettingScheduleFormSubmitData {
name: string
deviceId: string
startDate: string
endDate: string
- timezone: string
+ timeZone: string
climateSetting: ClimateSetting
}
@@ -29,7 +29,7 @@ export interface ClimateSettingScheduleFormFields {
deviceId: string
startDate: string
endDate: string
- timezone: string
+ timeZone: string
}
export function ClimateSettingScheduleForm({
@@ -54,18 +54,18 @@ function Content({
name: '',
startDate: '',
endDate: '',
- timezone: getBrowserTimezone(),
+ timeZone: getSystemTimeZone(),
},
})
const deviceId = watch('deviceId')
- const timezone = watch('timezone')
+ const timeZone = watch('timeZone')
const [page, setPage] = useState<
| 'device_select'
| 'default_setting'
| 'name_and_schedule'
- | 'timezone_select'
+ | 'time_zone_select'
| 'climate_setting'
>('device_select')
@@ -95,17 +95,17 @@ function Content({
onNext={() => {
setPage('climate_setting')
}}
- onChangeTimezone={() => {
- setPage('timezone_select')
+ onChangeTimeZone={() => {
+ setPage('time_zone_select')
}}
- timezone={timezone}
+ timeZone={timeZone}
/>
)
}
- if (page === 'timezone_select') {
+ if (page === 'time_zone_select') {
return (
- {
setPage('name_and_schedule')
diff --git a/src/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormNameAndSchedule.tsx b/src/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormNameAndSchedule.tsx
index df3090cc2..5bd741ae6 100644
--- a/src/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormNameAndSchedule.tsx
+++ b/src/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormNameAndSchedule.tsx
@@ -1,6 +1,6 @@
import { type Control, Controller } from 'react-hook-form'
-import { getTimezoneLabel } from 'lib/dates.js'
+import { formatTimeZone } from 'lib/dates.js'
import { ChevronRightIcon } from 'lib/icons/ChevronRight.js'
import { useDevice } from 'lib/seam/devices/use-device.js'
import { Button } from 'lib/ui/Button.js'
@@ -15,22 +15,22 @@ interface ClimateSettingScheduleFormNameAndScheduleProps {
title: string
control: Control
deviceId: string
- timezone: string
+ timeZone: string
onBack: () => void
onCancel: (() => void) | undefined
onNext: () => void
- onChangeTimezone: () => void
+ onChangeTimeZone: () => void
}
export function ClimateSettingScheduleFormNameAndSchedule({
title,
control,
deviceId,
- timezone,
+ timeZone,
onBack,
onCancel,
onNext,
- onChangeTimezone,
+ onChangeTimeZone,
}: ClimateSettingScheduleFormNameAndScheduleProps): JSX.Element {
const { device } = useDevice({
device_id: deviceId,
@@ -68,10 +68,10 @@ export function ClimateSettingScheduleFormNameAndSchedule({
{t.startTimeLabel}
-
-
{t.selectedTimezoneLabel}
-
- {getTimezoneLabel(timezone)}
+
+ {t.selectedTimeZoneLabel}
+
+ {formatTimeZone(timeZone)}
@@ -116,5 +116,5 @@ const t = {
cancel: 'Cancel',
save: 'Save',
next: 'Next',
- selectedTimezoneLabel: 'All times in',
+ selectedTimeZoneLabel: 'All times in',
}
diff --git a/src/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormTimezonePicker.tsx b/src/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormTimeZonePicker.tsx
similarity index 66%
rename from src/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormTimezonePicker.tsx
rename to src/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormTimeZonePicker.tsx
index b45b811ac..396371d37 100644
--- a/src/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormTimezonePicker.tsx
+++ b/src/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormTimeZonePicker.tsx
@@ -3,17 +3,17 @@ import { type Control, Controller } from 'react-hook-form'
import type { ClimateSettingScheduleFormFields } from 'lib/ui/ClimateSettingForm/ClimateSettingScheduleForm.js'
import { ContentHeader } from 'lib/ui/layout/ContentHeader.js'
-import { TimezonePicker } from 'lib/ui/TimezonePicker/TimezonePicker.js'
+import { TimeZonePicker } from 'lib/ui/TimeZonePicker/TimeZonePicker.js'
-interface ClimateSettingScheduleFormTimezonePickerProps {
+interface ClimateSettingScheduleFormTimeZonePickerProps {
control: Control
onClose: () => void
}
-export function ClimateSettingScheduleFormTimezonePicker({
+export function ClimateSettingScheduleFormTimeZonePicker({
control,
onClose,
-}: ClimateSettingScheduleFormTimezonePickerProps): JSX.Element {
+}: ClimateSettingScheduleFormTimeZonePickerProps): JSX.Element {
const [title, setTitle] = useState(t.titleAuto)
return (
@@ -21,13 +21,13 @@ export function ClimateSettingScheduleFormTimezonePicker({
(
- {
- setTitle(manualTimezoneSelected ? t.titleManual : t.titleAuto)
+ onManualTimeZoneSelected={(manualTimeZoneSelected) => {
+ setTitle(manualTimeZoneSelected ? t.titleManual : t.titleAuto)
}}
/>
)}
diff --git a/src/lib/ui/LoadingToast/LoadingToast.tsx b/src/lib/ui/LoadingToast/LoadingToast.tsx
index 2fb97dd89..df2bdace3 100644
--- a/src/lib/ui/LoadingToast/LoadingToast.tsx
+++ b/src/lib/ui/LoadingToast/LoadingToast.tsx
@@ -21,26 +21,23 @@ export function LoadingToast({
const [showToast, setShowToast] = useState(isLoading)
useEffect(() => {
- if (!isLoading) {
- const hideTimeout = globalThis.setTimeout(() => {
- setHidden(true)
- }, 1000)
-
- const removeTimeout = globalThis.setTimeout(() => {
- setShowToast(false)
- }, 1500)
-
- return () => {
- globalThis.clearTimeout(hideTimeout)
- globalThis.clearTimeout(removeTimeout)
- }
+ if (isLoading) {
+ setHidden(false)
+ setShowToast(true)
+ return () => {}
}
- setHidden(false)
- setShowToast(true)
+ const hideTimeout = globalThis.setTimeout(() => {
+ setHidden(true)
+ }, 1000)
+
+ const removeTimeout = globalThis.setTimeout(() => {
+ setShowToast(false)
+ }, 1500)
return () => {
- // noop
+ globalThis.clearTimeout(hideTimeout)
+ globalThis.clearTimeout(removeTimeout)
}
}, [isLoading])
diff --git a/src/lib/ui/TimeZonePicker/TimeZonePicker.stories.tsx b/src/lib/ui/TimeZonePicker/TimeZonePicker.stories.tsx
new file mode 100644
index 000000000..e80a59339
--- /dev/null
+++ b/src/lib/ui/TimeZonePicker/TimeZonePicker.stories.tsx
@@ -0,0 +1,31 @@
+import { useArgs } from '@storybook/preview-api'
+import type { Meta, StoryObj } from '@storybook/react'
+
+import { getSystemTimeZone } from 'lib/dates.js'
+import { TimeZonePicker } from 'lib/ui/TimeZonePicker/TimeZonePicker.js'
+
+const meta: Meta = {
+ title: 'Library/TimeZonePicker',
+ tags: ['autodocs'],
+ component: TimeZonePicker,
+}
+
+type Story = StoryObj
+
+export const Content: Story = {
+ render: (props) => {
+ const [, setArgs] = useArgs()
+
+ const onChange = (timeZone: string): void => {
+ setArgs({ value: timeZone })
+ }
+
+ return
+ },
+}
+
+Content.args = {
+ value: getSystemTimeZone(),
+}
+
+export default meta
diff --git a/src/lib/ui/TimeZonePicker/TimeZonePicker.tsx b/src/lib/ui/TimeZonePicker/TimeZonePicker.tsx
new file mode 100644
index 000000000..1899683f9
--- /dev/null
+++ b/src/lib/ui/TimeZonePicker/TimeZonePicker.tsx
@@ -0,0 +1,69 @@
+import { useEffect, useState } from 'react'
+
+import {
+ formatTimeZone,
+ getSupportedTimeZones,
+ getSystemTimeZone,
+} from 'lib/dates.js'
+import { Checkbox } from 'lib/ui/Checkbox.js'
+import { handleString } from 'lib/ui/TextField/TextField.js'
+
+interface TimeZonePickerProps {
+ value: string
+ onChange: (timeZone: string) => void
+ onManualTimeZoneSelected?: (manualTimeZoneSelected: boolean) => void
+}
+
+export function TimeZonePicker({
+ onChange,
+ value,
+ onManualTimeZoneSelected,
+}: TimeZonePickerProps): JSX.Element {
+ const [manualTimeZoneEnabled, setManualTimeZoneEnabled] = useState(false)
+
+ const isBrowserTimeZoneSelected = value === getSystemTimeZone()
+ const isManualTimeZoneSelected =
+ !isBrowserTimeZoneSelected || manualTimeZoneEnabled
+
+ useEffect(() => {
+ if (onManualTimeZoneSelected != null)
+ onManualTimeZoneSelected(isManualTimeZoneSelected)
+ }, [isManualTimeZoneSelected, onManualTimeZoneSelected])
+
+ const handleChangeManualTimeZone = (enabled: boolean): void => {
+ setManualTimeZoneEnabled(enabled)
+ if (!enabled) {
+ onChange(getSystemTimeZone())
+ }
+ }
+
+ return (
+
+ {
+ handleChangeManualTimeZone(!manual)
+ }}
+ className='seam-manual-time-zone-checkbox'
+ />
+
+
+
+ )
+}
+
+const t = {
+ utc: 'UTC',
+ setTimeZoneManuallyLabel: 'Use local time zone',
+}
diff --git a/src/lib/ui/TimezonePicker/TimezonePicker.stories.tsx b/src/lib/ui/TimezonePicker/TimezonePicker.stories.tsx
deleted file mode 100644
index 662b92c89..000000000
--- a/src/lib/ui/TimezonePicker/TimezonePicker.stories.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-import { useArgs } from '@storybook/preview-api'
-import type { Meta, StoryObj } from '@storybook/react'
-
-import { getBrowserTimezone } from 'lib/dates.js'
-import { TimezonePicker } from 'lib/ui/TimezonePicker/TimezonePicker.js'
-
-const meta: Meta = {
- title: 'Library/TimezonePicker',
- tags: ['autodocs'],
- component: TimezonePicker,
-}
-
-type Story = StoryObj
-
-export const Content: Story = {
- render: (props) => {
- const [, setArgs] = useArgs()
-
- const onChange = (timezone: string): void => {
- setArgs({ value: timezone })
- }
-
- return
- },
-}
-
-Content.args = {
- value: getBrowserTimezone(),
-}
-
-export default meta
diff --git a/src/lib/ui/TimezonePicker/TimezonePicker.tsx b/src/lib/ui/TimezonePicker/TimezonePicker.tsx
deleted file mode 100644
index c64e14d74..000000000
--- a/src/lib/ui/TimezonePicker/TimezonePicker.tsx
+++ /dev/null
@@ -1,70 +0,0 @@
-import { useEffect, useState } from 'react'
-
-import {
- getBrowserTimezone,
- getTimezoneLabel,
- getTimezoneOffset,
- getTimezones,
-} from 'lib/dates.js'
-import { Checkbox } from 'lib/ui/Checkbox.js'
-import { handleString } from 'lib/ui/TextField/TextField.js'
-
-interface TimezonePickerProps {
- value: string
- onChange: (timezone: string) => void
- onManualTimezoneSelected?: (manualTimezoneSelected: boolean) => void
-}
-
-export function TimezonePicker({
- onChange,
- value,
- onManualTimezoneSelected,
-}: TimezonePickerProps): JSX.Element {
- const [manualTimezoneEnabled, setManualTimezoneEnabled] = useState(false)
-
- const isBrowserTimezoneSelected = value === getBrowserTimezone()
- const isManualTimezoneSelected =
- !isBrowserTimezoneSelected || manualTimezoneEnabled
-
- useEffect(() => {
- if (onManualTimezoneSelected != null)
- onManualTimezoneSelected(isManualTimezoneSelected)
- }, [isManualTimezoneSelected, onManualTimezoneSelected])
-
- const handleChangeManualTimezone = (enabled: boolean): void => {
- setManualTimezoneEnabled(enabled)
- if (!enabled) {
- onChange(getBrowserTimezone())
- }
- }
-
- return (
-
- {
- handleChangeManualTimezone(!manual)
- }}
- className='seam-manual-timezone-checkbox'
- />
-
-
-
- )
-}
-
-const t = {
- utc: 'UTC',
- setTimezoneManuallyLabel: 'Use local time zone',
-}
diff --git a/src/lib/ui/device/BatteryStatus.tsx b/src/lib/ui/device/BatteryStatus.tsx
index 7b9366a08..ea7b8d74a 100644
--- a/src/lib/ui/device/BatteryStatus.tsx
+++ b/src/lib/ui/device/BatteryStatus.tsx
@@ -26,15 +26,14 @@ function Content(props: {
}): JSX.Element | null {
const { status, level } = props
- const percentage = level != null ? ` (${Math.floor(level * 100)}%)` : null
-
if (status === 'full') {
return (
<>
- {`${t.full}${
- percentage ?? ''
- }`}
+
+ {t.full}
+
+
>
)
}
@@ -43,9 +42,10 @@ function Content(props: {
return (
<>
- {`${t.high}${
- percentage ?? ''
- }`}
+
+ {t.high}
+
+
>
)
}
@@ -54,9 +54,10 @@ function Content(props: {
return (
<>
- {`${t.low}${
- percentage ?? ''
- }`}
+
+ {t.low}
+
+
>
)
}
@@ -65,9 +66,10 @@ function Content(props: {
return (
<>
- {`${t.critical}${
- percentage ?? ''
- }`}
+
+ {t.critical}
+
+
>
)
}
@@ -75,6 +77,13 @@ function Content(props: {
return null
}
+function Percentage(props: {
+ level: number | null | undefined
+}): JSX.Element | null {
+ if (props.level == null) return null
+ return <> ({Math.floor(props.level * 100)}%)>
+}
+
const t = {
full: 'Good',
high: 'Good',
diff --git a/src/lib/ui/use-current-time.ts b/src/lib/ui/use-now.ts
similarity index 87%
rename from src/lib/ui/use-current-time.ts
rename to src/lib/ui/use-now.ts
index 38932cc45..2f4f6839f 100644
--- a/src/lib/ui/use-current-time.ts
+++ b/src/lib/ui/use-now.ts
@@ -3,7 +3,7 @@ import { useCallback, useState } from 'react'
import { useInterval } from 'lib/ui/use-interval.js'
-export function useCurrentTime(): DateTime {
+export function useNow(): DateTime {
const [date, setDate] = useState(DateTime.now())
const update = useCallback(() => {
diff --git a/src/styles/_access-code-form.scss b/src/styles/_access-code-form.scss
index 096ddd9ca..184152615 100644
--- a/src/styles/_access-code-form.scss
+++ b/src/styles/_access-code-form.scss
@@ -4,7 +4,7 @@
.seam-access-code-form {
@include main;
@include schedule-picker;
- @include timezone-picker;
+ @include time-zone-picker;
}
}
@@ -96,7 +96,7 @@
.seam-content {
padding: 0 24px;
- .seam-timezone {
+ .seam-time-zone {
display: flex;
align-items: center;
font-size: 14px;
@@ -127,8 +127,8 @@
}
}
-@mixin timezone-picker {
- .seam-access-code-timezone-picker {
+@mixin time-zone-picker {
+ .seam-access-code-time-zone-picker {
.seam-content {
padding: 0 24px;
}
diff --git a/src/styles/_climate-setting-schedule-form.scss b/src/styles/_climate-setting-schedule-form.scss
index 67385f60d..b11c4e1b9 100644
--- a/src/styles/_climate-setting-schedule-form.scss
+++ b/src/styles/_climate-setting-schedule-form.scss
@@ -25,7 +25,7 @@
@mixin name-and-schedule {
.seam-climate-setting-schedule-form-name-and-schedule {
- .seam-timezone {
+ .seam-time-zone {
display: flex;
align-items: center;
font-size: 14px;
diff --git a/src/styles/_main.scss b/src/styles/_main.scss
index 12c45f50c..de748fae6 100644
--- a/src/styles/_main.scss
+++ b/src/styles/_main.scss
@@ -25,7 +25,7 @@
@use './switch';
@use './climate-setting-schedule-form';
@use './climate-setting-schedule-details';
-@use './timezone-picker';
+@use './time-zone-picker';
.seam-components {
// Reset
@@ -47,7 +47,7 @@
@include tooltip.all;
@include spinner.all;
@include switch.all;
- @include timezone-picker.all;
+ @include time-zone-picker.all;
// Components
@include device-details.all;
diff --git a/src/styles/_timezone-picker.scss b/src/styles/_time-zone-picker.scss
similarity index 73%
rename from src/styles/_timezone-picker.scss
rename to src/styles/_time-zone-picker.scss
index d595200ef..c4ea1043f 100644
--- a/src/styles/_timezone-picker.scss
+++ b/src/styles/_time-zone-picker.scss
@@ -1,12 +1,12 @@
@use './colors';
@mixin all {
- .seam-timezone-picker {
- .seam-manual-timezone-checkbox {
+ .seam-time-zone-picker {
+ .seam-manual-time-zone-checkbox {
margin-bottom: 8px;
}
- > .seam-timezone-select {
+ > .seam-time-zone-select {
background: colors.$white;
padding: 0 12px;
width: 100%;
diff --git a/test/lib/date.test.ts b/test/lib/date.test.ts
index 63bcac018..91c626dc4 100644
--- a/test/lib/date.test.ts
+++ b/test/lib/date.test.ts
@@ -1,51 +1,82 @@
-import { expect, it } from 'vitest'
+import { DateTime } from 'luxon'
+import { describe, expect, it } from 'vitest'
import {
- compareByTimezoneOffsetAsc,
- createIsoDate,
- formatDateTimeReadable,
- get24HoursLater,
- getNow,
- getTimezoneLabel,
- getTimezoneOffset,
+ compareByCreatedAtDesc,
+ formatTimeZone,
+ getSupportedTimeZones,
+ getSystemTimeZone,
+ parseDateTimePickerValue,
+ serializeDateTimePickerValue,
} from 'lib/dates.js'
-it('should return a timezone label', () => {
- expect(true).toBe(true)
+describe('compareByCreatedAtDesc', () => {
+ it('compares two valid dates', () => {
+ expect(
+ compareByCreatedAtDesc(
+ { created_at: '2023-09-27T22:44:52Z' },
+ { created_at: '2022-09-27T22:44:52Z' }
+ )
+ ).toBe(31536000000)
- expect(getTimezoneLabel('America/Los_angeles')).toBe('Los angeles (America)')
+ expect(
+ compareByCreatedAtDesc(
+ { created_at: '2022-09-27T22:44:52Z' },
+ { created_at: '2023-09-27T22:44:52Z' }
+ )
+ ).toBe(-31536000000)
+ })
})
-it('should compare 2 timezones by minutes', () => {
- const tokyo = 9 * 60 // +9 = 540 minutes
-
- const losAngeles = -7 * 60 // -7 = -420 minutes
-
- expect(compareByTimezoneOffsetAsc('Asia/Tokyo', 'America/Los_angeles')).toBe(
- tokyo - losAngeles
- )
+describe('getSupportedTimeZones', () => {
+ it('contains time zones', () => {
+ expect(getSupportedTimeZones()).toContain('Africa/Maputo')
+ expect(getSupportedTimeZones()).toContain('Asia/Tokyo')
+ })
})
-it('should return offset mintues', () => {
- expect(getTimezoneOffset('America/Los_angeles')).toBe('-07:00')
+describe('getSystemTimeZone', () => {
+ it('is a supported time zone', () => {
+ const systemTimeZone = getSystemTimeZone()
+ expect(getSupportedTimeZones()).toContain(systemTimeZone)
+ })
})
-it('should return a readable date, and time', () => {
- expect(formatDateTimeReadable('2023-04-17T13:15:00')).toBe(
- 'Apr 17, 2023 at 1:15 PM'
- )
-})
+describe('formatTimeZone', () => {
+ it('returns zone name and offset', () => {
+ expect(formatTimeZone('Africa/Maputo')).toBe('Africa/Maputo (UTC+2)')
+ expect(formatTimeZone('UTC')).toBe('UTC (UTC+0)')
+ })
-it('should only show current date and time', () => {
- // Assert doesn't contain any timezone, or milliseconds
-
- expect(getNow()).not.toContain('Z')
- expect(getNow()).not.toContain('.')
+ it('handles the case with no region', () => {
+ expect(formatTimeZone('Egypt')).toBe('Egypt (UTC+3)')
+ })
+})
- expect(get24HoursLater()).not.toContain('Z')
- expect(get24HoursLater()).not.toContain('.')
+describe('serializeDateTimePickerValue', () => {
+ it('formats without time zone', () => {
+ expect(
+ serializeDateTimePickerValue(
+ DateTime.fromISO('2023-09-27T22:44:52Z'),
+ 'UTC'
+ )
+ ).toBe('2023-09-27T22:44:52')
+ expect(
+ serializeDateTimePickerValue(
+ DateTime.fromISO('2023-09-27T22:44:52+0300'),
+ 'Asia/Tokyo'
+ )
+ ).toBe('2023-09-28T04:44:52')
+ })
})
-it('should create an ISO8601 date', () => {
- expect(createIsoDate(getNow(), 'America/Los_angeles')).toContain('.000-07:00')
+describe('parseDateTimePickerValue', () => {
+ it('keeps time with the new zone', () => {
+ expect(parseDateTimePickerValue('2023-09-27T22:44:52', 'UTC').toISO()).toBe(
+ '2023-09-27T22:44:52.000Z'
+ )
+ expect(
+ parseDateTimePickerValue('2023-09-28T04:44:52', 'Asia/Tokyo').toISO()
+ ).toBe('2023-09-28T04:44:52.000+09:00')
+ })
})
diff --git a/vite.config.ts b/vite.config.ts
index e56cb957a..608f5e063 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -12,11 +12,7 @@ export default defineConfig(async ({ mode }) => {
throw new Error('Missing version in package.json')
}
const config: UserConfig = {
- plugins: [
- tsconfigPaths(),
- // @ts-expect-error https://github.com/vitejs/vite-plugin-react/issues/104
- react(),
- ],
+ plugins: [tsconfigPaths(), react()],
define: isBuild
? {
'process.env.NODE_ENV': "'production'",