The Intl.RelativeTimeFormat API
developers.google.com
developers.google.com
rtf.format(3.14, Intl.RelativeTimeFormat.SECOND);If they're constants you can look at all constants available for Intl.RelativeTimeFormat, IDEs can do autocomplete, analysers can check if the value is valid and alert if not. That's just off the top of my head; I imagine there are even more reasons.
Thanks for feedback!
I understand where your suggestion is coming from, but please, take into account that we are designing the API to fit into the whole ECMA402 Intl API model.
The API we ended up with seems to be more consistent with it than what you suggested. It also allows us to, in the future extend it to compound units more easily.
Saying that, if you have a motivational o help us, come to ecma402 and review our active proposals! We have a bunch such as Intl.Locale, Number first revision, ListFormat etc :) That's a great time to work on the design of them!
Hope that helps!
Plenty of existing JS APIs do the stringly thing here, so the proper thing for a checker to do is just check the strings.
Try putting your cursor between the quotes here and hit ctl-space: http://www.typescriptlang.org/play/#src=fetch(%7B%0D%0A%20%2...
> It is the caller's responsibility to handle cut-off logic such as deciding between displaying "in 7 days" or "in 1 week". This API does not support relative dates involving compound units. e.g "in 5 days and 4 hours".
Specifying the locale is optional, and you can specify a list that will be matched against the user agent's preferences.
That seems like it'd make the API quite significantly less convenient: it becomes unusable on its own and pretty much has to be wrapped in a helper of some sort.
Moment.js does it, and I never felt like it wasn't what I wanted: https://momentjs.com/docs/#/displaying/fromnow/
I think a lean api without a lot of business rules is the way to go
Besides, most implementations keep the absolute date format in the alt tooltip if you need it.
Can't wait until this available in electronjs (sufficient browser support is as always likely to take a while longer)
Why? Considering the baseline size (both on-disk and in-memory) it's not like relative formatting has much of an impact, unlike genuine websites/web applications.
(TIL also that "semester" means "six months". I'm an idiot, I thought it was "half-length period". Like "semi" I guess.)
The point here is not to talk about an innovation, but about the eventuality of an up-to-date, API built into browsers such that eventually it will not be necessary for each and every application to ship and keep updating such a formatting subsystem themselves.