Skip to content

Commit

Permalink
fix: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmcgrath13 committed Jan 7, 2025
1 parent 252ae31 commit 1cfaf9f
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions containers/ecr-viewer/src/app/services/formatService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -113,21 +113,15 @@ 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);
const postfix = diffAbs < 10 ? `0${diffAbs}` : `${diffAbs}`;
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$/)) {
Expand Down

0 comments on commit 1cfaf9f

Please sign in to comment.