Mr Joker
Mr Joker

Reputation: 1

Python Daylight Savings Accomodation

Iam working on a django project. Im fairly new to it. I have a requirement to sent out email reports in which I need to convert datetimes into yours local timezone. Im saving records in utc time and I have users time zone with me.

Iam using the python package pytz to convert utc time into user's local time. The convsersion is working fine. No issues there.

from pytz import timezone as pytz_timezone input_time.astimezone(pytz_timezone(time_zone) This is how i convert utc time into user's local time

Im confused with Daylight savings time. I want to know whether this conversion will also account for daylight savings? Suppose the user is in New South Wales so he will have the time_zone as 'Australia/Sydney'. If the above mentioned code is applied during DST and not during DST , is it accounted in the conversion or do I need to add some other manipulation to the converted user local time to account for the DST. if so what should I do?

I hope my confusion and question makes sense.

Thanks in advance.

Upvotes: 0

Views: 35

Answers (0)

Related Questions