ariebovenberg / whenever

⏰ Sensible and typesafe datetimes for Python
https://whenever.rtfd.io
MIT License
362 stars 7 forks source link

In what way is The behavior of UTC, fixed offset, or IANA timezone datetimes very different when it comes to ambiguity #44

Closed metaperl closed 4 months ago

metaperl commented 4 months ago

At https://dev.arie.bovenberg.net/blog/python-datetime-pitfalls/#1-incompatible-concepts-are-squeezed-into-one-class we read:

The behavior of UTC, fixed offset, or IANA timezone datetimes is very different when it comes to ambiguity, for example.

But:

  1. what "ambiguity" is the author talking about? Are there any examples of it?
  2. what "different behavior" results?

Also:

what does the sentence in question have to do with a section titled "Incompatible concepts are squeezed into one class"? In my opinion, UTC, fixed offset, or IANA timezone datetimes do not represent incompatiable concepts squeezed into one class. Therefore this sentence should be removed from the document or this particular issue needs another section and with clear examples of "ambiguity" and "different behavior" to substantiate it.

As it stands right now, we have claims without examples or substantation in a section they do not belong.

ariebovenberg commented 4 months ago

👋 Hi there.

Interesting. Thanks for taking a fine-toothed comb through my article 👍

Taking your remarks one-by-one:

we have claims without examples or substantiation...

The behavior of UTC, fixed offset, or IANA timezone datetimes is very different when it comes to ambiguity, for example.

Indeed this is not well formulated. What I should have said:

While UTC/fixed-offset and IANA timezoned datetimes are both "aware", they differ on the fundamental topic of ambiguity. While the former is always unambiguous, the latter requires disambiguation for timezone transitions (e.g. DST). When translating these concepts into Python classes, two different APIs are probably warranted.

what do you think?

...in a section they do not belong.

You're right that it was confusing that I added this point in the "incompatible concepts" section. "incompatible concepts" clearly references naive/aware while my point about nuances in the "aware" category are not incompatibilities.

I should probably preface the paragraph better, indicating that it's a related issue—but doesn't concern 'incompatibility'

ariebovenberg commented 4 months ago

Here is my revised paragraph. What do you think?

There is another critique of this 'one class' approach: although mutually compatible, aware datetimes can take fundamentally different forms. UTC and fixed-offset datetimes are always unambiguous, while IANA timezoned datetimes require disambiguation sometimes. This warrents different APIs: One which allows users to avoid ambiguity, and another which forces users to explicitly handle it.

metaperl commented 4 months ago

UTC and fixed-offset datetimes are always unambiguous, while IANA timezoned datetimes require disambiguation sometimes.

You have to forgive me. I am a professional Python developer, but I am very unfamiliar with dates and times. So, when you say " IANA timezoned datetimes require disambiguation sometimes." I am wondering:

  1. what is an IANA timezone? should the author have linked to some docs on what an IANA timezone is?
  2. when the author uses the term 'disambiguation ' what is ambiguous about IANA timezoned datetimes? What options exist that make IANA timezoned datetimes ambiguous?
ariebovenberg commented 4 months ago
  1. With "IANA timezone" I mean "an entry in the IANA timezone database". There are plenty of resources only if you want to read about its history and use.
  2. times in IANA timezones can be ambiguous because entries in the database (for example Europe/Paris) have different UTC offsets over time. This means, for example, that when the clock is turned back due to Daylight Savings time at 3am, the time 2:30am occurs twice (once before the clock was turned back, and one after). here is a more in-depth explanation.
ariebovenberg commented 4 months ago

Closing this issue as answered. Feel free to open issues for other questions 👍