add minutes to the time until..
This commit is contained in:
@@ -6,6 +6,7 @@ const noTime = () => ({
|
|||||||
hours: 0,
|
hours: 0,
|
||||||
months: 0,
|
months: 0,
|
||||||
seconds: 0,
|
seconds: 0,
|
||||||
|
minutes: 0,
|
||||||
years: 0,
|
years: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ describe("time until", () => {
|
|||||||
months: 0,
|
months: 0,
|
||||||
days: 0,
|
days: 0,
|
||||||
hours: 0,
|
hours: 0,
|
||||||
|
minutes: 0,
|
||||||
seconds: 0,
|
seconds: 0,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -36,11 +38,12 @@ describe("time until", () => {
|
|||||||
vi.setSystemTime(fakeNow)
|
vi.setSystemTime(fakeNow)
|
||||||
|
|
||||||
expect(timeUntil("2024-02-12T19:34:22.200Z")).toStrictEqual({
|
expect(timeUntil("2024-02-12T19:34:22.200Z")).toStrictEqual({
|
||||||
|
years: 0,
|
||||||
|
months: 10,
|
||||||
days: 30,
|
days: 30,
|
||||||
hours: 10,
|
hours: 10,
|
||||||
months: 10,
|
minutes: 9,
|
||||||
seconds: 2062,
|
seconds: 2062,
|
||||||
years: 0,
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -61,6 +64,7 @@ describe("has passed", () => {
|
|||||||
months: 0,
|
months: 0,
|
||||||
days: 0,
|
days: 0,
|
||||||
hours: 0,
|
hours: 0,
|
||||||
|
minutes: 0,
|
||||||
seconds: 1,
|
seconds: 1,
|
||||||
})
|
})
|
||||||
).toBeFalsy()
|
).toBeFalsy()
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export interface TimeUntilReturn {
|
|||||||
months: number
|
months: number
|
||||||
days: number
|
days: number
|
||||||
hours: number
|
hours: number
|
||||||
|
minutes: number
|
||||||
seconds: number
|
seconds: number
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,12 +19,13 @@ export const timeUntil = (target: string): TimeUntilReturn => {
|
|||||||
months: 0,
|
months: 0,
|
||||||
days: 0,
|
days: 0,
|
||||||
hours: 0,
|
hours: 0,
|
||||||
|
minutes: 0,
|
||||||
seconds: 0,
|
seconds: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const interval = dateTimeTarget
|
const interval = dateTimeTarget
|
||||||
.diff(now, ["years", "months", "days", "hours", "seconds"])
|
.diff(now, ["years", "months", "days", "hours", "minutes", "seconds"])
|
||||||
.toObject()
|
.toObject()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -31,6 +33,7 @@ export const timeUntil = (target: string): TimeUntilReturn => {
|
|||||||
months: interval.months ? Math.round(interval.months) : 0,
|
months: interval.months ? Math.round(interval.months) : 0,
|
||||||
days: interval.days ? Math.round(interval.days) : 0,
|
days: interval.days ? Math.round(interval.days) : 0,
|
||||||
hours: interval.hours ? Math.round(interval.hours) : 0,
|
hours: interval.hours ? Math.round(interval.hours) : 0,
|
||||||
|
minutes: interval.minutes ? Math.round(interval.minutes) : 0,
|
||||||
seconds: interval.seconds ? Math.round(interval.seconds) : 0,
|
seconds: interval.seconds ? Math.round(interval.seconds) : 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user