Replace deprecated temporal proposal polyfill (#12636)

* Replace deprecated temporal proposal polyfill

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Switch polyfill

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Rounding

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Fix tests

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2024-07-03 18:02:10 +01:00 committed by GitHub
parent 6b90fe20ab
commit 0434929ee5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 108 deletions

View file

@ -15,7 +15,7 @@ limitations under the License.
*/
import React, { HTMLProps } from "react";
import { Temporal } from "proposal-temporal";
import { Temporal } from "temporal-polyfill";
import { formatSeconds } from "../../../DateUtils";
@ -45,8 +45,9 @@ export default class Clock extends React.Component<Props> {
return currentFloor !== nextFloor;
}
private calculateDuration(seconds: number): string {
return new Temporal.Duration(0, 0, 0, 0, 0, 0, seconds)
private calculateDuration(seconds: number): string | undefined {
if (isNaN(seconds)) return undefined;
return new Temporal.Duration(0, 0, 0, 0, 0, 0, Math.round(seconds))
.round({ smallestUnit: "seconds", largestUnit: "hours" })
.toString();
}