From 3bc6d717f1c2178790b99fd3bf3626d9f51bdec1 Mon Sep 17 00:00:00 2001 From: Daniel Kirkham Date: Thu, 15 Sep 2016 15:50:33 +0100 Subject: [PATCH] microseconds is 0 where date is None --- cf_units/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cf_units/__init__.py b/cf_units/__init__.py index fc785906..850e4454 100644 --- a/cf_units/__init__.py +++ b/cf_units/__init__.py @@ -820,7 +820,7 @@ def _num2date_to_nearest_second(time_value, utime): dates = utime.num2date(time_values) try: # We can assume all or none of the dates have a microsecond attribute - microseconds = np.array([d and d.microsecond for d in dates]) + microseconds = np.array([d.microsecond if d else 0 for d in dates]) except AttributeError: microseconds = 0 round_mask = np.logical_or(has_half_seconds, microseconds != 0)