Commit graph

44 commits

Author SHA1 Message Date
Linus Groh
bdb13a74b0 LibJS: Describe various kinds of "Duration Records"
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/983902e

We already had these defined as structs, but now they're properly
defined in the spec (opposed to the previous anonymous records), and we
don't have to make up our own names anymore :^)

Note that while we're usually not including 'record' in the name, in
this case the 'Duration Record' has a name clash with the Duration
object. Additionally, later editorial changes introduce CreateFooRecord
AOs, so let's just go with FooRecord structs here.
2022-03-10 23:20:39 +01:00
Linus Groh
fb6c8781a2 LibJS: Update RoundDuration after DRY refactor in spec
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/4ef2748

Apparently I missed this in December! :^)
2022-03-10 00:42:49 +01:00
Linus Groh
5277646f46 LibJS: Fix 'precision != "auto"' check in temporal_duration_to_string()
If the Variant does *not* have a StringView, it *also* is not "auto".

Thanks to YouTube user JWeis for noticing this :^)
2021-12-18 23:20:00 +00:00
Linus Groh
acce65b52c LibJS: Fix fractionalSecondDigits behavior in Duration.proto.toString()
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/3ee771e
2021-12-18 22:32:39 +00:00
Linus Groh
bdb8fc54f2 LibJS: Update spec comment in balance_duration_relative()
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/665871e
2021-12-09 23:18:01 +00:00
Andreas Kling
fed6a76990 LibJS: Add Handle::operator->() 2021-12-09 21:28:52 +01:00
Timothy Flynn
1039159a6c LibJS: Change LargerOfTwoTemporalUnits AO to return a StringView 2021-11-30 00:01:07 +00:00
Linus Groh
7a2eeae8c6 LibJS: Implement Temporal.ZonedDateTime.prototype.until() 2021-11-24 17:53:00 +00:00
Luke Wilde
7dc846d51c LibJS: Implement balance_duration_relative() 2021-11-24 17:53:00 +00:00
Luke Wilde
9559cea8e5 LibJS: Implement add_duration() 2021-11-24 17:53:00 +00:00
Luke Wilde
1f84deaf63 LibJS: Implement default_temporal_largest_unit() 2021-11-24 17:53:00 +00:00
Linus Groh
a20b189eab LibJS: Fix incorrectly formatted section comments
A couple of missing URLs, spaces, and a stray comma.
2021-11-24 17:37:27 +00:00
Linus Groh
8d6d39e07c LibJS: Treat relativeTo parameters as PlainDate or ZonedDateTime
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/c822e14
2021-11-19 19:59:13 +00:00
Linus Groh
ec1e1f4f12 LibJS: Disallow Temporal.Duration input values to be non-integers
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/8c85450
2021-11-17 22:20:59 +00:00
Linus Groh
dbe70e7c55 LibJS: Implement Temporal.Duration.prototype.total() 2021-11-13 18:50:54 +00:00
Linus Groh
656efe5d6c LibJS: Fix days calculation in round_duration() for "year" - "day" units
This relies on floating point division, which is not possible with
LibCrypto bigints at the moment. So, instead of completely ignoring the
remainder we now first do a bigint division, then convert the remainder
to a double, and do another native floating point division to get the
final result.
2021-11-13 18:50:54 +00:00
Linus Groh
f11277b50d LibJS: Fix missing handling of "week" largest_unit in balance_duration()
It would crash because of VERIFY(largest_unit == "nanosecond"sv) in the
final else branch when passing "week", because it's not handled in any
of the previous branches.
2021-11-13 14:21:08 +00:00
Linus Groh
8c73d85a65 LibJS: Fix logic typo in round_duration() remainder calculation
For unit == "hour", the remainder would not return the difference
between fractional_hours and hours, but fractional_hours and days.
2021-11-13 13:33:00 +00:00
Linus Groh
f0cd727d74 LibJS: Fix logic typo in balance_duration() hours calculation
By using milliseconds_division_result instead of seconds_division_result
here, the result for hours was off by a factor of 60.
2021-11-13 13:32:35 +00:00
Luke Wilde
29072f4b09 LibJS: Implement the required AOs for Temporal.Duration.compare 2021-11-11 21:06:54 +00:00
Linus Groh
e9f66d1c2a LibJS: Mark DaysUntil as infallible
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/30a8939
2021-11-09 20:37:17 +00:00
Linus Groh
b2548393d2 LibJS: Implement Temporal.Duration.prototype.toString()
I hereby claim "implemented largest AO in LibJS ever" (450 lines). :^)
2021-11-07 15:31:28 +01:00
Linus Groh
d49bbb1da3 LibJS: Implement TODO()'d parts of balance_duration()
Massive :yakstack:, so I understand why it was skipped in the first
place :^)
2021-11-02 09:24:35 +01:00
Idan Horowitz
20d990563c LibJS: Convert to_number() to ThrowCompletionOr 2021-10-18 08:01:38 +03:00
Linus Groh
4d8912a92b LibJS: Convert to_string() to ThrowCompletionOr
Also update get_function_name() to use ThrowCompletionOr, but this is
not a standard AO and should be refactored out of existence eventually.
2021-10-13 09:55:10 +01:00
Linus Groh
b7e5f08e56 LibJS: Convert Object::get() to ThrowCompletionOr
To no one's surprise, this patch is pretty big - this is possibly the
most used AO of all of them. Definitely worth it though.
2021-10-03 20:14:03 +01:00
Linus Groh
4d5bd092ea LibJS: Use MUST() where applicable 2021-10-03 20:14:03 +01:00
Linus Groh
ea7cc70118 LibJS: Convert Duration AOs to ThrowCompletionOr 2021-09-17 08:25:12 +01:00
Linus Groh
f86fa12deb LibJS: Convert parse_temporal_duration_string() to ThrowCompletionOr 2021-09-16 22:34:24 +01:00
Idan Horowitz
5a4c90fcb1 LibJS: Convert ordinary_create_from_constructor<T> to ThrowCompletionOr 2021-09-16 13:53:37 +01:00
Linus Groh
77a18392ff LibJS: Make to_temporal_duration_record() time like Object a const&
This only calls Object::get() or some Duration getters on the
temporal_duration_like Object, both of which are const-qualified.
2021-09-09 23:46:45 +01:00
Linus Groh
e4c07c5b8f LibJS: Make new_target parameter of all Temporal AOs a const*
These are passed to ordinary_create_from_constructor() in each case,
which takes the parameter as a const&, so these can also be const.
2021-09-09 23:46:45 +01:00
Linus Groh
33f76f88bb LibJS: Add and use the CreateNegatedTemporalDuration AO
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/6178ed3
2021-09-08 00:07:18 +01:00
Idan Horowitz
24b78fff7d LibJS: Add a bunch of Temporal Abstract Operations
These will allow us to (partially) implement
Temporal.Instant.prototype.{until, since}
2021-09-06 22:15:39 +01:00
Linus Groh
3492fbf9cf LibJS: Account for negative numbers in ToTemporalDurationRecord
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/fa9d547
2021-09-02 20:16:44 +01:00
Linus Groh
0e6d503317 LibJS: Throw RangeError for non-integral values in ToPartialDuration
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/895c8e5
2021-09-02 20:16:44 +01:00
Linus Groh
38bef3e28e LibJS: Handle undefined, NaN, and Infinity in ToTemporalDurationRecord
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/d4b9bcf
2021-09-01 15:11:35 +01:00
Linus Groh
0cdad283c0 LibJS: Reflect Record wording editorial change in the Temporal spec
See: https://github.com/tc39/proposal-temporal/commit/c8f14d0
2021-08-17 21:59:35 +01:00
Linus Groh
16c38788c3 LibJS: Add missing spec links 2021-08-08 11:04:30 +01:00
Linus Groh
b38f1fb071 LibJS: Implement Temporal.Instant.prototype.add() 2021-08-07 13:10:35 +01:00
Linus Groh
5c77885873 LibJS: Implement Temporal.Duration.from()
...with ParseTemporalDurationString currently TODO()'d.
2021-07-19 00:34:28 +01:00
Linus Groh
7355c23e17 LibJS: Fix TemporalDurationLike property order
The table is sorted alphabetically and supposed to be iterated in that
oder. Also move this to a templated lambda for later re-use with
different target structs and value types.
2021-07-19 00:34:28 +01:00
Linus Groh
9aa1e4b885 LibJS: Implement Temporal.Duration.prototype.with() 2021-07-16 21:59:13 +01:00
Linus Groh
7921d8ba91 LibJS: Start implementing Temporal.Duration
This patch adds the Duration object itself, its constructor and
prototype (currently empty), and three required abstract operations.
2021-07-16 01:07:01 +01:00