You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the course of reviewing the spec draft, I see that the from() method, perhaps others as well, accept both a string and an Object input. I have a preference for making calls to any kind of parser look explicit.
Where can I read about the motivation for these methods accepting both strings and Objects? Was the ergonomic hit from splitting the functions to one that parses string input and one that takes structured data deemed unacceptable?
The text was updated successfully, but these errors were encountered:
Sorry, I meant to respond to this yesterday, but digging up the relevant discussions took some time 😄
On both from() as well as other methods accepting strings we have had it both ways at some point during the proposal's history, before settling on the status quo. For a unified from() vs separate from() and fromString() methods, the discussion is in #230. There doesn't seem to be a lot of background there and it was before I started working on this, so maybe @pipobscure could weigh in.
For other methods, the status quo is that any entry point that accepts a Temporal object can also accept the corresponding ISO string. The main reason for settling on this change was due to collecting feedback from JS developers and starting to write cookbook examples using the polyfill ourselves, and discovering that it's really cumbersome and makes code less readable to call from() explicitly if you are effectively providing a literal value and not a variable, e.g. dt.since(Temporal.PlainDateTime.from('2000-01-01')) instead of the more concise dt.since('2000-01-01').
Relevant discussions about accepting strings in other methods:
In the course of reviewing the spec draft, I see that the
from()
method, perhaps others as well, accept both a string and an Object input. I have a preference for making calls to any kind of parser look explicit.Where can I read about the motivation for these methods accepting both strings and Objects? Was the ergonomic hit from splitting the functions to one that parses string input and one that takes structured data deemed unacceptable?
The text was updated successfully, but these errors were encountered: