vangheem / pyzipcode

revive the pyzipcode project!
MIT License
14 stars 11 forks source link

Is timezone returned accounting for daylight savings? #2

Open EricPHassey opened 4 years ago

EricPHassey commented 4 years ago

We return timezone, however is the offset provided accounting for daylight savings time?

verhovsky commented 3 years ago

Use the zipcode.dst property for that.

https://en.wikipedia.org/wiki/Daylight_saving_time_in_the_United_States

Currently in America most regions observe DST (Arizona and Hawaii are notable exceptions, but not the only ones):

The DST switch starts on the second Sunday in March and ends on the first Sunday in November.

In pyzipcode, zipcode.timezone always returns the same UTC offset, which is the time when not in DST, i.e. before March. For each zip code, zipcode.dst will either be 0 (if DST is not observed in that zip code) or 1 if it is. Use zipcode.timezone when you are not in DST and use zipcode.timezone + zipcode.dst to get the UTC offset when you are in DST (which again, is between March and November).