Luke Wilde
29072f4b09
LibJS: Implement the required AOs for Temporal.Duration.compare
2021-11-11 21:06:54 +00:00
Ali Mohammad Pur
bf59d9e824
Userland: Include Vector.h in a few places to make HeaderCheck happy
...
This header was being transitively pulled in, but that no longer happens
after 5f7d008791
.
2021-11-11 20:36:36 +01:00
Andreas Kling
8b1108e485
Everywhere: Pass AK::StringView by value
2021-11-11 01:27:46 +01:00
Linus Groh
4eaa95769d
LibJS: Add missing (void) to handle [[nodiscard]] TRY() result
2021-11-11 00:03:07 +00:00
Linus Groh
fdffdc43fa
LibJS: Implement the rest of to_temporal_month_day()
...
Always throws at the moment, because parse_temporal_month_day_string()
is basically a stub, and parse_iso_date_time() isn't functional either.
The spec issue has been resolved though, so I figured we might as well
get one small step further :^)
2021-11-10 22:28:27 +00:00
Linus Groh
6ef1a2793f
LibJS: Rename ZonedDateTime's MatchBehavior enum members to match spec
2021-11-10 21:27:25 +00:00
Andreas Kling
cd49f30bea
AK+LibJS: Simplify MUST() and move it from LibJS to AK/Try.h
...
This is generally useful so let's move it to AK. Also it seems that we
don't need the temporary variable hack anymore, so let's lose that.
2021-11-10 21:58:58 +01:00
Andreas Kling
5f7d008791
AK+Everywhere: Stop including Vector.h from StringView.h
...
Preparation for using Error.h from Vector.h. This required moving some
things out of line.
2021-11-10 21:58:58 +01:00
Idan Horowitz
a445deb205
LibJS: Remove left-over debug assertion from the Await AO
2021-11-10 18:11:26 +00:00
Idan Horowitz
d5f637fa21
LibJS: Do not parse async methods with a new line after the "async"
...
This was already checked in normal function expressions, but was
missing for Object Expressions.
2021-11-10 18:11:26 +00:00
Luke Wilde
5594a492f0
LibJS: Implement Temporal.ZonedDateTime.prototype.toJSON
2021-11-10 12:56:56 +00:00
Luke Wilde
6856b6168a
LibJS: Implement Temporal.ZonedDateTime.prototype.toLocaleString
2021-11-10 12:56:56 +00:00
Luke Wilde
a9ad993e78
LibJS: Implement Temporal.ZonedDateTime.prototype.toString
2021-11-10 12:56:56 +00:00
Luke Wilde
dc72d416b2
LibJS: Implement the required AOs for ZonedDateTime stringifiers
2021-11-10 12:56:56 +00:00
Idan Horowitz
04253c3254
LibJS: Add tests for async functions and await expressions
2021-11-10 08:48:27 +00:00
Idan Horowitz
46dabf02ec
LibJS: Add support for await expressions
2021-11-10 08:48:27 +00:00
Idan Horowitz
681787de76
LibJS: Add support for async functions
...
This commit adds support for the most bare bones version of async
functions, support for async generator functions, async arrow functions
and await expressions are TODO.
2021-11-10 08:48:27 +00:00
Luke Wilde
05c3320da3
LibJS: Mark RoundTemporalInstant as infallible
...
This is an editorial change in the Temporal spec.
See: 0b4141c
This also allows us to get rid of two old exception checks.
2021-11-09 23:42:34 +02:00
Linus Groh
e9f66d1c2a
LibJS: Mark DaysUntil as infallible
...
This is an editorial change in the Temporal spec.
See: 30a8939
2021-11-09 20:37:17 +00:00
Idan Horowitz
91881be4b0
LibJS: Convert GeneratorObject to ThrowCompletionOr
2021-11-09 20:32:51 +02:00
Idan Horowitz
11a90700df
LibJS: Convert the IntegerIndexedElementSet AO to ThrowCompletionOr
2021-11-09 20:32:51 +02:00
Idan Horowitz
ba55d77665
LibJS: Remove leftover exception check in OrdinaryHasProperty
2021-11-09 20:32:51 +02:00
Linus Groh
1e3e0477cb
LibJS: Implement Temporal.PlainMonthDay.prototype.with()
2021-11-08 22:19:45 +00:00
Linus Groh
fa1d5feec0
LibJS: Implement Temporal.PlainYearMonth.prototype.with()
2021-11-08 22:19:45 +00:00
Linus Groh
aca2ef9e1c
LibJS: Implement Temporal.PlainDateTime.prototype.with()
2021-11-08 22:19:45 +00:00
Linus Groh
c3c9ac93d0
LibJS: Implement Temporal.PlainDate.prototype.with()
...
With one caveat: in the PreparePartialTemporalFields AO I made a change
to fix a spec issue that would require the input object to always have a
month or monthCode property.
This is tracked in https://github.com/tc39/proposal-temporal/issues/1910
and may get accepted as-is, in which case we simply need to remove the
NOTE comment.
2021-11-08 22:19:45 +00:00
Linus Groh
310016aee4
LibJS/Tests: Fix Temporal.PlainDate.prototype.equals() tests
...
Just calling "expect()" doesn't do anything!
2021-11-08 19:12:54 +00:00
Linus Groh
46d7c34028
LibJS: Use StringView literals in prepare_temporal_fields()
2021-11-08 19:12:47 +00:00
Timothy Flynn
2530b6adf0
LibJS: Create the RegExpExec result's "input" field last
...
We move the input string into this field to avoid a string copy, so we
must do this step last to avoid using any views into it (note that
match.view here is a view into this string).
2021-11-08 01:36:29 +01:00
Linus Groh
a3b8303f3c
LibJS: Fix modulo() template argument deduction on i686
...
Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp:283:24:
note: deduced conflicting types for parameter 'T' ('long long int'
and 'long int')
283 | nanosecond = modulo(nanosecond, 1000l);
| ~~~~~~^~~~~~~~~~~~~~~~~~~
Worked fine on x86_84 :yakshrug:
2021-11-07 21:33:56 +00:00
Linus Groh
b3ea7332b2
LibJS: Fix use of "modulo" for negative values in balance_time()
2021-11-07 21:11:31 +00:00
Linus Groh
3d84fb64c3
LibJS: Add a modulo() function to represent the "x modulo y" notation
...
This *not* being the same as C++ "%" in all cases is a massive footgun,
and hopefully one I came across for the last time.
2021-11-07 21:11:31 +00:00
Linus Groh
e93ce1ff69
LibJS: Fix nanoseconds formatting in format_time_zone_offset_string()
...
Two issues:
- The format string said "{:9}", which left-pads with spaces and not
zeros as required
- Even when correcting that, we were not accounting for step 11 b:
"Set fraction to the longest possible substring of fraction starting
at position 0 and not ending with the code unit 0x0030 (DIGIT ZERO)."
We can safely use trim() for that as the formatted string is known to
not contain only zeros (which would leave the left-most in place).
Also adds tests for "UTC" and various numeric offsets.
2021-11-07 20:06:28 +00:00
Linus Groh
68d80d239b
LibJS: Fix fraction substring in parse_time_zone_offset_string()
...
We're supposed to get the substring from `fraction`, which is guaranteed
to have the required length. `fraction_part` is the user-supplied value
and trying to get a substring view from 0-9 might crash.
2021-11-07 20:01:31 +00:00
Linus Groh
df2ccb3d38
LibJS: Implement Temporal.Duration.prototype.toLocaleString()
2021-11-07 15:31:28 +01:00
Linus Groh
90fa356b93
LibJS: Implement Temporal.Duration.prototype.toJSON()
2021-11-07 15:31:28 +01: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
36b51276d5
LibJS: Change calendar_date_add() date parameter from PlainDate to Value
...
Turns out use of this AO is a bit more flexible than I anticipated.
2021-11-07 15:31:28 +01:00
Luke Wilde
706296374b
LibJS: Implement Temporal.ZonedDateTime.prototype.equals
2021-11-07 15:35:16 +02:00
Luke Wilde
ac12581140
LibJS: Implement Temporal.ZonedDateTime.compare
2021-11-07 15:35:16 +02:00
Luke Wilde
c9ec3295d9
LibJS: Implement Temporal.ZonedDateTime.from
2021-11-07 15:35:16 +02:00
Luke Wilde
2b89d2a360
LibJS: Implement ToTemporalZonedDateTime and the required AOs
2021-11-07 15:35:16 +02:00
Luke Wilde
b8db0ddc70
LibJS: Implement Temporal.ZonedDateTime.prototype.withCalendar
2021-11-05 09:49:47 +01:00
Luke Wilde
58bb73b60f
LibJS: Implement Temporal.ZonedDateTime.prototype.withTimeZone
2021-11-05 09:49:47 +01:00
Luke Wilde
d5f2745a19
LibJS: Implement Temporal.ZonedDateTime.prototype.withPlainDate
2021-11-05 09:49:47 +01:00
Luke Wilde
132a56f07c
LibJS: Implement Temporal.ZonedDateTime.prototype.withPlainTime
2021-11-05 09:49:47 +01:00
Linus Groh
1dc32fed8f
LibJS: Adjust approximated result in year_from_time() if necessary
2021-11-05 01:18:27 +01:00
Linus Groh
37146e305a
LibJS: Account for leap days in year_from_time()
...
A year has 365.2425 days, not 365. This lead to off-by-one results for
time values (milliseconds) near the end of a year, which would lead to
calculation issues and crashes in other AOs.
Fixes #10796 .
2021-11-05 01:09:18 +01:00
Linus Groh
0dae7c9420
LibJS: Replace a couple of TODO()'s in Temporal with InternalError
...
This helps us to distinguish between crashes because of incomplete code
paths and crashes because of genuine bugs more easily when running
test262.
2021-11-04 23:59:40 +01:00
Linus Groh
dd1a808f7e
LibJS: Remove TODO() from implemented code path
...
Well, that's embarassing. TODO()'d it, implemented it, forgot to remove
the TODO().
2021-11-04 23:59:40 +01:00