-
Notifications
You must be signed in to change notification settings - Fork 533
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #331 from evq/wasm
basic wasm support
- Loading branch information
Showing
7 changed files
with
85 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))] | ||
mod test { | ||
extern crate chrono; | ||
extern crate wasm_bindgen_test; | ||
|
||
use self::chrono::prelude::*; | ||
use self::wasm_bindgen_test::*; | ||
|
||
use std::env; | ||
|
||
#[wasm_bindgen_test] | ||
fn now() { | ||
let utc: DateTime<Utc> = Utc::now(); | ||
let local: DateTime<Local> = Local::now(); | ||
|
||
// Ensure time fetched is correct | ||
let actual = Utc.datetime_from_str(env!("NOW"), "%s").unwrap(); | ||
assert!(utc - actual < chrono::Duration::minutes(5)); | ||
|
||
// Ensure offset retrieved when getting local time is correct | ||
let expected_offset = match env!("TZ") { | ||
"ACST-9:30" => FixedOffset::east(19 * 30 * 60), | ||
"Asia/Katmandu" => FixedOffset::east(23 * 15 * 60), // No DST thankfully | ||
"EST4" => FixedOffset::east(-4 * 60 * 60), | ||
"UTC0" => FixedOffset::east(0), | ||
_ => panic!("unexpected TZ"), | ||
}; | ||
assert_eq!(&expected_offset, local.offset()); | ||
} | ||
} |