1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
window.angular && (function(angular) {
'use strict';
angular.module('app.common.filters', [])
.filter(
'unResolvedCount',
function() {
return function(data) {
data = data.filter(function(item) {
return item.Resolved == 0;
});
return data.length;
}
})
.filter(
'quiescedToError',
function() {
return function(state) {
if (state.toLowerCase() == 'quiesced') {
return 'Error';
} else {
return state;
}
}
})
.filter('localeDate', function() {
return function(timestamp, utc = false) {
var dt = new Date(timestamp);
if (isNaN(dt)) {
return 'not available';
}
const ro = Intl.DateTimeFormat().resolvedOptions();
var tz = 'UTC';
if (!utc) {
tz = ro.timeZone;
}
// Examples:
// "Dec 3, 2018 11:35:01 AM CST" for en-US at 'America/Chicago'
// "Dec 3, 2018 5:35:01 PM UTC" for en-US at 'UTC'
// "Dec 3, 2018 17:35:01 GMT" for en-GB at 'Europe/London'
// "Dec 3, 2018 20:35:01 GMT+3" for ru-RU at 'Europe/Moscow'
// "Dec 3, 2018 17:35:01 UTC" for ru-RU at 'UTC'
return dt.toLocaleDateString('en-US', {
timeZone: tz,
month: 'short',
year: 'numeric',
day: 'numeric'
}) + ' ' +
dt.toLocaleTimeString(
ro.locale, {timeZone: tz, timeZoneName: 'short'});
}
});
})(window.angular);
|