round to whole seconds
the steps are serialized as f32, and the resulting imprecision was leading to decimal values closes #1203
This commit is contained in:
parent
dcb7dc41de
commit
4c2a598be4
@ -9,6 +9,7 @@ test("whole steps", () => {
|
||||
expect(stepsToString(steps)).toBe(string);
|
||||
expect(stringToSteps(string)).toStrictEqual(steps);
|
||||
});
|
||||
|
||||
test("fractional steps", () => {
|
||||
const steps = [1 / 60, 5 / 60, 1.5, 400];
|
||||
const string = "1s 5s 90s 400m";
|
||||
@ -16,6 +17,11 @@ test("fractional steps", () => {
|
||||
expect(stringToSteps(string)).toStrictEqual(steps);
|
||||
});
|
||||
|
||||
test("rounding", () => {
|
||||
const steps = [0.1666666716337204];
|
||||
expect(stepsToString(steps)).toBe("10s");
|
||||
});
|
||||
|
||||
test("parsing", () => {
|
||||
expect(stringToSteps("")).toStrictEqual([]);
|
||||
expect(stringToSteps(" ")).toStrictEqual([]);
|
||||
|
@ -38,7 +38,7 @@ function minutesToString(step: number): string {
|
||||
if ([TimespanUnit.Months, TimespanUnit.Years].includes(unit)) {
|
||||
unit = TimespanUnit.Days;
|
||||
}
|
||||
const amount = unitAmount(unit, secs);
|
||||
const amount = Math.round(unitAmount(unit, secs));
|
||||
|
||||
return `${amount}${unitSuffix(unit)}`;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user