You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Python 3.6, the timespec argument was added to datetime.isoformat(...) and for good reason: depending on whether or not the datetime object has milliseconds, the isoformat() method returns a different structured string.
Pendulum's to_iso8601_string() has the same issue.
Here's how I resolved it:
iso_8601 = dt.to_iso8601_string()
if len(iso_8601) > 25:
# Contains microseconds and milliseconds. Remove.
iso_8601 = iso_8601[:19] + iso_8601[26:]
return iso_8601
However, I think this type of workaround (hack, really) should not be needed and the option to return only to a certain precision (hours, minutes, seconds, milliseconds and microseconds) should be supported in pendulum, as it is in datetime.
Note: this issue is similar to #191 but I think things changed since then, given the support of this feature by Python AND the fact that there are real world scenarios where it's needed.
The text was updated successfully, but these errors were encountered:
Itay4
linked a pull request
Mar 9, 2019
that will
close
this issue
In Python 3.6, the
timespec
argument was added todatetime.isoformat(...)
and for good reason: depending on whether or not thedatetime
object has milliseconds, theisoformat()
method returns a different structured string.Pendulum's
to_iso8601_string()
has the same issue.Here's how I resolved it:
However, I think this type of workaround (hack, really) should not be needed and the option to return only to a certain precision (hours, minutes, seconds, milliseconds and microseconds) should be supported in pendulum, as it is in datetime.
Note: this issue is similar to #191 but I think things changed since then, given the support of this feature by Python AND the fact that there are real world scenarios where it's needed.
The text was updated successfully, but these errors were encountered: