fix: varTurn60에 밀리초 없음
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
import {parseISO} from 'date-fns';
|
||||
|
||||
export function parseTime(dateString: string): Date{
|
||||
return parseISO(dateString);
|
||||
if(dateString === null){
|
||||
console.warn('why null');
|
||||
console.trace();
|
||||
return new Date();
|
||||
}
|
||||
const tmp = parseISO(dateString);
|
||||
return tmp;
|
||||
}
|
||||
+5
-13
@@ -167,14 +167,6 @@ export class VarTurn60 {
|
||||
return formatTime(zoned, withFraction);
|
||||
}
|
||||
|
||||
private static addSecondsUTC(base: Date, sec: number): Date {
|
||||
return addSeconds(base, sec);
|
||||
}
|
||||
|
||||
private static addDaysUTC(base: Date, days: number): Date {
|
||||
return addDays(base, days);
|
||||
}
|
||||
|
||||
// ----- Core Logic -----
|
||||
|
||||
|
||||
@@ -183,7 +175,7 @@ export class VarTurn60 {
|
||||
const baseDayUTC = this.toSeoulMidnightUTC(utc);
|
||||
const zoned = toZonedTime(utc, this.TZ);
|
||||
|
||||
const totalSec = zoned.getHours() * 3600 + zoned.getMinutes() * 60 + zoned.getSeconds();
|
||||
const totalSec = zoned.getHours() * 3600 + zoned.getMinutes() * 60 + zoned.getSeconds() + zoned.getMilliseconds() / 1000;
|
||||
const min30 = Math.floor(totalSec / 1800);
|
||||
if (min30 < 0 || min30 >= 48) throw new RangeError('half-hour index out of range');
|
||||
const [turnIdx, minOffset] = this.min30ToTurn[min30];
|
||||
@@ -202,21 +194,21 @@ export class VarTurn60 {
|
||||
cutTurn(withFraction = true): [string, number] {
|
||||
const [hour, minOffset, turnTerm] = VarTurn60.turnToHM[this.turnIdx];
|
||||
const sec = (hour * 60 + minOffset) * 60;
|
||||
const date = VarTurn60.addSecondsUTC(this.baseDayUTC, sec);
|
||||
const date = addSeconds(this.baseDayUTC, sec);
|
||||
return [VarTurn60.format(date, withFraction), turnTerm];
|
||||
}
|
||||
|
||||
toDate(): Date {
|
||||
const [hour, minOffset] = VarTurn60.turnToHM[this.turnIdx];
|
||||
const sec = (hour * 60 + minOffset) * 60 + this.secOffset;
|
||||
const date = toZonedTime(VarTurn60.addSecondsUTC(this.baseDayUTC, sec), SEOUL_TZ);
|
||||
const date = toZonedTime(addSeconds(this.baseDayUTC, sec), SEOUL_TZ);
|
||||
return date;
|
||||
}
|
||||
|
||||
toDateStr(withFraction = true): string {
|
||||
const [hour, minOffset] = VarTurn60.turnToHM[this.turnIdx];
|
||||
const sec = (hour * 60 + minOffset) * 60 + this.secOffset;
|
||||
const date = VarTurn60.addSecondsUTC(this.baseDayUTC, sec);
|
||||
const date = addSeconds(this.baseDayUTC, sec);
|
||||
return VarTurn60.format(date, withFraction);
|
||||
}
|
||||
|
||||
@@ -253,7 +245,7 @@ export class VarTurn60 {
|
||||
}
|
||||
|
||||
const nextBaseDayUTC =
|
||||
dayDiff === 0 ? this.baseDayUTC : VarTurn60.addDaysUTC(this.baseDayUTC, dayDiff);
|
||||
dayDiff === 0 ? this.baseDayUTC : addDays(this.baseDayUTC, dayDiff);
|
||||
|
||||
return new VarTurn60(nextBaseDayUTC, nextTurnIdx, nextSecOffset);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user