dbader / schedule

Python job scheduling for humans.
https://schedule.readthedocs.io/
MIT License
11.62k stars 954 forks source link

.hour.at() broken in some cross-timezone cases #584

Closed SijmenHuizenga closed 9 months ago

SijmenHuizenga commented 1 year ago
with mock_datetime(2023, 4, 28, 23, 15):
    # Current Berlin time: apr-28 23:15 (local) (during daylight saving)
    # Current India time: apr-29 02:45
    # Expected to run India time: apr-29 03:00
    # Next run Berlin time: apr-28 23:30
    # Expected idle seconds: 900 (15 minutes)
    schedule.clear()
    next = every().hour.at("03:00", "Asia/Kolkata").do(mock_job).next_run

    print(next)

    assert next.day == 28
    assert next.hour == 23
    assert next.minute == 30
    assert schedule.idle_seconds() == 900

This fails with next = 2023-04-28 20:33:00. Probably there is a bug somewhere, but I'm not entirely sure where it is. Does anyone know what is going on?

AnezeR commented 1 year ago

Isn't it an issue with pytz?

dshetyo commented 1 year ago

I am facing similar issue. See this https://github.com/dbader/schedule/issues/592

SijmenHuizenga commented 9 months ago

Resolved with #583 and released in 1.2.1