pendulum
pendulum copied to clipboard
Default datetime string format changed in 3.0 release
- [x] I have searched the issues of this repo and believe that this is not a duplicate.
Issue
The pendulum docs say "The default string representation is the same as the one returned by the isoformat() method."
This was true in Pendulum 2, but is no longer true in Pendulum 3. This could be a breaking change for users that are casting pendulum datetimes to strings.
In Pendulum 2:
>>> import pendulum
>>> str(pendulum.now())
'2024-01-29T16:00:38.678167-06:00'
In Pendulum 3:
>>> import pendulum
>>> str(pendulum.now())
'2024-01-29 16:00:23.305698-06:00'
>>>
This changed to be consistent with the stdlib:
>>> import pendulum
>>> import datetime
>>> print(datetime.datetime.now(tz=datetime.timezone.utc))
2024-05-08 16:37:28.783379+00:00
>>> print(pendulum.now(tz=datetime.timezone.utc))
2024-05-08 16:37:31.622175+00:00
IMO it's a good, if breaking, change. It was also called out in the changelog but it should've probably had bold letters and indicated it's a breaking change.
@edgarrmondragon all docs are still mentioning that default str representation is iso :)
Is there anyway to override the current behaviour to same as v2?