Skip to content

pickling doesn't preserve DST offset #908

@ruaridhw

Description

@ruaridhw
  • I am on the latest Pendulum version.
  • I have searched the issues of this repo and believe that this is not a duplicate.

Issue

The following test case fails for after_fold because pendulum doesn't keep a record of which side of the fold this datetime is. It only knows the date, time, and "Chicago"...

chicago_tz = pendulum.timezone('America/Chicago')
before_fold = pendulum.datetime(2024, 11, 3, 6, 0, 0, tz='utc').astimezone(chicago_tz)
after_fold = pendulum.datetime(2024, 11, 3, 7, 0, 0, tz='utc').astimezone(chicago_tz)

for test_dt in [before_fold, after_fold]:
    pickled_data = pickle.dumps(test_dt)
    unpickled_dt = pickle.loads(pickled_data)

    assert test_dt.timestamp() == unpickled_dt.timestamp()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions