diff --git a/apps/main/src/utils/getAge.test.ts b/apps/main/src/utils/getAge.test.ts index 92a7c3a..9b98459 100644 --- a/apps/main/src/utils/getAge.test.ts +++ b/apps/main/src/utils/getAge.test.ts @@ -1,7 +1,6 @@ import { testing } from "./getAge" -const { birth, dateFormatOption, getAge, ageInt, ageDecimal, isOverBirthDay } = - testing +const { birth, getAge, ageInt, ageDecimal, isOverBirthDay } = testing describe("getAge tests", () => { test("birthday to be 2002-07-30", () => { @@ -73,15 +72,6 @@ describe("getAge tests", () => { expect(isOverBirthDay(date)).toEqual(testData.overBD) }) - test("dateFormatOption to work properly", () => { - expect( - new Date("2002-07-30, 00:00:00.000 +09:00").toLocaleString( - "en-US", - dateFormatOption - ) - ).toEqual("7/30/2002, 00:00:00.000 GMT+09:00") - }) - test("ageInt to work", () => { expect(ageInt(birth)).toEqual(0) expect(ageInt(new Date("2023-07-29"))).toEqual(20) diff --git a/apps/main/src/utils/getAge.ts b/apps/main/src/utils/getAge.ts index 2eb84b8..9ddebc6 100644 --- a/apps/main/src/utils/getAge.ts +++ b/apps/main/src/utils/getAge.ts @@ -1,32 +1,12 @@ -const dateFormatOption: Intl.DateTimeFormatOptions = { - timeZone: "Asia/Seoul", - timeZoneName: "longOffset", - hourCycle: "h23", - year: "numeric", - month: "numeric", - day: "numeric", - hour: "numeric", - minute: "numeric", - second: "numeric", - fractionalSecondDigits: 3, -} - // my birthday in KST :D -const birth = new Date( - new Date("2002-07-30, 00:00:00.000 +09:00").toLocaleString( - "en-US", - dateFormatOption - ) -) +const birth = new Date("2002-07-30, 00:00:00.000 +09:00") /** * Gets developomp's age with decimal precision * * @param now - current `Date` in KST */ -export default function getAge( - now: Date = new Date(new Date().toLocaleString("en-US", dateFormatOption)) -): number { +export default function getAge(now: Date = new Date()): number { return ageInt(now) + ageDecimal(now) } @@ -76,7 +56,6 @@ function isOverBirthDay(now: Date): boolean { export const testing = { birth, - dateFormatOption, getAge, ageInt, ageDecimal,