feat: 밤 시작을 21시 고정에서 일몰 1시간 뒤로 (계절 따라)
This commit is contained in:
1 parent
c00623e690
commit
498e4d677a
5 files changed
+18
-13
No files matched your search
@@ -97,11 +97,12 @@ export type TimeKind = 'morning' | 'day' | 'sunset' | 'night'
|
||||
// 서울 월별 대략 일몰 시각(시). 서버 값(/v1/feed hero.sky_mode)이 없을 때만 쓴다
|
||||
const SUNSET_HOUR = [17.7, 18.2, 18.6, 19.1, 19.5, 19.9, 19.9, 19.5, 18.9, 18.2, 17.6, 17.3]
|
||||
|
||||
/** 피드와 같은 시간대: 아침 05–11 · 낮 11–일몰 2시간 전 · 저녁(sunset) 일몰 2시간 전–21 · 밤 21–05 */
|
||||
/** 피드와 같은 시간대: 아침 05–11 · 낮 11–일몰 2시간 전 · 저녁(sunset) 일몰 2시간 전–일몰 1시간 뒤 · 밤 일몰 1시간 뒤–05 */
|
||||
export function kindOfHour(h: number, month = new Date().getMonth() + 1, minute = 0): TimeKind {
|
||||
const at = h + minute / 60
|
||||
const sunset = SUNSET_HOUR[month - 1]
|
||||
if (at >= 5 && at < 11) return 'morning'
|
||||
if (at >= 11 && at < 21) return at < SUNSET_HOUR[month - 1] - 2 ? 'day' : 'sunset'
|
||||
if (at >= 11 && at < sunset + 1) return at < sunset - 2 ? 'day' : 'sunset'
|
||||
return 'night'
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user