zopefoundation / DateTime

This package provides a DateTime data type, as known from Zope. Unless you need to communicate with Zope APIs, you're probably better off using Python's built-in datetime module.
Other
19 stars 25 forks source link

implicit datefmt #36

Closed georgpfolz closed 2 years ago

georgpfolz commented 2 years ago

I stumbled upon this when trying to create a DateTime object like this: DateTime.DateTime('2.4.2022'). The result was "DateTime('2022/02/04 00:00:00 GMT+1')" instead of "DateTime('2022/04/02 00:00:00 GMT+2')".

First I only saw the difference in the timezone, but obviously the date string is interpreted differently than I expected.

I realize that the correct way to create the object would have been DateTime.DateTime('2.4.2022', datefmt='international').

I'm from Austria, so I don't know exactly how dates are used in the US, but according to wikipedia it seems the notation with dots is not used for m/d/Y notation.

Wouldn't it be logical to assume the international order (d.m.Y) for strings with dots rather than the US-based order? (even if the argument datefmt is not passed explicitly)

icemac commented 2 years ago

I'd vote to not change the behavior of this ancient library. The changes to beak existing code in a non-obvious way are too big.

The rule of thumb for non US people is to always use datefmt='international'.

georgpfolz commented 2 years ago

OK, makes sense.