Skip to content

Commit

Permalink
Wherever datetime converted to Unix time, note other places
Browse files Browse the repository at this point in the history
 * If update the conversion in one place, need to update it everywhere
   for consistency.
  • Loading branch information
jtniehof authored and dnadeau-lanl committed Oct 20, 2020
1 parent 861667e commit 20afffc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dbprocessing/DButils.py
Expand Up @@ -1492,6 +1492,8 @@ def addFile(self,
r.file_id = d1.file_id
# Round times down so they don't slide into next second
# (and potentially next day)
# If changed, also change getFiles, addUnixTimeTable,
# updateUnixTime.py
r.unix_start = None if utc_start_time is None \
else int((utc_start_time - unx0)\
.total_seconds())
Expand Down Expand Up @@ -1760,6 +1762,7 @@ def getFiles(self,
# and non-truncated start time of file is 1.6) but better than
# missing a file that does overlap (e.g requested start time is 1.2
# and non-truncated file start is 1.6, truncates to 1.0)
# If changed, also change addFile, addUnixTimeTable, updateUnixTime.py
if startTime is not None:
startTime = Utils.toDatetime(startTime)
if unixtime:
Expand Down Expand Up @@ -2683,6 +2686,7 @@ def addUnixTimeTable(self):
for f in self.getFiles(): # Populate the times
r = self.Unixtime()
r.file_id = f.file_id
# If changed, also change addFile, getFiles, updateUnixTime.py
r.unix_start = int((f.utc_start_time - unx0)\
.total_seconds())
r.unix_stop = int((f.utc_stop_time - unx0)\
Expand Down
2 changes: 2 additions & 0 deletions scripts/updateUnixTime.py
Expand Up @@ -44,6 +44,8 @@ def main(mission):
unx0 = datetime.datetime(1970, 1, 1)
for f in dbu.getFiles(): # Populate the times
r = dbu.getEntry('Unixtime', f.file_id)
# If changed, also change addFile, addUnixTimeTable, getFiles
# (all in DButils)
r.unix_start = int((f.utc_start_time - unx0)\
.total_seconds())
r.unix_stop = int((f.utc_stop_time - unx0)\
Expand Down

0 comments on commit 20afffc

Please sign in to comment.