Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
csst-pipeline
csst_common
Commits
a9e1e0de
Commit
a9e1e0de
authored
Jul 07, 2023
by
BO ZHANG
🏀
Browse files
add TimeStamp
parent
f46b435d
Changes
1
Hide whitespace changes
Inline
Side-by-side
csst_common/time.py
View file @
a9e1e0de
import
datetime
from
astropy
import
time
def
now
():
""" Return ISOT8601 format datetime, for time stamps in data products. """
...
...
@@ -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
"
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment