[Tutor] Formatting questions regarding datetime.isoformat()

eryksun eryksun at gmail.com
Thu Sep 6 10:23:23 CEST 2012


On Thu, Sep 6, 2012 at 3:50 AM, Dave Angel <d at davea.name> wrote:
> On 09/06/2012 03:35 AM, eryksun wrote:
>> <Snip>
>> Or you could use datetime.now(dateutil.tz.tzutc()) for a UTC tzinfo.
>> It doesn't matter if you're only interested in the timedelta.
>
> Actually, it can matter.  Whenever possible, produce all times as UTC
> and do your manipulations (eg. difference) in that space.  With local
> time, there are times that don't exist and times that are ambiguous, one
> in the fall and one in the spring, due to setting the clock forward or back.
>
> i don't know for sure if it matters here, but I've found it's better to
> work that way.

These are aware datetime objects. See the datetime docs for supported
operations, case 3, timedelta = datetime1 - datetime2:

http://docs.python.org/library/datetime#datetime.datetime.tzinfo


More information about the Tutor mailing list