mirror of
https://github.com/home-assistant/frontend.git
synced 2025-06-29 13:36:35 +00:00
25 lines
620 B
JavaScript
25 lines
620 B
JavaScript
import fecha from 'fecha';
|
|
|
|
// Check for support of native locale string options
|
|
function toLocaleStringSupportsOptions() {
|
|
try {
|
|
new Date().toLocaleString('i');
|
|
} catch (e) {
|
|
return e.name === 'RangeError';
|
|
}
|
|
return false;
|
|
}
|
|
|
|
export default (toLocaleStringSupportsOptions() ?
|
|
function (dateObj, locales) {
|
|
return dateObj.toLocaleString(locales, {
|
|
year: 'numeric',
|
|
month: 'long',
|
|
day: 'numeric',
|
|
hour: 'numeric',
|
|
minute: '2-digit',
|
|
});
|
|
} : function (dateObj, locales) { // eslint-disable-line no-unused-vars
|
|
return fecha.format(dateObj, 'haDateTime');
|
|
});
|