Time Zone Provider
To obtain a correct local time in JavaScript Prysm needs to know about your time zone. The product has a default implementation that queries the OS for it, but since time zone correctness is either unnecessary or expensive you can provide your own implementation.
The default implementation for Sony PlayStation and Nintendo Switch does not offset
Date.now()
from the UTC zone.The Time Zone Provider interface resides in include/cohtml/ITimeZoneProvider.h
.
The UTC standard uses leap seconds. What is more different time zones change their UTC/DST offsets due to political reasons. To return a correct UTC/DST offset for a time point one needs to consult a database for the leap seconds and a database for the history of the zone. It is not possible to correctly return a result for the future. The API callbacks receive a time point for which to return a result but to reduce complexity Prysm
ITimeZoneProvider
implementations ignore it and return a result for the current point in time. They also assume that DST is always 1 hour.To override the default code you have to implement the interface and pass an object to a View
through the ViewSettings::TimezoneProvider
initialization option.
You are responsible for the lifetime of the
ITimeZoneProvider
implementation object. A View
can use it as long as it is alive.You can pass a different
ITimeZoneProvider
to each view or have a single one shared by all of them.Prysm calls methods of the interface when needed. The methods receive a UTC time point and are expected to return one of the following:
- Time offset from the UTC zone.
- Time offset for daylight savings time if it is in effect.
- The name of the time zone that you are in.
For an example implementation you can check the Modules/TimeZoneProvider
folder.