Locale format for last sync date

This commit is contained in:
Mo Bitar
2018-07-18 21:10:34 -05:00
parent 57a140e272
commit 382c40cfa6
2 changed files with 18 additions and 6 deletions

View File

@@ -1,3 +1,6 @@
// reuse
var locale, formatter;
angular.module('app')
.filter('appDate', function ($filter) {
return function (input) {
@@ -6,6 +9,20 @@ angular.module('app')
})
.filter('appDateTime', function ($filter) {
return function (input) {
if (typeof Intl !== 'undefined' && Intl.DateTimeFormat) {
if (!formatter) {
locale = (navigator.languages && navigator.languages.length) ? navigator.languages[0] : navigator.language;
formatter = new Intl.DateTimeFormat(locale, {
year: 'numeric',
month: 'numeric',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
});
}
return formatter.format(input);
} else {
return input ? $filter('date')(new Date(input), 'MM/dd/yyyy h:mm a') : '';
};
}
}
});