Skip to content

PlainTime.prototype.toString() includes seconds by default. Possible to set smallestUnit: "minutes" as a global default? #260

Answered by justingrant
revosw asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for the question! No, there is no global default. ECMAScript generally avoids global state, because one user's changes can affect other code.

But here's a few possible ways you could customize things to get what you want:

  • You could use a custom JSON.stringify replacer function.
  • You could patch Temporal.prototype.toJSON, but there's danger there because if your code calls into other libraries that use Temporal, then your patching could break them.
  • You could build an API wrapper

Good luck with your project!

Replies: 1 comment 1 reply

Comment options

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

Answer selected by revosw
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