{"action":"created","issue":{"url":"https://api.github.com/repos/tc39/ecma402/issues/108","repository_url":"https://api.github.com/repos/tc39/ecma402","labels_url":"https://api.github.com/repos/tc39/ecma402/issues/108/labels{/name}","comments_url":"https://api.github.com/repos/tc39/ecma402/issues/108/comments","events_url":"https://api.github.com/repos/tc39/ecma402/issues/108/events","html_url":"https://github.com/tc39/ecma402/issues/108","id":183158971,"number":108,"title":"short/medium/long/full style for Intl.DateTimeFormat","user":{"login":"zbraniecki","id":449986,"avatar_url":"https://avatars.githubusercontent.com/u/449986?v=3","gravatar_id":"","url":"https://api.github.com/users/zbraniecki","html_url":"https://github.com/zbraniecki","followers_url":"https://api.github.com/users/zbraniecki/followers","following_url":"https://api.github.com/users/zbraniecki/following{/other_user}","gists_url":"https://api.github.com/users/zbraniecki/gists{/gist_id}","starred_url":"https://api.github.com/users/zbraniecki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zbraniecki/subscriptions","organizations_url":"https://api.github.com/users/zbraniecki/orgs","repos_url":"https://api.github.com/users/zbraniecki/repos","events_url":"https://api.github.com/users/zbraniecki/events{/privacy}","received_events_url":"https://api.github.com/users/zbraniecki/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-10-14T21:56:18Z","updated_at":"2016-10-18T17:57:50Z","closed_at":null,"body":"I'm working on trying to design an alignment between how Intl API works and OS Intl preferences work.\r\n\r\nAn example of such task is how to incorporate the date/time formatting OS user preferences into DateTimeFormat API.\r\n\r\nCurrently, we expect users of our API to list the elements of the date/time format as options, or, if none are listed, we take:\r\n - for `Intl.DateTimeFormat` and `Date.prototype.toLocaleString`: hour/minute/second/day/month/year as `numeric`\r\n - for `Date.prototype.toLocaleTimeString`: hour/minute/second as `numeric`\r\n - for `Date.prototype.toLocaleDateString`: day/month/year as `numeric`\r\n\r\nOn the other hand, MacOS exposes four styles for date and time: short, medium, long and full.\r\nWindows exposes short/long.\r\n\r\nI see two solutions to bind those two APIs:\r\n\r\n1) Create OS Intl prefs API that returns Intl API options.\r\n\r\n```javascript\r\nlet opts = intlOSPrefs.DateFormat(intlOSPrefs.formatFull);\r\n  --> returns {weekday: 'long', month: 'long', day: 'numeric', year: 'numeric'}\r\nlet dtf = new Intl.DateTimeFormat(navigator.locales, opts);\r\ndtf.format(date);\r\n```\r\n\r\n2) Add `style` option and change how we handle \"defaults\" in Intl.DateTimeFormat\r\n\r\nIn this approach, we would use the language in spec similar to one we use for timezones: if user did not specify a timezone, we try to retrieve it from the host OS and we land on the current defaults (all as `numeric`) only if we cannot get anything from the OS.\r\n\r\n```javascript\r\ndate.toLocaleString() == date.toLocaleString(navigator.locales, {\r\n  style: 'medium'\r\n}) == date.toLocaleString(navigator.locales, {\r\n  day: 'numeric',\r\n  month: 'short',\r\n  year: 'numeric'\r\n}); // In MacOS\r\n\r\ndate.toLocaleDateString(navigator.locales, {\r\n  style: 'long'\r\n}) == date.toLocaleString(navigator.locales, {\r\n  day: 'numeric',\r\n  month: 'long',\r\n  year: 'numeric'\r\n}); // default in MacOS\r\n\r\n\r\ndate.toLocaleDateString(navigator.locales, {\r\n  style: 'full'\r\n}) == date.toLocaleString(navigator.locales, {\r\n  weekday: 'long',\r\n  day: 'numeric',\r\n  month: 'long',\r\n  year: 'numeric'\r\n}); // default in MacOS\r\n```\r\n\r\nThat would require adding an additional step in `12.1.2 ToDateTimeOptions` as `6.a` and `7.a` where the implementation could reach to host OS for the preferences and only fallback to the current `6.a` and `7.a` if those cannot be retrieved.\r\n\r\nIn this approach, `style` option would be mutually exclusive with any of the token options.\r\n\r\nOpinions? @caridy , @rxaviers , @jungshik, @srl295 ?"},"comment":{"url":"https://api.github.com/repos/tc39/ecma402/issues/comments/254588037","html_url":"https://github.com/tc39/ecma402/issues/108#issuecomment-254588037","issue_url":"https://api.github.com/repos/tc39/ecma402/issues/108","id":254588037,"user":{"login":"jfkthame","id":1706499,"avatar_url":"https://avatars.githubusercontent.com/u/1706499?v=3","gravatar_id":"","url":"https://api.github.com/users/jfkthame","html_url":"https://github.com/jfkthame","followers_url":"https://api.github.com/users/jfkthame/followers","following_url":"https://api.github.com/users/jfkthame/following{/other_user}","gists_url":"https://api.github.com/users/jfkthame/gists{/gist_id}","starred_url":"https://api.github.com/users/jfkthame/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfkthame/subscriptions","organizations_url":"https://api.github.com/users/jfkthame/orgs","repos_url":"https://api.github.com/users/jfkthame/repos","events_url":"https://api.github.com/users/jfkthame/events{/privacy}","received_events_url":"https://api.github.com/users/jfkthame/received_events","type":"User","site_admin":false},"created_at":"2016-10-18T17:57:50Z","updated_at":"2016-10-18T17:57:50Z","body":"Mapping preferences retrieved from the OS to values for the year/month/day/hour/minute/second/etc options is not sufficient to fully support the flexibility of OS formatting patterns (if that's a desired goal).\r\n\r\nFor example, in Mac OS X and Windows, users can customize the order of the components and the separators between them, as well as the format used for each individual components of the date/time. AFAICS, this is not exposed by Intl.DateTimeFormat in any way; the options can be used to control which components are present, and which format is used for each component, but *not* their order nor any literal separators used between them.\r\n"}}
{"actor":{"display_login":"jfkthame"}}