diff --git a/containers/ecr-viewer/src/app/services/formatService.tsx b/containers/ecr-viewer/src/app/services/formatService.tsx index 3ede27bdf..f8352c1cb 100644 --- a/containers/ecr-viewer/src/app/services/formatService.tsx +++ b/containers/ecr-viewer/src/app/services/formatService.tsx @@ -93,12 +93,12 @@ export const formatAddress = ( .join("\n"); }; -// TODO: get this mathing right for both timezoned and utc a;sodifha -// EDT => -4 -// Z => 0 -// none => 0 +// Return the offset from UTC for a dateTimeString given the original time zone string +// EDT => -04 +// Z => +00 +// none => +00 const getTimeZoneOffset = (dateTimeString: string, tzString: string | null) => { - if (tzString === null) return "+00"; + if (tzString === null) return formatTzOffset(0); const trueDate = new Date(dateTimeString); const notzDateString = dateTimeString.slice(0, -1 * tzString.length).trim(); @@ -113,6 +113,7 @@ const getTimeZoneOffset = (dateTimeString: string, tzString: string | null) => { // return formatTzOffset(date.getTimezoneOffset() / -60); // }; +// Format numeric offset in parser friendly '+/-dd' const formatTzOffset = (diffHr: number): string => { const prefix = diffHr < 0 ? "-" : "+"; const diffAbs = Math.abs(diffHr); @@ -120,14 +121,7 @@ const formatTzOffset = (diffHr: number): string => { return `${prefix}${postfix}`; }; -// 04 Dec 1995 00:12:00 GMT-5 -// 04 Dec 1995 00:12:00 -// 200401010924-0400 -// 200401010924 -// 08/04/2024 10:02 AM EDT -// 08/04/2024 10:02 AM -// 2019-01-16T12:19:10-05:00 -// 2019-01-16T12:19:10 +// Extract out the timezone part of the datetime string. Return null if none found. const getTimeZoneString = (dateTimeString: string): string | null => { // Z if (dateTimeString.match(/[0-9]Z$/)) {