1export default function (dayjs, expTimeDJ, expiredTextParam) { 2 const nowJS = dayjs(); 3 4 if (nowJS.isSameOrAfter(expTimeDJ)) { 5 return { 6 text: expiredTextParam || 'Expired', 7 isExpired: true, 8 }; 9 } 10 11 const duration = dayjs.duration(expTimeDJ.diff(nowJS)); 12 13 if (duration.as('days') >= 1 && duration.as('days') < 2) { 14 if (duration.get('hours') === 1) { 15 return { 16 text: duration.format('D [day,] H [hour]'), 17 isExpired: false, 18 }; 19 } 20 21 return { 22 text: duration.format('D [day,] H [hours]'), 23 isExpired: false, 24 }; 25 } 26 27 if (duration.as('days') >= 1) { 28 return { 29 text: duration.format('D [days,] H [hours]'), 30 isExpired: false, 31 }; 32 } 33 34 if (duration.as('hours') >= 1) { 35 return { 36 text: duration.format('H:mm:ss'), 37 isExpired: false, 38 }; 39 } 40 41 if (duration.as('hours') < 1) { 42 return { 43 text: duration.format('mm:ss [mins]'), 44 isExpired: false, 45 }; 46 } 47}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.