Loading csst_common/time.py +15 −0 Original line number Diff line number Diff line import datetime from astropy import time def now(): """ Return ISOT8601 format datetime, for time stamps in data products. """ Loading @@ -9,3 +11,16 @@ def now(): def now_dfs(): """ Return ISOT8601 format datetime, for DFS usage only. """ return datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') class TimeStamp: def __init__(self, file_path=""): self.file_path = file_path def truncate(self): with open(self.file_path, 'w') as file: file.truncate(0) def punch_in(self): with open(self.file_path, "a+") as f: f.write(f"{time.Time.now().isot}+00:00\n") Loading
csst_common/time.py +15 −0 Original line number Diff line number Diff line import datetime from astropy import time def now(): """ Return ISOT8601 format datetime, for time stamps in data products. """ Loading @@ -9,3 +11,16 @@ def now(): def now_dfs(): """ Return ISOT8601 format datetime, for DFS usage only. """ return datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') class TimeStamp: def __init__(self, file_path=""): self.file_path = file_path def truncate(self): with open(self.file_path, 'w') as file: file.truncate(0) def punch_in(self): with open(self.file_path, "a+") as f: f.write(f"{time.Time.now().isot}+00:00\n")