3 ms·
The real problem is that datetime.datetime.now() returns a naïve datetime. If only it returned something that contained the UTC offset in which is was created,
by munch117 4y ago
The real problem is that datetime.datetime.now() returns a naïve datetime.
If only it returned something that contained the UTC offset in which is was created, then all of this would be much easier to deal with. Conversions to timestamps would just work, and comparisons would just work.
Note that I said "UTC offset", not "timezone". datetime doesn't deal in UTC offsets, it deals in timezones. And timezones are a zillion times more complicated, which is why no one want to deal with them on the critical path, and no one has ever proposed having now() return an object with .tzinfo set. Logical though it may be.