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

Skip to content

Commit 36a6d81

Browse files
committed
Fix to csv2rec bug for review
Datetime strings in csv files in dayfirst or yearfirst format with nonzero hour&minute&second will not be properly represented. Date strings will, presuming the csv file contains no strings in that column that have nonzero hour/minute/second components in a datetime string.
1 parent 2b97396 commit 36a6d81

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

lib/matplotlib/mlab.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2833,7 +2833,13 @@ def mybool(x):
28332833
raise ValueError('invalid bool')
28342834

28352835
dateparser = dateutil.parser.parse
2836-
mydateparser = with_default_value(dateparser, datetime.date(1, 1, 1))
2836+
2837+
def mydateparser(x):
2838+
# try and return a datetime object
2839+
d = dateparser(x, dayfirst=dayfirst, yearfirst=yearfirst)
2840+
return d
2841+
mydateparser = with_default_value(mydateparser, datetime.datetime(1,1,1,0,0,0))
2842+
28372843
myfloat = with_default_value(float, np.nan)
28382844
myint = with_default_value(int, -1)
28392845
mystr = with_default_value(str, '')

0 commit comments

Comments
 (0)