Commit a9e1e0de authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

add TimeStamp

parent f46b435d
import datetime import datetime
from astropy import time
def now(): def now():
""" Return ISOT8601 format datetime, for time stamps in data products. """ """ Return ISOT8601 format datetime, for time stamps in data products. """
...@@ -9,3 +11,16 @@ def now(): ...@@ -9,3 +11,16 @@ def now():
def now_dfs(): def now_dfs():
""" Return ISOT8601 format datetime, for DFS usage only. """ """ Return ISOT8601 format datetime, for DFS usage only. """
return datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') 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")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment