dmitryelj / RPi-P2000Receiver

P2000 paging autonomous receiver with LCD and browser access
15 stars 7 forks source link

time in utc not local time #24

Closed Dinges28 closed 3 years ago

Dinges28 commented 3 years ago

followed your install manual, but my time showed in the browser is in utc not my local timezone. Current default time zone: 'Europe/Amsterdam' Local time is now: Thu May 27 22:28:30 CEST 2021. Universal Time is now: Thu May 27 20:28:30 UTC 2021.

2021-05-27 20:28:16 07.018. To: 002029568, 001423377, 001423001, 001420999 A2 (DIA: ja) AMBU 18177 Willem de Zwijgerstraat 2967EM Langerak LANGRK bon 70079

dmitryelj commented 3 years ago

The timestamp for FLEX messages is extracting from a multimon-ng output. If you do not want it, remove the line 664 "msg.timestamp = timestamp" from p2000.py.

cyberjunky commented 3 years ago

A quick fix:

in utils.py add this below import tzlocal

import calendar

in p2000.py around line 664 change this line: msg.timestamp = timestamp

to: msg.timestamp = utils.to_local_datetime(timestamp)

Add this at end of utils.py:

def to_local_datetime(utc_dt):

  time_tuple = time.strptime(utc_dt, "%Y-%m-%d %H:%M:%S")
  t = calendar.timegm(time_tuple)
  return time.ctime(t)