-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Read-only OS time formatting preferences #171
Comments
There a several similar preferences that the API should either expose now, or be able to add in the future - timezone selection manual/automatic, showing/hiding dayperiod (am/pm) for 12h clock, showing/hiding seconds etc. |
I propose the following API:
Also, applications which want to customize the time display according to the OS defaults, and they need to be notified when the OS defaults change in order to have a chance to update their UI. Therefore, I think we need to queue a task to fire a simple event named |
@ehsan - If we decide to add another time formatting setting API like this in the future (let's say, ampm display), will we want I'm wondering if it would make sense to plan the API to handle more than one setting (and get one event for all time/date formatting options)? |
What is "ampm display"? If you mean displaying AM/PM next to times, is that not the same as hour12?
I usually prefer specific solutions to specific problems. I don't think we should try to create anything generic here, all we're talking about is a boolean flag. :) |
What is the benefit of the "system" prefix? Also, if we return "boolean" we cannot return "undefined", which appears to be necessary per the referenced bug. I think we'll need to use "any" or maybe "(boolean or undefined)" but I don't think that's allowed. @heycam? |
No. See MacOS settings screenshot for an example: http://imgur.com/FxosgeL It means that the same time (14:23) can be formatted as:
So, my thought is that there seem to be a set of options that user specifies in his settings app that should be exposed, read-only, to the web developer. Examples (from macos):
I don't see a need to specify that now, but if we standardize it, I'd be worried about specifying each one of them separately on |
We wouldn't add a new API just to collect stuff from elsewhere. |
ok, sounds good! |
This seems out of scope for HTML. It is rather part of the ES internationalization API, I would think. Otherwise, I'd expect HTML to grow a huge family of APIs for exposing current system locale settings. |
E.g. in .NET their equivalent of the internationalization API contains a CultureInfo.CurrentCulture static value which contains all the locale settings currently present. You then pass these CultureInfo objects to various formatting methods (DateTimeOffset.ToString, etc.). I really think only the ES internationalization working group will have the expertise to develop the correct system here. |
@domenic the ES Internationalization API doesn't expose system settings. |
Sure. But I think the ES API should. It's useful in more than just the browser. Alternately, the 402 group could work on a separate spec extending navigator. Either way, out of scope for HTML. |
It makes the name different to
That is true. We can also return an enum with three values if the above is not an option. |
@caridy - what do you think? Should we take this into Ecma 402? I feel like there are three ways we can slice it:
|
@domenic How would an ES level solution notify the application when the system settings change? |
yes, we can take part of this into 402, open the issues in the ecma 402 repo. |
@domenic I really don't see why this would be out of scope, but |
Right, the only way currently to do that is to use "any". (It's on my todo list to add an "undefined" IDL type to make this easier.) |
@annevk Let me clarify a bit. This isn't necessarily out of scope, in that HTML is the kitchen sink and we can justifiably say that anything is in its scope. However, the OP and the couple of posts following it make it clear that this is a pretty large new undertaking, which ideally integrates deeply with the work done in 402, e.g. allowing passing of this "culture info" or "locale data" object to 402's toLocale{String,DateString,TimeString,LowerCase,UpperCase} overloads or to its Intl.{Collator,DateTimeFormat,NumberFormat} constructors. It would need to integrate with 402's existing notion of locale data, for example. And it would need to tease out the relationship between intrinsic locale data, derived directly from a language tag, and user preferences. (Possibly the former sets defaults that can be overridden by the latter? Possibly user preferences create a new locale, that doesn't have a language tag? Not my area of expertise, but I am sure these problems have been solved before...) Thus, I think an undertaking like this should ideally be developed in tandem with those 402 APIs for best integration, and maintained by a group that has good familiarity with those APIs and can work alongside those editors (or maybe that group should just be the 402 editors). Making it the responsibility of the HTML editors seems like a bad idea, especially since it doesn't gain anything compared to a separate spec. There are no deep hooks into the HTML spec needed; this would be a fine extension spec. Maybe even |
as for events, this is tricky for fee reasons:
|
It really isn't. I am quite puzzled by why you think that. |
Here is what the equivalent work looked like for .NET: I appreciate the OP contained only an incomplete version of DateTimeFormatInfo, i.e. hour12. But then in the second post onward it started expanding to dayperiodstyle---which already mismatches 402, so we're having a group coordination problem here. Other 402 options that might change due to user settings include timeZone and the various formatting parameters, or even the calendar. hourNo0 also is treated as similar to hour12 in 402, so I am not sure why hour12 is included but hourNo0 is not. If this is going to be an incompletely-done solution, I don't want it in HTML; we should have higher standards for this spec. If it's going to be a completely done solution with good 402 integration, then I think it needs domain expertise outside of what HTML offers. The speed to which people have jumped to nitty-gritty IDL details, and your incomprehension of how large this problem space is, are worrying... |
As an idea to get things started, something that integrates better with 402 might be something like |
I don't fully understand what would be I would expect similar Does it make sense? Wrt. scope. Currently all we need is a single true/false/undefined variable. I wanted to plan it ahead for additional data, but @ehsan suggested to focus on the task at hand which I agree with. So I see it as a single variable and a single event when the variable changes. HTML seems better suited IMO. |
Because Intl.DateTimeFormat instances are what you use to format datetimes, you should have one representing the user's current preferences for how to format datetimes. You can use |
@domenic are the maintainers of 402 interested in extending |
@annevk no, we are not interested on Aside from that, settings like |
@annevk I really do not like the framing of this as "a couple of properties and events". It should integrate better with 402's primitives, e.g. as in #171 (comment). Even if the 402 group is not interested in extending navigator, I'd expect their help and sign-off on any design of this sort. |
@zbraniecki is this still something you want to pursue in the HTML Standard? |
I think we have come to "agreement" on the idea of using |
Thanks, what does BC mean? |
backward-compatible since it is a new member of navigator. |
I see, so should we introduce these members in the HTML Standard or will something else introduce an extension of sorts? Anyone willing to provide a PR? |
All operating systems allow user to select time format. Usually between 12h, 24h or follow automatic.
Firefox OS is currently providing
navigator.mozHour12
that can take true/false/undefined values and that nicely fits into Intl API:When "use default" is used,
mozHour
is undefined and Intl uses the defaulthour12
value for the given locale. IfmozHour
is specified to eithertrue
orfalse
, Intl API follows that.There's also an event associated with it:
timeformatchange
that is dipatched onwindow
.The text was updated successfully, but these errors were encountered: