-
-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
I'm trying to test my function:
import { tzDate } from '@formkit/tempo'
export function convertToUTCISO(localTimestamp: string): string {
const timezone = 'Europe/Berlin'
const timestamp = tzDate(localTimestamp, timezone)
const formattedTimestamp = timestamp.toISOString()
return formattedTimestamp
}
with:
describe('convertToUTCISO', () => {
it.each([
['2024-03-31T03:01', '2024-03-31T01:01:00.000Z'], // invalid, result: 2024-03-31T02:01:00.000Z
['2024-03-31T03:59', '2024-03-31T01:59:00.000Z'], // invalid, result: 2024-03-31T02:59:00.000Z
['2024-03-31T04:00', '2024-03-31T02:00:00.000Z'], // valid
['2024-03-31T04:01', '2024-03-31T02:01:00.000Z'], // valid
])('should get the correct value for given input %s: [%s]', (value: string, expected: string) => {
// Act
const result = convertToUTCISO(value)
// Assert
expect(result).toBe(expected)
})
})
However the first couple of value & expected pairs of it won't work. To me it acts as if the ST -> DST happens on 4 AM local time as opposed to 3 AM. What's my mistake?
Metadata
Metadata
Assignees
Labels
No labels