#35858: Issue with make_aware Function Causing Timezone Conversion Errors with 
pytz
---------------------------+--------------------------------------
     Reporter:  acture     |                    Owner:  acture
         Type:  Bug        |                   Status:  closed
    Component:  Utilities  |                  Version:  5.0
     Severity:  Normal     |               Resolution:  invalid
     Keywords:  timezone   |             Triage Stage:  Unreviewed
    Has patch:  0          |      Needs documentation:  0
  Needs tests:  0          |  Patch needs improvement:  0
Easy pickings:  1          |                    UI/UX:  0
---------------------------+--------------------------------------
Changes (by Sarah Boyce):

 * resolution:   => invalid
 * status:  assigned => closed
 * summary:  Issue with make_aware Function Causing Timezone Conversion
     Errors =>
     Issue with make_aware Function Causing Timezone Conversion Errors with
     pytz

Comment:

 Since Django 4.0, [https://docs.djangoproject.com/en/5.1/releases/4.0
 /#zoneinfo-default-timezone-implementation zoneinfo is the default
 timezone implementation].
 I believe you shouldn't be using pytz here
 {{{#!python
 from datetime import datetime
 from django.utils.timezone import make_aware
 from zoneinfo import ZoneInfo

 time_str = "2024-10-22"
 time_obj = datetime.strptime(time_str, "%Y-%m-%d")
 shanghai_tz = ZoneInfo("Asia/Shanghai")

 django_aware_time = make_aware(time_obj, timezone=shanghai_tz)
 print(f"django_aware_time: {django_aware_time}")
 }}}
 Returns `django_aware_time: 2024-10-22 00:00:00+08:00`
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35858#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070192b3413fe7-31e9adab-f92a-4907-96fa-4175935d3d49-000000%40eu-central-1.amazonses.com.

Reply via email to