mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:18:12 +00:00
LibJS: Implement Temporal.Duration.prototype.toString()
I hereby claim "implemented largest AO in LibJS ever" (450 lines). :^)
This commit is contained in:
parent
36b51276d5
commit
b2548393d2
7 changed files with 816 additions and 0 deletions
|
@ -719,6 +719,21 @@ String format_seconds_string_part(u8 second, u16 millisecond, u16 microsecond, u
|
|||
return String::formatted("{}.{}", seconds_string, fraction_string);
|
||||
}
|
||||
|
||||
// 13.28 Sign ( n ), https://tc39.es/proposal-temporal/#sec-temporal-sign
|
||||
double sign(double n)
|
||||
{
|
||||
// 1. If n is NaN, n is +0𝔽, or n is −0𝔽, return n.
|
||||
if (isnan(n) || n == 0)
|
||||
return n;
|
||||
|
||||
// 2. If n < +0𝔽, return −1𝔽.
|
||||
if (n < 0)
|
||||
return -1;
|
||||
|
||||
// 3. Return 1𝔽.
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 13.29 ConstrainToRange ( x, minimum, maximum ), https://tc39.es/proposal-temporal/#sec-temporal-constraintorange
|
||||
double constrain_to_range(double x, double minimum, double maximum)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue