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

Use local timezone, not local UTC offset #329

Merged
merged 1 commit into from
Feb 9, 2024
Merged

Conversation

sharkdp
Copy link
Owner

@sharkdp sharkdp commented Feb 9, 2024

With this change, we treat "local" as the local timezone, whereas before, we treated "local" as the local (current) UTC offset.

The following behavior is shown for timezone Europe/Berlin, during winter.

Before: UTC offset is used for parse_datetime

>>> parse_datetime("2024-01-01T12:00:00Z")
    = Mon, 1 Jan 2024 12:00:00 +0000    [DateTime]

After:

>>> parse_datetime("2024-01-01T12:00:00Z")
    = Mon, 1 Jan 2024 13:00:00 +0100    [DateTime]

Before: "Winter" UTC offset is used for datetime in summer

>>> parse_datetime("2024-07-01T12:00:00Z") -> "local"
    = Mon, 1 Jul 2024 13:00:00 +0100    [DateTime]

After: "Summer" UTC offset is used for datetime in summer

>>> parse_datetime("2024-07-01T12:00:00Z") -> "local"
    = Mon, 1 Jul 2024 14:00:00 +0200    [DateTime]

After: "Winter" UTC offset is used for datetime in winter

>>> parse_datetime("2024-01-01T12:00:00Z") -> "local"
    = Mon, 1 Jan 2024 13:00:00 +0100    [DateTime]

With this change, we treat "local" as the local timezone, whereas
before, we treated "local" as the local (current) UTC offset.

The following behavior is shown for timezone Europe/Berlin, during
winter.

Before: UTC offset is used for parse_datetime

    >>> parse_datetime("2024-01-01T12:00:00Z")
        = Mon, 1 Jan 2024 12:00:00 +0000    [DateTime]

After:

    >>> parse_datetime("2024-01-01T12:00:00Z")
        = Mon, 1 Jan 2024 13:00:00 +0100    [DateTime]

Before: "Winter" UTC offset is used for datetime in summer

    >>> parse_datetime("2024-07-01T12:00:00Z") -> "local"
        = Mon, 1 Jul 2024 13:00:00 +0100    [DateTime]

After: "Summer" UTC offset is used for datetime in summer

    >>> parse_datetime("2024-07-01T12:00:00Z") -> "local"
        = Mon, 1 Jul 2024 14:00:00 +0200    [DateTime]

After: "Winter" UTC offset is used for datetime in winter

    >>> parse_datetime("2024-01-01T12:00:00Z") -> "local"
        = Mon, 1 Jan 2024 13:00:00 +0100    [DateTime]
@sharkdp sharkdp merged commit 89f799e into master Feb 9, 2024
15 checks passed
@sharkdp sharkdp deleted the use-local-timezone branch February 9, 2024 21:20
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

Successfully merging this pull request may close these issues.

1 participant