Skip to content

Commit

Permalink
feat: date client for weather lol
Browse files Browse the repository at this point in the history
  • Loading branch information
PleahMaCaka committed Oct 31, 2023
1 parent a3cb098 commit f96306d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib/types/Date.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export enum DayOfWeek {
Sunday = 0,
Monday = 1,
Tuesday = 2,
Wednesday = 3,
Thursday = 4,
Friday = 5,
Saturday = 6
}
40 changes: 40 additions & 0 deletions src/lib/utils/DateClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { DayOfWeek } from "$lib/types/Date"

// noinspection JSUnusedGlobalSymbols
export const date = new class _ extends Date {

private readonly date = new Date()

public getFullMonth(): number {
let month = this.date.getMonth() + 1
if (month > 10) return Number("0" + month)
return month
}

public getDayOfWeek(yyyyMMdd: number | string): DayOfWeek {
const dayOfWeek = new Date(yyyyMMdd).getDay()
return dayOfWeek as DayOfWeek
}

public getDayOfWeekCurrentKr(): string { // lol
const dayOfWeek = new Date().getDay()
switch (dayOfWeek) {
case 0:
return "일"
case 1:
return "월"
case 2:
return "화"
case 3:
return "수"
case 4:
return "목"
case 5:
return "금"
case 6:
return "토"
}
return "??"
}

}

0 comments on commit f96306d

Please sign in to comment.