From 5ad5dfe718b98bf64d1c1132ce7509de9cfbec75 Mon Sep 17 00:00:00 2001 From: BO ZHANG Date: Wed, 20 Dec 2023 11:45:46 +0800 Subject: [PATCH] use astropy.time --- csst_common/time.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/csst_common/time.py b/csst_common/time.py index 4585138..a6bd1f0 100644 --- a/csst_common/time.py +++ b/csst_common/time.py @@ -7,15 +7,21 @@ Created: 2023-03-09 Modified-History: 2023-03-09, Bo Zhang, created 2023-03-09, Bo Zhang, add two time formats + 2023-12-20, Bo Zhang, use astropy.time """ -import datetime +from astropy import time def now(): - """Return ISOT8601 format datetime, for time stamps in data products.""" - return datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%f") + """Return ISOT format datetime using `astropy`.""" + return time.Time.now().isot -def now_dfs(): - """Return ISOT8601 format datetime, for DFS usage only.""" - return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") +# def now(): +# """Return ISOT8601 format datetime, for time stamps in data products.""" +# return datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%f") + + +# def now_dfs(): +# """Return ISOT8601 format datetime, for DFS usage only.""" +# return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") -- GitLab