DoESLiverpool / logcards

Basic RFID logging system used to control the doors and access to the space
http://wiki.doesliverpool.com/DoorBot
3 stars 0 forks source link

scans.log (at least) is not storing time correctly #13

Open johnmckerrell opened 5 years ago

johnmckerrell commented 5 years ago

While looking for a scan on the doorbots I found that they don't appear to be logging scans in the way we expect them to. The log file claims to be storing UTC times when in fact it appears to be using local time. I'm not sure where it's even getting the local time zone from but the following appears to suggest it:

94fa5964    2019-08-22 16:14:18 UTC
7b60b555    2019-08-22 20:00:46 UTC
pi@doorbot5:~/logcards $ date
Thu 22 Aug 19:08:26 UTC 2019

As you can see the last scan was apparently at 20:00 UTC, when the time is actually 19:08 UTC. To confirm this was actually at 20:08 BST/local time.

johnmckerrell commented 5 years ago

Ah, so appears this is a feature:

# Optional timezone, used for defining half-days of hotdesking
    timezone: "Europe/London"

and

       time = Time.now.utc
        if LCConfig.tz
          time = LCConfig.tz.utc_to_local(time)
        end
        today = Date.today.to_s
        scansFile.write("#{uid}\t#{time}\n")

Annoying that we end up stating UTC when its not so I'll leave this open to see if we can fix that. If not maybe we just make sure the scans file does store UTC.

ajlennon commented 5 years ago

I’m not understanding why the string representation of a local time would expand to a UTC time?