Skip to content

Commit

Permalink
Merge pull request #17 from nicolas-f/utcpatch
Browse files Browse the repository at this point in the history
use utc epoch for day switch
  • Loading branch information
nicolas-f authored Jun 22, 2022
2 parents 49aaf91 + c105f6b commit a05a9c4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions service/noisesensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def run(self):


def build_csv_path(folder, epoch):
return os.path.join(folder, datetime.date.fromtimestamp(epoch).strftime("%Y_%m_%d.csv"))
return os.path.join(folder, datetime.datetime.utcfromtimestamp(epoch).strftime("%Y_%m_%d.csv"))


class CsvWriter(threading.Thread):
Expand All @@ -474,8 +474,9 @@ def run(self):
while len(self.fast) > 0:
new_epoch = self.fast[0][0]
if len(rows_to_write) > 0:
# break if we change to a new day
if datetime.date.fromtimestamp(epoch).day != datetime.date.fromtimestamp(new_epoch).day:
# break if we change to a new day (in UTC)
if datetime.datetime.utcfromtimestamp(epoch).day != \
datetime.datetime.utcfromtimestamp(new_epoch).day:
break
else:
epoch = new_epoch
Expand Down

0 comments on commit a05a9c4

Please sign in to comment.