-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relative time/dates #35
Comments
@zbraniecki, now that we are ready to start working on the 3rd edition (using this repo), I plan to champion the relative time feature based on the initial work that we did on https://github.com/yahoo/intl-relativeformat. Do you want to help? |
absolutely. We're currently using a very nasty hack for that[1] and I'd love to see some better, possibly CLDR based, API for that. |
I could not find "a few minutes ago" data in CLDR, nor the "one", "less than", etc... Here is the initial spec: https://github.com/caridy/intl-relative-time-spec, and here is the HTML version https://rawgit.com/caridy/intl-relative-time-spec/master/index.html |
That looks awesome! Thanks @caridy I'll play with this against our use cases more, but first thing I miss here is pure duration. You have "X ago" and "in X", but you don't have "X". Examples:
|
Hmm, the more I think about this the more I feel like there's a direct overlap area between three proposals:
First of all, there are three modes - future (in 5 minutes), past (5 minutes ago) and "neutral" (5 minutes). Second, there may be specific maximum unit to show - "50000" meters is "50km", and "5000000" meters is "5000km". Same for "12000000" minutes being "50000h". I think that however incremental we want to take it, we should design the API to be forward compatible to allow ourselves to add the next bits later. |
|
|
@caridy @zbraniecki the "neutral form" (or sometimes referred to as absolute time) you are talking about is called "unit" - #37 :) as you may already figured out. |
@rxaviers - So #37 is about abbreviation, but #32 is about units. Did you mean #32? Should we keep it separate from this API? I feel like they overlap a lot and I feel tempted to try to address future/past/absolute in one API, but I don't have much experience designing APIs like that so I can imagine that there may be an obvious reason not to. |
@caridy - in CLDR the "absolute time" is part of Duration Patterns - http://unicode.org/repos/cldr/trunk/specs/ldml/tr35-general.html#durationUnit I'm talking about things like: Is it part of your plan for this API? |
@zbraniecki that's a good question, we need some bikeshedding on this topic I guess. Obviously that fits into the relative time paradigm since you have to use %Date.now% to compute the lapse. The other part of the equation is to figure whether or not %Date.now% is a default value of a configuration option, allowing users to provide the pivot, just like we do in intl-relativeformat, that probably makes more sense for the absolute, but it is proven to be useful for past and future as well. |
Yeah, I mocked it today for our code in Clock/Timer/Stopwatch app and I used something like that:
I can see it becoming a separate formatter or becoming part of RelativeFormat. |
Whoops, yeap I meant #32 you're correct.
I agree with you that these three forms overlap. But, I'm not too convinced RelativeTimeFormat should include an absolute form. Because, FormatUnit can be used for that purpose.
I see the above as FormatUnit plus an abbreviation modifier. It just happens that it's easier to think of abbreviating 1000 into 1K, or $1,000,000 into $1M because they are powers of 10. The above unit abbreviations require that the abbreviation logic know how to convert units that are not powers of 10, including time. PS: Eventually, there might be an API that gracefully unifies all the three (relative time formatting, unit formatting, and abbreviation). So far, I think FormatUnit is a foundation similar to what FormatPlural is for MessageFormat (or possible a different more sophisticated API for formatting messages). |
sounds great! |
@rxaviers that's the same conclusion we arrived yesterday when discussing this issue. |
;) |
I separated discussion about |
update: we are cooking the proposal for the next meeting in two weeks. |
Heads up, this has been advanced to Stage 0 as of today. |
This proposal has been advanced to Stage 1 as of today. |
Today I submitted the patch proposal for an internal Gecko API mozIntl.RelativeTimeFormat which is based on the ECMA402 - https://bugzilla.mozilla.org/show_bug.cgi?id=1270140 I also submitted suggestions for the spec changes based on my implementation experience. |
|
I don't remember that happening... I thought we just go to Stage 2, and we had to go back and make the changes that were suggested in the previous meeting. |
My bad. The notes were confusing. I corrected the stages2 - RTF is in Stage 2. |
In other news, RTF landed behind the flag in SpiderMonkey - https://bugzilla.mozilla.org/show_bug.cgi?id=1270140 |
I guess there are more languages like German. Korean also has special words for the day after tomorrow and the day before yesterday. Actually, it has special words for 3 days ago and 3 days from today. |
As with unit format, I wonder what the plan is for 'more than one units'. 3 days and 5 hours ago |
we can support those in the future by providing an option for more accuracy. |
Just dropping by to say that I implemented a polyfill for the current |
|
The spec has the above provision. I wonder why minIntDigits is set to 2. That leads to zero-padding likes '04 days ago', 'In 05 hours' instead of '4 days ago' / 'In 5 hours'. |
Should we just closed this issue now since we already have Intl.RelativeTimeFormat in Stage 3? |
We can close this when the corresponding proposal reaches Stage 4 and is merged. This issue has the tag "active proposal". |
|
Thanks @anba; this proposal is now Stage 4 and merged. Closing as Fixed |
There are two major areas where relative time/date formatting could use standardization:
Good example are timers - representing time like "31 hours, 15 minutes and 23 seconds" as "31:15:23".
A lot of web apps humanize relative date and time with messages like:
All of those patterns are available in CLDR and it would enable web authors to provide better user interfaces if we could incorporate this kind of formatting either into DateTimeFormat or into a separate RelativeDateTimeFormat.
The text was updated successfully, but these errors were encountered: