Skip to content

Any examples of custom zones? #1270

Answered by icambron
ccfoo242 asked this question in Q&A
Discussion options

You must be logged in to vote

To make a custom zone, you write an implementation of the Zone interface. Then you can pass instances of that object anywhere that takes zone for an argument. Luxon's own zones do the same thing, with additional convenience that we've aliased strings to them so that, say, setZone("utc") is equivalent to setZone(anInstanceOfUTCZone).

If you are OK passing a different kind of thing, you might not have to do much of anything, except something like:

const MISO = FixedOffsetZone.instance(-4 * 60);
const SPP = "America/Chicago";

and then pass those values into anything that accepts zone as an argument.

However, if what you're after is being able to pass the strings "MISO" and "SPP" as args, the…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ccfoo242
Comment options

Answer selected by ccfoo242
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants