Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ad55256

Browse files
author
Paul G
committed
Modified strftime code so it only falls back to this other routine when necessary.
Signed-off-by: Paul G <[email protected]>
1 parent 35b93d2 commit ad55256

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/matplotlib/dates.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,9 +491,11 @@ def strftime(self, dt, fmt):
491491
fmt = fmt.replace("%s", "s")
492492

493493
# strftime is not supported on datetime for years <= 1900 in Python 2.x
494-
# or years <= 1000 in Python 3.x
495-
if dt.year > 1900:
494+
# or years <= 1000 in Python 3.3. Raises ValueError on failure.
495+
try:
496496
return cbook.unicode_safe(dt.strftime(fmt))
497+
except ValueError:
498+
pass
497499

498500
year = dt.year
499501
# For every non-leap year century, advance by

0 commit comments

Comments
 (0)