Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(unstable): add Temporal API support #21738

Merged
merged 18 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,22 +315,28 @@ pub(crate) static UNSTABLE_GRANULAR_FLAGS: &[(
"Enable unstable net APIs",
7,
),
(
"temporal",
"Enable unstable Temporal API",
// Not used in JS
8,
),
(
"unsafe-proto",
"Enable unsafe __proto__ support. This is a security risk.",
// This number is used directly in the JS code. Search
// for "unstableFeatures" to see where it's used.
bartlomieju marked this conversation as resolved.
Show resolved Hide resolved
8,
9,
),
(
deno_runtime::deno_webgpu::UNSTABLE_FEATURE_NAME,
"Enable unstable `WebGPU` API",
9,
10,
),
(
deno_runtime::ops::worker_host::UNSTABLE_FEATURE_NAME,
"Enable unstable Web Worker APIs",
10,
11,
),
];

Expand Down Expand Up @@ -394,7 +400,15 @@ pub fn main() {
// Using same default as VSCode:
// https://github.com/microsoft/vscode/blob/48d4ba271686e8072fc6674137415bc80d936bc7/extensions/typescript-language-features/src/configuration/configuration.ts#L213-L214
DenoSubcommand::Lsp => vec!["--max-old-space-size=3072".to_string()],
_ => vec![],
_ => {
if flags.unstable
|| flags.unstable_features.contains(&"temporal".to_string())
{
vec!["--harmony-temporal".to_string()]
} else {
vec![]
}
}
};
init_v8_flags(&default_v8_flags, &flags.v8_flags, get_v8_flags_from_env());
deno_core::JsRuntime::init_platform(None);
Expand Down
14 changes: 14 additions & 0 deletions cli/tests/integration/run_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4911,3 +4911,17 @@ Warning Sloppy module resolution (hint: specify path to index.tsx file in direct
",
);
}

itest!(unstable_temporal_api {
args: "run --unstable-temporal --check run/unstable_temporal_api/main.ts",
output: "run/unstable_temporal_api/main.out",
http_server: false,
exit_code: 0,
});

itest!(unstable_temporal_api_missing_flag {
args: "run run/unstable_temporal_api/missing_flag.js",
output: "run/unstable_temporal_api/missing_flag.out",
http_server: false,
exit_code: 1,
});
12 changes: 12 additions & 0 deletions cli/tests/testdata/run/unstable_temporal_api/main.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Check [WILDCARD]
Temporal.Now [WILDCARD]
Temporal.Instant 1969-07-20T20:17:00Z
Temporal.ZonedDateTime 1995-12-07T03:24:30.0000035-08:00[America/Los_Angeles]
Temporal.PlainDate 2006-08-24
Temporal.PlainTime 19:39:09.068346205
Temporal.PlainDateTime 1995-12-07T15:00:00
Temporal.PlainYearMonth 2020-10
Temporal.PlainMonthDay 07-14
Temporal.Duration PT130H20M
Temporal.TimeZone Africa/Cairo
Temporal.Calendar 1999-12-31
71 changes: 71 additions & 0 deletions cli/tests/testdata/run/unstable_temporal_api/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
console.log("Temporal.Now", Temporal.Now.instant());
console.log(
"Temporal.Instant",
Temporal.Instant.from("1969-07-20T20:17Z"),
);
console.log(
"Temporal.ZonedDateTime",
Temporal.ZonedDateTime.from({
timeZone: "America/Los_Angeles",
year: 1995,
month: 12,
day: 7,
hour: 3,
minute: 24,
second: 30,
millisecond: 0,
microsecond: 3,
nanosecond: 500,
}),
);
console.log(
"Temporal.PlainDate",
Temporal.PlainDate.from({ year: 2006, month: 8, day: 24 }),
);
console.log(
"Temporal.PlainTime",
Temporal.PlainTime.from({
hour: 19,
minute: 39,
second: 9,
millisecond: 68,
microsecond: 346,
nanosecond: 205,
}),
);
console.log(
"Temporal.PlainDateTime",
Temporal.PlainDateTime.from({
year: 1995,
month: 12,
day: 7,
hour: 15,
}),
);
console.log(
"Temporal.PlainYearMonth",
Temporal.PlainYearMonth.from({ year: 2020, month: 10 }),
);
console.log(
"Temporal.PlainMonthDay",
Temporal.PlainMonthDay.from({ month: 7, day: 14 }),
);
console.log(
"Temporal.Duration",
Temporal.Duration.from({
hours: 130,
minutes: 20,
}),
);
console.log(
"Temporal.TimeZone",
Temporal.TimeZone.from("Africa/Cairo"),
);
console.log(
"Temporal.Calendar",
Temporal.Calendar.from("iso8601").dateFromFields({
year: 1999,
month: 12,
day: 31,
}, {}),
);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Temporal.Now.instant();
4 changes: 4 additions & 0 deletions cli/tests/testdata/run/unstable_temporal_api/missing_flag.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
error: Uncaught (in promise) ReferenceError: Temporal is not defined
Temporal.Now.instant();
^
at [WILDCARD]missing_flag.js:1:1
Loading
Loading