fix floor in times

This commit is contained in:
Sebastian 2023-06-05 11:24:25 -03:00
parent 75fdf6137f
commit 6e7c88a620
No known key found for this signature in database
GPG Key ID: 173909D1A5F66069

View File

@ -81,7 +81,7 @@ export namespace TalerPreciseTimestamp {
export function fromSeconds(s: number): TalerPreciseTimestamp {
return {
t_s: Math.floor(s),
off_us: (s - Math.floor(s)) / 1000 / 1000,
off_us: Math.floor((s - Math.floor(s)) / 1000 / 1000),
};
}
@ -89,7 +89,7 @@ export namespace TalerPreciseTimestamp {
return {
t_s: Math.floor(ms / 1000),
off_us: Math.floor((ms - Math.floor(ms / 100) * 1000) * 1000),
}
};
}
}
@ -254,7 +254,7 @@ export namespace Duration {
};
}
return {
d_ms: d.d_us / 1000,
d_ms: Math.floor(d.d_us / 1000),
};
}
@ -371,7 +371,7 @@ export namespace AbsoluteTime {
}
const offsetUs = t.off_us ?? 0;
return {
t_ms: t.t_s * 1000 + offsetUs / 1000,
t_ms: t.t_s * 1000 + Math.floor(offsetUs / 1000),
[opaque_AbsoluteTime]: true,
};
}