You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For Django porject which TIME_ZONE is not UTC (Ex: In my case "Asia/Taipei")
freeze_time would face problem in some scenario
Case 1: @freeze_time(datetime(2024, 1, 1))
We will get timezone.now() == datetime(2024, 1, 1, 1, tzinfo=timezone.utc)
But timezone.now() return UTC time so I should get 2023/12/31 instead
Case 2: @freeze_time(datetime(2024, 1, 1, 0, 0, 0, tzinfo=pytz.timezone("Asia/Taipei")))
We will get datetime.now() == datetime(2023, 12, 31, 15, 54)
But datetime.now() return "Asia/Taipei" in this case so we should get 2024/01/01 instead
It may not the problem can be solve in freeze_gun
I think the case might happen if freeze_gun have no way to know django is going to change the
TIME_ZONE or impose something to datetime, in this case we might consider to close the issue directly, many thanks !
The text was updated successfully, but these errors were encountered:
For Django porject which
TIME_ZONE
is not UTC (Ex: In my case"Asia/Taipei"
)freeze_time
would face problem in some scenarioCase 1: @freeze_time(datetime(2024, 1, 1))
We will get
timezone.now() == datetime(2024, 1, 1, 1, tzinfo=timezone.utc)
But timezone.now() return UTC time so I should get 2023/12/31 instead
Case 2: @freeze_time(datetime(2024, 1, 1, 0, 0, 0, tzinfo=pytz.timezone("Asia/Taipei")))
We will get
datetime.now() == datetime(2023, 12, 31, 15, 54)
But datetime.now() return "Asia/Taipei" in this case so we should get 2024/01/01 instead
It may not the problem can be solve in freeze_gun
I think the case might happen if freeze_gun have no way to know django is going to change the
TIME_ZONE or impose something to datetime, in this case we might consider to close the issue directly, many thanks !
The text was updated successfully, but these errors were encountered: