frigate icon indicating copy to clipboard operation
frigate copied to clipboard

Option to set timezone

Open ehn opened this issue 2 years ago • 2 comments

What I am trying to accomplish and why in non-technical terms

I want to be able to set a timezone and configure Frigate to use that in the UI so that I can see, for example, when an event occurred in a way that makes sense when thinking about the location where the camera is installed and communicating with people onsite. When accessing Frigate from other timezones, using the browser timezone forces the user to manually add or subtract the time difference.

The solution I'd like

Set a timezone in Frigate's config and have it use that throughout the UI.

Alternatives I've considered

There is a Chrome extension that can be used to change the browser timezone, but that would mess up other websites that one wants in the local timezone.

ehn avatar Jan 11 '23 13:01 ehn

I just realized I think this is a duplicate of https://github.com/blakeblackshear/frigate/issues/2838

NickM-27 avatar Jan 11 '23 15:01 NickM-27

Maybe partially? Some of #2838 seems to be about inconsistencies, which I think are fixed in 0.12? Storing everything internally in UTC is great and the correct way IMHO. My issue is only about presentation.

ehn avatar Jan 11 '23 15:01 ehn

Will be nice to have that possibility. Set timezone for web ui as @ehn mention. Iam using privacy care browsers with small fingerprint, and i have those problems with wrong time presentations of clips :) For example in mull browser.

edit: I must add also that on that browser i get not only wrong time (from wrong timezone) but also PM/AM :) so that function only for web ui presentation will be nice :)

skupi20 avatar Jan 13 '23 09:01 skupi20

I pull latest version and timezone not work for me. I found in code

const timezone = config.ui?.timezone

this question mark its not a mistake?

skupi20 avatar Jan 14 '23 10:01 skupi20

It's not. How did you set the timezone in your config?

blakeblackshear avatar Jan 14 '23 12:01 blakeblackshear

I pull latest version and timezone not work for me. I found in code

const timezone = config.ui?.timezone

this question mark its not a mistake?

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining

ehn avatar Jan 14 '23 13:01 ehn

i tried Europe/Warsaw and later pl-PL, but on my phone i still get am/fm and wrong hour

skupi20 avatar Jan 14 '23 14:01 skupi20

Am/pm will not change from this change, it's only timezone not locale. I'll have to test that and see but I tried a bunch of different America/ values and they worked as expected

NickM-27 avatar Jan 14 '23 14:01 NickM-27

Looks like my cleanup on the recordings side broke the timezone part, will take a look

NickM-27 avatar Jan 14 '23 14:01 NickM-27

Fixed in https://github.com/blakeblackshear/frigate/pull/5086

NickM-27 avatar Jan 14 '23 14:01 NickM-27

So this works in most parts of the UI, but not all. When viewing snapshots, the embedded timestamp seems to be using the server time (which should be in UTC), disregarding the timezone setting in the config file.

ehn avatar Feb 16 '23 21:02 ehn

@ehn yeah the option is under the UI category so wouldn't expect it to affect the snapshots timestamp, that would be a separate request (and honestly a separate option in the config most likely)

NickM-27 avatar Feb 16 '23 22:02 NickM-27

Oh, ok. Is there any conceivable situation where one would want different timezones for the UI and embedded timestamps?

ehn avatar Feb 16 '23 22:02 ehn

Oh, ok. Is there any conceivable situation where one would want different timezones for the UI and embedded timestamps?

Probably not, but you never know. I suppose using the UI option wouldn't be an issue, but it may not be intuitive if a user was just looking for a way to set the timezone of the timestamp

NickM-27 avatar Feb 16 '23 22:02 NickM-27

I thought about this some more and was able to come up with one scenario where you might want different timezones for the snapshot timestamps and the surrounding UI: if you are pulling in video feeds from multiple sites in different timezones. Not sure if that's a reasonable use case, though.

I have two sites that are 6–7 hours apart. Currently, I'm running two Frigate instances, which makes more sense to me, but I suppose I could run just one, in which case I'd want per-camera timezone settings. It seems a bit excessive, though. Arguably, in the vast majority of cases, there will be a site timezone that should be used throughout the entire UI, including embedded timestamps.

One counterargument is that, while the UI timezone can be changed, once something is written to a snapshot image, it's there forever. Based on that, one could argue that embedded timestamps should always be in UTC. Then I'd also argue for using ISO 8601 format including the timezone to make that clear: 2023-02-17T08:06:54+00:00.

ehn avatar Feb 17 '23 08:02 ehn

One small issue remains: If you go to recordings, it will say something like "Dates and times are based on the browser's timezone Asia/Singapore". This is technically incorrect if you have set the timezone in the config file. Just removing "browser's" would be a simple fix that doesn't require keeping track of where and how the timezone was set.

(Let me know if you want me to create a new issue for this.)

ehn avatar Feb 17 '23 08:02 ehn

One small issue remains: If you go to recordings, it will say something like "Dates and times are based on the browser's timezone Asia/Singapore". This is technically incorrect if you have set the timezone in the config file. Just removing "browser's" would be a simple fix that doesn't require keeping track of where and how the timezone was set.

(Let me know if you want me to create a new issue for this.)

Fixed for the next beta

NickM-27 avatar Feb 17 '23 17:02 NickM-27

@NickM-27 I don't think there was ever a conclusion in this thread about how to handle the timezone of embedded timestamps, which currently seems to be UTC (or host timezone, which IMHO should always be UTC for a server regardless of physical location). Should it adhere to the UI config? Should there be a separate setting? Should this be discussed in a separate issue?

ehn avatar Mar 14 '23 07:03 ehn

Nick is taking some time off this week, but he messaged me about this already and we will get it fixed for the next beta when he returns.

blakeblackshear avatar Mar 14 '23 13:03 blakeblackshear

@ehn if suggest making a feature request for timezone configuration in the snapshots. That's a separate change unrelated to anything done in 0.12 (it works the same as before)

NickM-27 avatar Mar 16 '23 12:03 NickM-27

Done: #5755

ehn avatar Mar 17 '23 02:03 ehn