I am writing a library and I don't want to require pytz since the library itself doesn't know or care about timezones (it's reading and writing data in the form of Unix timestamps, which don't have any timezone information associated with them). I always return new timestamps as aware datetimes using
dt.timezone.utc (i.e. something like
Will these timestamps interact sensibly (e.g. datetime subtraction produces correct results) with pytz timestamps like those you get from
pytz.localize(...), or do I need to use
It is ok to use
datetime.timezone.utc. You don't need to use
pytz.utc, only to cooperate with
utc timezone has a fixed utc offset (zero, always). Such tzinfo objects should work with any tzinfo implementations.