Skip to content
Snippets Groups Projects

DataFile: Don't write creationDate & updateDate unless specified

Merged Thomas Kluyver requested to merge fix/rm-default-timestamp into master
1 unresolved thread
1 file
+ 14
9
Compare changes
  • Side-by-side
  • Inline
+ 14
9
from datetime import datetime
from datetime import datetime, timezone
from itertools import chain
from numbers import Integral
from pathlib import Path
@@ -310,14 +310,20 @@ class DataFile(h5py.File):
if sequence is None:
sequence = self.__sequence
if creation_date is None:
creation_date = datetime.fromtimestamp(0, tz=timezone.utc)
elif creation_date is True:
creation_date = datetime.now(timezone.utc)
if update_date is None:
update_date = creation_date
elif update_date is True:
update_date = datetime.now(timezone.utc)
md_group = self.require_group('METADATA')
if creation_date is not None:
md_group.create_dataset(
'creationDate', shape=(1,),
data=creation_date.strftime('%Y%m%dT%H%M%SZ').encode('ascii'))
md_group.create_dataset(
'creationDate', shape=(1,),
data=creation_date.strftime('%Y%m%dT%H%M%SZ').encode('ascii'))
md_group.create_dataset('daqLibrary', shape=(1,),
data=daq_library.encode('ascii'))
md_group.create_dataset('dataFormatVersion', shape=(1,), data=b'1.2')
@@ -358,10 +364,9 @@ class DataFile(h5py.File):
'runNumber', shape=(1,), dtype=np.uint32, data=run)
md_group.create_dataset(
'sequenceNumber', shape=(1,), dtype=np.uint32, data=sequence)
if update_date is not None:
md_group.create_dataset(
'updateDate', shape=(1,),
data=update_date.strftime('%Y%m%dT%H%M%SZ').encode('ascii'))
md_group.create_dataset(
'updateDate', shape=(1,),
data=update_date.strftime('%Y%m%dT%H%M%SZ').encode('ascii'))
class ControlSource(h5py.Group):
Loading