There is code for this living https://github.com/mozilla-b2g/gaia/blob/master/shared/js/l10n_date.js#L64 ?