![]() To interoperate with libraries or other code that you didn't write, then you should implement all the other Temporal.TimeZone members as well: toString(), toJSON(), getOffsetStringFor(), getPlainDateTimeFor(), getInstantFor(), getNextTransition(), getPreviousTransition(), and toJSON(). However, most other code will assume that custom time zones act like built-in Temporal.TimeZone objects. The object must have at least getOffsetNanosecondsFor() and getPossibleInstantsFor() methods, and an id property.Īny object with those three methods will return the correct output from any Temporal property or method. The other, more difficult, way to create a custom time zone is to create a plain object implementing the Temporal.TimeZone protocol, without subclassing. Overriding all the other properties of is optional.Īny property that is not overridden will behave as in the base time zone. The class must override the id prototype property, and should override toString() and toJSON() to match. In the class's constructor, call super() with the identifier of a built-in time zone to serve as a base. You must use one of the built-in time zones as the "base time zone". The recommended way is to create a class inheriting from Temporal.TimeZone. Custom time zonesįor specialized applications where you need to do calculations in a time zone that is not built in, you can implement a custom time zone. Since Temporal.Instant and Temporal.PlainDateTime do not contain any time zone information, a Temporal.TimeZone object is required to convert between the two. or simply a particular UTC offset with no offset transitions. ![]() either an IANA time zone, including information about the time zone, such as the offset between the local time and UTC at a particular time, daylight saving time (DST) and other political UTC offset changes like a country having permanently changed its offset.Difference between IANA time zones and numeric UTC offsetsĪ Temporal.TimeZone is a representation of a time zone:.Do try it and report bugs don't use it in production!
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |