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