diff --git a/cal_tools/cal_tools/tools.py b/cal_tools/cal_tools/tools.py index f112c3cf089b62279ee18692ca719e37fd37ed7a..1b5707a3767f7934e92b218d591a214f70203a45 100644 --- a/cal_tools/cal_tools/tools.py +++ b/cal_tools/cal_tools/tools.py @@ -275,7 +275,8 @@ def get_dir_creation_date(directory: Union[str, Path], run: int, rfile = sorted(rfiles, key=path.getmtime)[0] with h5py.File(rfile, 'r') as fin: cdate = fin['METADATA/creationDate'][0].decode() - cdate = datetime.datetime.strptime(cdate, "%Y%m%dT%H%M%SZ") + cdate = datetime.datetime.strptime(cdate, + "%Y%m%dT%H%M%SZ").replace(tzinfo=datetime.timezone.utc) return cdate except (IndexError, IOError, ValueError): ntries -= 1 diff --git a/tests/test_cal_tools.py b/tests/test_cal_tools.py index 24d61719ce141e78e517e32cc02816e02228f40f..7fe26e12a9fb96a9a38f006311726da13ae46559 100644 --- a/tests/test_cal_tools.py +++ b/tests/test_cal_tools.py @@ -20,7 +20,7 @@ def test_dir_creation_date(): date = get_dir_creation_date(folder, 9983) assert isinstance(date, datetime) - assert str(date) == '2020-09-23 13:30:50' + assert str(date) == '2020-09-23 13:30:50+00:00' with pytest.raises(ValueError) as e: get_dir_creation_date(folder, 4)