Commit 3adb1224 authored by Etor Lucio Eceiza's avatar Etor Lucio Eceiza
Browse files

Make cftime convertion more flexible

parent c3c80085
......@@ -331,9 +331,12 @@ class Plotter:
except AttributeError:
return ''
except TypeError:
units = 'seconds since 1970-01-01:00:00'
tt = cftime.date2num(dset.time.values, units)
return cftime.num2date(tt, units).strftime(fmt)
units = 'days since 1970-01-01:00:00'
try:
tt = cftime.date2num(dset.time.values, units, has_year_zero=True)
return cftime.num2date(tt, units, has_year_zero=True).strftime(fmt)
except:
return ''
time_lt = time.astimezone(pytz.timezone(tz))
return time_lt.strftime(fmt)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment