diff --git a/cal_tools/cal_tools/tools.py b/cal_tools/cal_tools/tools.py index 363dd51c8a821b4f9645896887b4772a91ddcb72..4212ee96fc829152d399ab32736396dfd35c9d74 100644 --- a/cal_tools/cal_tools/tools.py +++ b/cal_tools/cal_tools/tools.py @@ -425,7 +425,7 @@ def get_notebook_name(): return environ.get("CAL_NOTEBOOK_NAME", "Unknown Notebook") -def get_dir_creation_date(directory, run): +def get_dir_creation_date(directory, run, tsdir=False): """ Return modification time of [directory]/[run]04 @@ -433,8 +433,14 @@ def get_dir_creation_date(directory, run): :param run: run number :return: (datetime) modification time """ - creation_time = stat("{}/r{:04d}".format(directory, run)).st_mtime - creation_time = datetime.datetime.fromtimestamp(creation_time) + if tsdir: + creation_time = stat("{}/r{:04d}".format(directory, run)).st_mtime + else: + rfiles = glob("{}/r{:04d}/*.h5".format(directory, run)) + rfiles.sort(key=path.getmtime) + creation_time = stat(rfiles[0]).st_mtime + + creation_time = datetime.datetime.fromtimestamp(creation_time) return creation_time