mirror of
https://github.com/chronotope/chrono.git
synced 2025-09-30 22:42:08 +00:00
Fixes to wasm test
This commit is contained in:
parent
afb1f1f214
commit
4dceb645e9
@ -1,11 +1,18 @@
|
|||||||
|
//! Run this test with:
|
||||||
|
//! `env TZ="$(date +%z)" NOW="$(date +%s)" wasm-pack test --node -- --features wasmbind`
|
||||||
|
//!
|
||||||
|
//! The `TZ` and `NOW` variables are used to compare the results inside the WASM environment with
|
||||||
|
//! the host system.
|
||||||
|
//! The check will fail if the local timezone does not match one of the timezones defined below.
|
||||||
|
|
||||||
#![cfg(all(
|
#![cfg(all(
|
||||||
target_arch = "wasm32",
|
target_arch = "wasm32",
|
||||||
feature = "wasmbind",
|
feature = "wasmbind",
|
||||||
not(any(target_os = "emscripten", target_os = "wasi"))
|
not(any(target_os = "emscripten", target_os = "wasi"))
|
||||||
))]
|
))]
|
||||||
|
|
||||||
use self::chrono::prelude::*;
|
use chrono::prelude::*;
|
||||||
use self::wasm_bindgen_test::*;
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
#[wasm_bindgen_test]
|
#[wasm_bindgen_test]
|
||||||
fn now() {
|
fn now() {
|
||||||
@ -52,7 +59,7 @@ fn from_is_exact() {
|
|||||||
|
|
||||||
let dt = DateTime::<Utc>::from(now.clone());
|
let dt = DateTime::<Utc>::from(now.clone());
|
||||||
|
|
||||||
assert_eq!(now.get_time() as i64, dt.timestamp_millis_opt().unwrap());
|
assert_eq!(now.get_time() as i64, dt.timestamp_millis());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[wasm_bindgen_test]
|
#[wasm_bindgen_test]
|
||||||
@ -72,7 +79,7 @@ fn convert_all_parts_with_milliseconds() {
|
|||||||
let js_date = js_sys::Date::from(time);
|
let js_date = js_sys::Date::from(time);
|
||||||
|
|
||||||
assert_eq!(js_date.get_utc_full_year(), 2020);
|
assert_eq!(js_date.get_utc_full_year(), 2020);
|
||||||
assert_eq!(js_date.get_utc_month(), 12);
|
assert_eq!(js_date.get_utc_month(), 11); // months are numbered 0..=11
|
||||||
assert_eq!(js_date.get_utc_date(), 1);
|
assert_eq!(js_date.get_utc_date(), 1);
|
||||||
assert_eq!(js_date.get_utc_hours(), 3);
|
assert_eq!(js_date.get_utc_hours(), 3);
|
||||||
assert_eq!(js_date.get_utc_minutes(), 1);
|
assert_eq!(js_date.get_utc_minutes(), 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user