Skip to content

Commit 3d11c77

Browse files
authored
Add typings for JSDate (#484)
* Add typings for JSDate * Regularize member names * Add DateTimeToJSDate * Add Date tests
1 parent 35fc98d commit 3d11c77

File tree

7 files changed

+648
-0
lines changed

7 files changed

+648
-0
lines changed

.github/workflows/js_interop.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: package:js_interop
2+
permissions: read-all
3+
4+
on:
5+
# Run CI on pushes to the main branch and on PRs.
6+
push:
7+
branches: [ main ]
8+
paths:
9+
- '.github/workflows/js_interop.yaml'
10+
- 'js_interop/**'
11+
pull_request:
12+
paths:
13+
- '.github/workflows/js_interop.yaml'
14+
- 'js_interop/**'
15+
schedule:
16+
- cron: "0 0 * * 0"
17+
18+
defaults:
19+
run:
20+
working-directory: js_interop/
21+
22+
jobs:
23+
build:
24+
runs-on: ubuntu-latest
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
sdk: [3.9, beta, dev]
29+
test_config: ['-p chrome', '-p chrome -c dart2wasm', '-p node']
30+
31+
steps:
32+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
33+
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
34+
with:
35+
sdk: ${{ matrix.sdk }}
36+
37+
- run: dart pub get
38+
- run: dart format --output=none --set-exit-if-changed .
39+
if: ${{ matrix.sdk == 'dev' }}
40+
- run: dart analyze --fatal-infos
41+
- run: dart test ${{ matrix.test_config }}

js_interop/dart_test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
platforms: [chrome, node]

js_interop/lib/js_interop.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
export 'src/dart/date_time.dart';
6+
export 'src/date.dart';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import '../date.dart';
6+
7+
extension DateTimeToJSDate on DateTime {
8+
/// Converts this to a [JSDate] that represents the same instant in time.
9+
JSDate get toJS => JSDate.fromMillisecondsSinceEpoch(millisecondsSinceEpoch);
10+
}

0 commit comments

Comments
 (0)