Timezone for datetime.date objects

Cameron Simpson cs at cskk.id.au
Sun Feb 27 16:17:57 EST 2022


On 27Feb2022 11:16, Morten W. Petersen <morphex at gmail.com> wrote:
>I was initially using the date object to get the right timespan, but 
>then
>found that using the right timezone with that was a bit of a pain.  So I
>went for the datetime object instead, specifying 0 on hour, minute and
>second.
>
>What's the thinking behind this with the date object?  Wouldn't it be nice
>to be able to specify a timezone?

This has come up before. My own opinion is that no, it would be a bad 
idea. You're giving subday resolution to an object which is inherently 
"days". Leaving aside the many complications it brings (compare two 
dates, now requiring timezone context?) you've already hit on the easy 
and simple solution: datetimes.

I'd even go so far as to suggest that if you needed a timezone for 
precision, then dates are the _wrong_ precision to work in.

Anyway, personally I am -1 on the idea.

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Python-list mailing list