Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standart Time to Daylight Saving Time Tests Result Unexpected #74

Open
n-ae opened this issue Oct 8, 2024 · 0 comments
Open

Standart Time to Daylight Saving Time Tests Result Unexpected #74

n-ae opened this issue Oct 8, 2024 · 0 comments

Comments

@n-ae
Copy link

n-ae commented Oct 8, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant