mozilla-b2g/gaia — pull request #3706 by fabi1cazenave (2012-08-22 14:50:25+00:00)
Title: [l10n] localized date/time formats

See issue #2217. The idea is to:
* add a `DateTimeFormat` constructor to the `navigator.mozL10n` object (not unlike the [ES.next draft](http://wiki.ecmascript.org/doku.php?id=globalization:specification_drafts) proposal);
* implement a `localeFormat` method that would be an equivalent of the [toLocaleFormat](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toLocaleFormat) one, but which really localizes the date/time strings;
* as a bonus, implement a `fromNow` method to handle “pretty dates”;
* store shared l10n resources in the `shared/locales` directory, like we do for JS scripts.

Example, suppose the current language is set to French:

```javascript
var today = new Date();
var date = today.toLocaleFormat("%c");
```

result: `Wed 22 Aug 2012 16:43:47` (incorrect)

```javascript
var today = new Date();
var fmt = new navigator.mozL10n.DateTimeFormat();
var date = fmt.localeFormat(today, "%c");
```

result: `mer 22 aoû 2012 16:43:47` (correct)

Suggestions concerning the API are very welcome. @stasm, what’s your opinion on this?

This has been applied to the lockscreen, it could be applied for all other Gaia apps if this lands.