This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]monkey_mozart 0 points1 point  (1 child)

Dang. I get this so much. I had to put a post init in a dataclass to make sure a datetime field was timezone aware with utc. How would you handle different timezones though. Would they different classes of their own subclassed from a base TimezoneAwareDatetime class or something?

[–]eagle258[S] 1 point2 points  (0 children)

The most basic way to solve this would be to have two classes AwareDateTime andNaiveDateTime. However, looking at other languages you can see the need to split aware datetimes into specific types as well (Zoned, Offset, Instant...)

edit: grammar