2018-06-25 11:12:27 +03:00
|
|
|
#![allow(non_snake_case)]
|
|
|
|
|
|
|
|
use super::project;
|
|
|
|
|
2018-07-02 23:44:38 +03:00
|
|
|
#[test]
|
|
|
|
fn get_date() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-02 23:44:38 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
2018-07-05 23:02:40 +03:00
|
|
|
use wasm_bindgen::js::Date;
|
2018-07-02 23:44:38 +03:00
|
|
|
|
|
|
|
#[wasm_bindgen]
|
2018-07-05 23:02:40 +03:00
|
|
|
pub fn get_date(this: &Date) -> u32 {
|
2018-07-02 23:44:38 +03:00
|
|
|
this.get_date()
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date = new Date(1993, 6, 28, 14, 39, 7);
|
|
|
|
|
|
|
|
assert.equal(wasm.get_date(date), 28);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-07-04 13:41:06 +03:00
|
|
|
#[test]
|
|
|
|
fn get_day() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-04 13:41:06 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
2018-07-05 23:02:40 +03:00
|
|
|
use wasm_bindgen::js::Date;
|
2018-07-04 13:41:06 +03:00
|
|
|
|
|
|
|
#[wasm_bindgen]
|
2018-07-05 23:02:40 +03:00
|
|
|
pub fn get_day(this: &Date) -> u32 {
|
2018-07-04 13:41:06 +03:00
|
|
|
this.get_day()
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
2018-07-05 06:37:09 +03:00
|
|
|
"test.js",
|
2018-07-04 13:41:06 +03:00
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date = new Date('August 19, 1975 23:15:30');
|
|
|
|
|
|
|
|
assert.equal(wasm.get_day(date), 2);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-07-04 13:52:12 +03:00
|
|
|
#[test]
|
|
|
|
fn get_full_year() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-04 13:52:12 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
2018-07-05 23:02:40 +03:00
|
|
|
use wasm_bindgen::js::Date;
|
2018-07-04 13:52:12 +03:00
|
|
|
|
|
|
|
#[wasm_bindgen]
|
2018-07-05 23:02:40 +03:00
|
|
|
pub fn get_full_year(this: &Date) -> u32 {
|
2018-07-04 13:52:12 +03:00
|
|
|
this.get_full_year()
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
2018-07-05 06:37:09 +03:00
|
|
|
"test.js",
|
2018-07-04 13:52:12 +03:00
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date = new Date('July 20, 1969 00:20:18');
|
|
|
|
let abbrDate = new Date('Thu, 06 Sep 12 00:00:00');
|
|
|
|
|
|
|
|
assert.equal(wasm.get_full_year(date), 1969);
|
|
|
|
assert.equal(wasm.get_full_year(abbrDate), 2012);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-07-07 20:09:46 +03:00
|
|
|
#[test]
|
|
|
|
fn get_hours() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-07 20:09:46 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn get_hours(this: &Date) -> u32 {
|
|
|
|
this.get_hours()
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date = new Date('March 13, 08 04:20');
|
|
|
|
|
|
|
|
assert.equal(wasm.get_hours(date), 4);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn get_milliseconds() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-07 20:09:46 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn get_milliseconds(this: &Date) -> u32 {
|
|
|
|
this.get_milliseconds()
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date = new Date('July 20, 69 00:20:18');
|
|
|
|
let dateWithMs = new Date('July 20, 69 00:20:18:123');
|
|
|
|
|
|
|
|
assert.equal(wasm.get_milliseconds(date), 0);
|
|
|
|
assert.equal(wasm.get_milliseconds(dateWithMs), 123);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn get_minutes() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-07 20:09:46 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn get_minutes(this: &Date) -> u32 {
|
|
|
|
this.get_minutes()
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date = new Date('March 13, 08 04:20');
|
|
|
|
|
|
|
|
assert.equal(wasm.get_minutes(date), 20);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn get_month() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-07 20:09:46 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn get_month(this: &Date) -> u32 {
|
|
|
|
this.get_month()
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date = new Date('July 20, 69 00:20:18');
|
|
|
|
|
|
|
|
assert.equal(wasm.get_month(date), 6);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn get_seconds() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-07 20:09:46 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn get_seconds(this: &Date) -> u32 {
|
|
|
|
this.get_seconds()
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date = new Date('July 20, 69 00:20:18');
|
|
|
|
|
|
|
|
assert.equal(wasm.get_seconds(date), 18);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn get_time() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-07 20:09:46 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn get_time(this: &Date) -> f64 {
|
|
|
|
this.get_time()
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date = new Date('July 20, 69 00:20:18 GMT+00:00');
|
|
|
|
|
|
|
|
assert.equal(wasm.get_time(date), -14254782000);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-07-09 11:38:38 +03:00
|
|
|
#[test]
|
|
|
|
fn get_timezone_offset() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-09 11:38:38 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn get_timezone_offset(this: &Date) -> f64 {
|
|
|
|
this.get_timezone_offset()
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date1 = new Date('August 19, 1975 23:15:30 GMT+07:00');
|
|
|
|
let date2 = new Date('August 19, 1975 23:15:30 GMT-02:00');
|
|
|
|
|
|
|
|
assert.equal(typeof wasm.get_timezone_offset(date1), "number");
|
|
|
|
assert.equal(wasm.get_timezone_offset(date1), wasm.get_timezone_offset(date2));
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-07-09 11:42:30 +03:00
|
|
|
#[test]
|
|
|
|
fn get_utc_date() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-09 11:42:30 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn get_utc_date(this: &Date) -> u32 {
|
|
|
|
this.get_utc_date()
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date1 = new Date('August 19, 1975 23:15:30 GMT+11:00');
|
|
|
|
let date2 = new Date('August 19, 1975 23:15:30 GMT-11:00');
|
|
|
|
|
|
|
|
assert.equal(wasm.get_utc_date(date1), 19);
|
|
|
|
assert.equal(wasm.get_utc_date(date2), 20);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-07-09 11:46:21 +03:00
|
|
|
#[test]
|
|
|
|
fn get_utc_day() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-09 11:46:21 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn get_utc_day(this: &Date) -> u32 {
|
|
|
|
this.get_utc_day()
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date1 = new Date('August 19, 1975 23:15:30 GMT+11:00');
|
|
|
|
let date2 = new Date('August 19, 1975 23:15:30 GMT-11:00');
|
|
|
|
|
|
|
|
assert.equal(wasm.get_utc_day(date1), 2);
|
|
|
|
assert.equal(wasm.get_utc_day(date2), 3);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-07-09 11:50:13 +03:00
|
|
|
#[test]
|
|
|
|
fn get_utc_full_year() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-09 11:50:13 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn get_utc_full_year(this: &Date) -> u32 {
|
|
|
|
this.get_utc_full_year()
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date1 = new Date('December 31, 1975, 23:15:30 GMT+11:00');
|
|
|
|
let date2 = new Date('December 31, 1975, 23:15:30 GMT-11:00');
|
|
|
|
|
|
|
|
assert.equal(wasm.get_utc_full_year(date1), 1975);
|
|
|
|
assert.equal(wasm.get_utc_full_year(date2), 1976);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-07-09 11:54:19 +03:00
|
|
|
#[test]
|
|
|
|
fn get_utc_hours() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-09 11:54:19 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn get_utc_hours(this: &Date) -> u32 {
|
|
|
|
this.get_utc_hours()
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date1 = new Date('December 31, 1975, 23:15:30 GMT+11:00');
|
|
|
|
let date2 = new Date('December 31, 1975, 23:15:30 GMT-11:00');
|
|
|
|
|
|
|
|
assert.equal(wasm.get_utc_hours(date1), 12);
|
|
|
|
assert.equal(wasm.get_utc_hours(date2), 10);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-07-09 11:59:15 +03:00
|
|
|
#[test]
|
|
|
|
fn get_utc_milliseconds() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-09 11:59:15 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn get_utc_milliseconds(this: &Date) -> u32 {
|
|
|
|
this.get_utc_milliseconds()
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date = new Date('2018-01-02T03:04:05.678Z');
|
|
|
|
|
|
|
|
assert.equal(wasm.get_utc_milliseconds(date), 678);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-07-09 12:04:20 +03:00
|
|
|
#[test]
|
|
|
|
fn get_utc_minutes() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-09 12:04:20 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn get_utc_minutes(this: &Date) -> u32 {
|
|
|
|
this.get_utc_minutes()
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date1 = new Date('1 January 2000 03:15:30 GMT+07:00');
|
|
|
|
let date2 = new Date('1 January 2000 03:15:30 GMT+03:30');
|
|
|
|
|
|
|
|
assert.equal(wasm.get_utc_minutes(date1), 15);
|
|
|
|
assert.equal(wasm.get_utc_minutes(date2), 45);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-07-09 12:08:38 +03:00
|
|
|
#[test]
|
|
|
|
fn get_utc_month() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-09 12:08:38 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn get_utc_month(this: &Date) -> u32 {
|
|
|
|
this.get_utc_month()
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date1 = new Date('December 31, 1975, 23:15:30 GMT+11:00');
|
|
|
|
let date2 = new Date('December 31, 1975, 23:15:30 GMT-11:00');
|
|
|
|
|
|
|
|
assert.equal(wasm.get_utc_month(date1), 11);
|
|
|
|
assert.equal(wasm.get_utc_month(date2), 0);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-07-09 12:20:04 +03:00
|
|
|
#[test]
|
|
|
|
fn get_utc_seconds() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-09 12:20:04 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn get_utc_seconds(this: &Date) -> u32 {
|
|
|
|
this.get_utc_seconds()
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date = new Date('July 20, 1969, 20:18:04 UTC');
|
|
|
|
|
|
|
|
assert.equal(wasm.get_utc_seconds(date), 4);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-06-26 17:52:56 +03:00
|
|
|
#[test]
|
|
|
|
fn new() {
|
|
|
|
project()
|
2018-06-28 08:42:34 +03:00
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-06-26 17:52:56 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn new_date() -> Date {
|
|
|
|
Date::new()
|
|
|
|
}
|
2018-06-28 08:42:34 +03:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
2018-07-05 06:37:09 +03:00
|
|
|
"test.js",
|
2018-06-28 08:42:34 +03:00
|
|
|
r#"
|
2018-06-26 17:52:56 +03:00
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
assert.equal(typeof wasm.new_date(), "object");
|
|
|
|
}
|
2018-06-28 08:42:34 +03:00
|
|
|
"#,
|
|
|
|
)
|
2018-06-26 17:52:56 +03:00
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-06-27 10:40:40 +03:00
|
|
|
#[test]
|
|
|
|
fn now() {
|
|
|
|
project()
|
|
|
|
.file("src/lib.rs", r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-06-27 10:40:40 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
2018-07-03 15:26:00 +03:00
|
|
|
use wasm_bindgen::js::Date;
|
2018-06-27 10:40:40 +03:00
|
|
|
|
|
|
|
#[wasm_bindgen]
|
2018-07-03 15:26:00 +03:00
|
|
|
pub fn now() -> f64 {
|
2018-06-27 10:40:40 +03:00
|
|
|
Date::now()
|
|
|
|
}
|
|
|
|
"#)
|
2018-07-05 06:37:09 +03:00
|
|
|
.file("test.js", r#"
|
2018-06-27 10:40:40 +03:00
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
assert.equal(typeof wasm.now(), "number");
|
|
|
|
}
|
|
|
|
"#)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-07-07 20:09:46 +03:00
|
|
|
#[test]
|
|
|
|
fn parse() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-07 20:09:46 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::{Date, JsString};
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn parse(date: JsString) -> f64 {
|
|
|
|
Date::parse(date)
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date = wasm.parse('04 Dec 1995 00:12:00 GMT');
|
|
|
|
let unixTimeZero = wasm.parse('01 Jan 1970 00:00:00 GMT');
|
|
|
|
|
|
|
|
assert.equal(date, 818035920000);
|
|
|
|
assert.equal(unixTimeZero, 0);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-07-10 14:38:54 +03:00
|
|
|
#[test]
|
|
|
|
fn set_date() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-10 14:38:54 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn set_date(this: &Date, day: u32) -> f64 {
|
|
|
|
this.set_date(day)
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let event1 = new Date('August 19, 1975 23:15:30');
|
|
|
|
let event2 = new Date('August 24, 1975 23:15:30');
|
|
|
|
|
|
|
|
let eventMsFromUnixEpoch = wasm.set_date(event1, 24);
|
|
|
|
|
2018-07-10 17:31:25 +03:00
|
|
|
assert.equal(eventMsFromUnixEpoch, event2.getTime());
|
2018-07-10 14:38:54 +03:00
|
|
|
assert.equal(event1.getTime(), event2.valueOf());
|
|
|
|
assert.equal(event1.getDate(), 24);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-07-10 14:45:25 +03:00
|
|
|
#[test]
|
|
|
|
fn set_full_year() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-10 14:45:25 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn set_full_year(this: &Date, year: u32) -> f64 {
|
|
|
|
this.set_full_year(year)
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let event1 = new Date('August 19, 1975 23:15:30');
|
|
|
|
let event2 = new Date('August 19, 1976 23:15:30');
|
|
|
|
|
|
|
|
let eventMsFromUnixEpoch = wasm.set_full_year(event1, 1976);
|
|
|
|
|
2018-07-10 17:31:25 +03:00
|
|
|
assert.equal(eventMsFromUnixEpoch, event2.getTime());
|
2018-07-10 14:45:25 +03:00
|
|
|
assert.equal(event1.getTime(), event2.valueOf());
|
|
|
|
assert.equal(event1.getFullYear(), 1976);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-07-10 14:51:39 +03:00
|
|
|
#[test]
|
|
|
|
fn set_hours() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-10 14:51:39 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn set_hours(this: &Date, hours: u32) -> f64 {
|
|
|
|
this.set_hours(hours)
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let event1 = new Date('August 19, 1975 23:15:30');
|
|
|
|
let event2 = new Date('August 19, 1975 20:15:30');
|
|
|
|
|
|
|
|
let eventMsFromUnixEpoch = wasm.set_hours(event1, 20);
|
|
|
|
|
2018-07-10 17:31:25 +03:00
|
|
|
assert.equal(eventMsFromUnixEpoch, event2.getTime());
|
2018-07-10 14:51:39 +03:00
|
|
|
assert.equal(event1.getTime(), event2.valueOf());
|
|
|
|
assert.equal(event1.getHours(), 20);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-07-10 14:55:45 +03:00
|
|
|
#[test]
|
|
|
|
fn set_milliseconds() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-10 14:55:45 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn set_milliseconds(this: &Date, milliseconds: u32) -> f64 {
|
|
|
|
this.set_milliseconds(milliseconds)
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let event = new Date('August 19, 1975 23:15:30');
|
|
|
|
|
|
|
|
let eventMsFromUnixEpoch = wasm.set_milliseconds(event, 456);
|
|
|
|
|
2018-07-10 17:31:25 +03:00
|
|
|
assert.equal(eventMsFromUnixEpoch, event.getTime());
|
2018-07-10 14:55:45 +03:00
|
|
|
assert.equal(event.getMilliseconds(), 456);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-07-10 15:20:18 +03:00
|
|
|
#[test]
|
|
|
|
fn set_minutes() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-10 15:20:18 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn set_minutes(this: &Date, minutes: u32) -> f64 {
|
|
|
|
this.set_minutes(minutes)
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let event1 = new Date('August 19, 1975 23:15:30');
|
|
|
|
let event2 = new Date('August 19, 1975 23:45:30');
|
|
|
|
|
|
|
|
let eventMsFromUnixEpoch = wasm.set_minutes(event1, 45);
|
|
|
|
|
2018-07-10 17:31:25 +03:00
|
|
|
assert.equal(eventMsFromUnixEpoch, event2.getTime());
|
2018-07-10 15:20:18 +03:00
|
|
|
assert.equal(event1.getTime(), event2.valueOf());
|
|
|
|
assert.equal(event1.getMinutes(), 45);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-07-10 15:27:12 +03:00
|
|
|
#[test]
|
|
|
|
fn set_month() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-10 15:27:12 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn set_month(this: &Date, month: u32) -> f64 {
|
|
|
|
this.set_month(month)
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let event1 = new Date('August 19, 1975 23:15:30');
|
|
|
|
let event2 = new Date('April 19, 1975 23:15:30');
|
|
|
|
|
|
|
|
let eventMsFromUnixEpoch = wasm.set_month(event1, 3);
|
|
|
|
|
2018-07-10 17:31:25 +03:00
|
|
|
assert.equal(eventMsFromUnixEpoch, event2.getTime());
|
2018-07-10 15:27:12 +03:00
|
|
|
assert.equal(event1.getTime(), event2.valueOf());
|
|
|
|
assert.equal(event1.getMonth(), 3);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-07-10 15:45:33 +03:00
|
|
|
#[test]
|
|
|
|
fn set_seconds() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-10 15:45:33 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn set_seconds(this: &Date, seconds: u32) -> f64 {
|
|
|
|
this.set_seconds(seconds)
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let event1 = new Date('August 19, 1975 23:15:30');
|
|
|
|
let event2 = new Date('August 19, 1975 23:15:42');
|
|
|
|
|
|
|
|
let eventMsFromUnixEpoch = wasm.set_seconds(event1, 42);
|
|
|
|
|
2018-07-10 17:31:25 +03:00
|
|
|
assert.equal(eventMsFromUnixEpoch, event2.getTime());
|
2018-07-10 15:45:33 +03:00
|
|
|
assert.equal(event1.getTime(), event2.valueOf());
|
|
|
|
assert.equal(event1.getSeconds(), 42);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-07-10 15:46:44 +03:00
|
|
|
#[test]
|
|
|
|
fn set_time() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-10 15:46:44 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn set_time(this: &Date, time: f64) -> f64 {
|
|
|
|
this.set_time(time)
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let event1 = new Date('July 1, 1999');
|
|
|
|
let event2 = new Date();
|
|
|
|
|
|
|
|
let eventMsFromUnixEpoch = wasm.set_time(event2, event1.getTime());
|
|
|
|
|
2018-07-10 17:31:25 +03:00
|
|
|
assert.equal(eventMsFromUnixEpoch, event2.getTime());
|
2018-07-10 15:46:44 +03:00
|
|
|
assert.equal(event1.valueOf(), event2.getTime());
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-07-11 17:27:59 +03:00
|
|
|
#[test]
|
|
|
|
fn set_utc_date() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-11 17:27:59 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn set_utc_date(this: &Date, day: u32) -> f64 {
|
|
|
|
this.set_utc_date(day)
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let event1 = new Date('August 19, 1975 23:15:30 GMT-3:00');
|
|
|
|
let event2 = new Date('August 19, 1975 02:15:30 GMT');
|
|
|
|
|
|
|
|
let eventMsFromUnixEpoch = wasm.set_utc_date(event1, 19);
|
|
|
|
|
|
|
|
assert.equal(eventMsFromUnixEpoch, event2.getTime());
|
|
|
|
assert.equal(event1.getTime(), event2.valueOf());
|
|
|
|
assert.equal(event1.getUTCDate(), 19);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn set_utc_full_year() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-11 17:27:59 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn set_utc_full_year(this: &Date, year: u32) -> f64 {
|
|
|
|
this.set_utc_full_year(year)
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let event1 = new Date('December 31, 1975 23:15:30 GMT-3:00');
|
|
|
|
let event2 = new Date('January 01, 1975 02:15:30 GMT');
|
|
|
|
|
|
|
|
let eventMsFromUnixEpoch = wasm.set_utc_full_year(event1, 1975);
|
|
|
|
|
|
|
|
assert.equal(eventMsFromUnixEpoch, event2.getTime());
|
|
|
|
assert.equal(event1.getTime(), event2.valueOf());
|
|
|
|
assert.equal(event1.getUTCFullYear(), 1975);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn set_utc_hours() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-11 17:27:59 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn set_utc_hours(this: &Date, hours: u32) -> f64 {
|
|
|
|
this.set_utc_hours(hours)
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let event1 = new Date('August 19, 1975 23:15:30 GMT-3:00');
|
|
|
|
let event2 = new Date('August 20, 1975 23:15:30 GMT');
|
|
|
|
|
|
|
|
let eventMsFromUnixEpoch = wasm.set_utc_hours(event1, 23);
|
|
|
|
|
|
|
|
assert.equal(eventMsFromUnixEpoch, event2.getTime());
|
|
|
|
assert.equal(event1.getTime(), event2.valueOf());
|
|
|
|
assert.equal(event1.getUTCHours(), 23);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn set_utc_milliseconds() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-11 17:27:59 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn set_utc_milliseconds(this: &Date, milliseconds: u32) -> f64 {
|
|
|
|
this.set_utc_milliseconds(milliseconds)
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let event1 = new Date('August 19, 1975 23:15:30 GMT-3:00');
|
|
|
|
let event2 = new Date('August 20, 1975 02:15:30.420Z GMT');
|
|
|
|
|
|
|
|
let eventMsFromUnixEpoch = wasm.set_utc_milliseconds(event1, 420);
|
|
|
|
|
|
|
|
assert.equal(eventMsFromUnixEpoch, event2.getTime());
|
|
|
|
assert.equal(event1.getTime(), event2.valueOf());
|
|
|
|
assert.equal(event1.getUTCMilliseconds(), 420);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn set_utc_minutes() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-11 17:27:59 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn set_utc_minutes(this: &Date, minutes: u32) -> f64 {
|
|
|
|
this.set_utc_minutes(minutes)
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let event1 = new Date('December 31, 1975, 23:15:30 GMT-3:00');
|
|
|
|
let event2 = new Date('January 01, 1976 02:25:30 GMT');
|
|
|
|
|
|
|
|
let eventMsFromUnixEpoch = wasm.set_utc_minutes(event1, 25);
|
|
|
|
|
|
|
|
assert.equal(eventMsFromUnixEpoch, event2.getTime());
|
|
|
|
assert.equal(event1.getTime(), event2.valueOf());
|
|
|
|
assert.equal(event1.getUTCMinutes(), 25);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn set_utc_month() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-11 17:27:59 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn set_utc_month(this: &Date, minutes: u32) -> f64 {
|
|
|
|
this.set_utc_month(minutes)
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let event1 = new Date('December 31, 1975 23:15:30 GMT-3:00');
|
|
|
|
let event2 = new Date('December 01, 1976 02:15:30 GMT');
|
|
|
|
|
|
|
|
let eventMsFromUnixEpoch = wasm.set_utc_month(event1, 11);
|
|
|
|
|
|
|
|
assert.equal(eventMsFromUnixEpoch, event2.getTime());
|
|
|
|
assert.equal(event1.getTime(), event2.valueOf());
|
|
|
|
assert.equal(event1.getUTCMonth(), 11);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn set_utc_seconds() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-07-11 17:27:59 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn set_utc_seconds(this: &Date, seconds: u32) -> f64 {
|
|
|
|
this.set_utc_seconds(seconds)
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.js",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let event1 = new Date('December 31, 1975 23:15:30 GMT-3:00');
|
|
|
|
let event2 = new Date('January 01, 1976 02:15:39 GMT');
|
|
|
|
|
|
|
|
let eventMsFromUnixEpoch = wasm.set_utc_seconds(event1, 39);
|
|
|
|
|
|
|
|
assert.equal(eventMsFromUnixEpoch, event2.getTime());
|
|
|
|
assert.equal(event1.getTime(), event2.valueOf());
|
|
|
|
assert.equal(event1.getUTCSeconds(), 39);
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-06-25 11:17:31 +03:00
|
|
|
#[test]
|
|
|
|
fn to_date_string() {
|
|
|
|
project()
|
2018-06-28 08:42:34 +03:00
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-06-25 11:17:31 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::{Date, JsString};
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn to_date_string(this: &Date) -> JsString {
|
|
|
|
this.to_date_string()
|
|
|
|
}
|
2018-06-28 08:42:34 +03:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
2018-07-05 06:37:09 +03:00
|
|
|
"test.js",
|
2018-06-28 08:42:34 +03:00
|
|
|
r#"
|
2018-06-25 11:17:31 +03:00
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date = new Date(1993, 6, 28, 14, 39, 7);
|
|
|
|
|
|
|
|
assert.equal(wasm.to_date_string(date), 'Wed Jul 28 1993');
|
|
|
|
}
|
2018-06-28 08:42:34 +03:00
|
|
|
"#,
|
|
|
|
)
|
2018-06-25 11:17:31 +03:00
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-06-25 11:16:58 +03:00
|
|
|
#[test]
|
|
|
|
fn to_iso_string() {
|
|
|
|
project()
|
2018-06-28 08:42:34 +03:00
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-06-25 11:16:58 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::{Date, JsString};
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn to_iso_string(this: &Date) -> JsString {
|
|
|
|
this.to_iso_string()
|
|
|
|
}
|
2018-06-28 08:42:34 +03:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
2018-07-05 06:37:09 +03:00
|
|
|
"test.js",
|
2018-06-28 08:42:34 +03:00
|
|
|
r#"
|
2018-06-25 11:16:58 +03:00
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date = new Date('05 October 2011 14:48 UTC');
|
|
|
|
|
|
|
|
assert.equal(wasm.to_iso_string(date), '2011-10-05T14:48:00.000Z');
|
|
|
|
}
|
2018-06-28 08:42:34 +03:00
|
|
|
"#,
|
|
|
|
)
|
2018-06-25 11:16:58 +03:00
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-06-25 11:16:30 +03:00
|
|
|
#[test]
|
|
|
|
fn to_json() {
|
|
|
|
project()
|
2018-06-28 08:42:34 +03:00
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-06-25 11:16:30 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::{Date, JsString};
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn to_json(this: &Date) -> JsString {
|
|
|
|
this.to_json()
|
|
|
|
}
|
2018-06-28 08:42:34 +03:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
2018-07-05 06:37:09 +03:00
|
|
|
"test.js",
|
2018-06-28 08:42:34 +03:00
|
|
|
r#"
|
2018-06-25 11:16:30 +03:00
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date = new Date('August 19, 1975 23:15:30 UTC');
|
|
|
|
|
|
|
|
assert.equal(wasm.to_json(date), '1975-08-19T23:15:30.000Z');
|
|
|
|
}
|
2018-06-28 08:42:34 +03:00
|
|
|
"#,
|
|
|
|
)
|
2018-06-25 11:16:30 +03:00
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-06-25 11:16:04 +03:00
|
|
|
#[test]
|
|
|
|
fn to_locale_date_string() {
|
|
|
|
project()
|
|
|
|
.file("src/lib.rs", r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-06-25 11:16:04 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use JsValue;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::{Date, JsString};
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn to_locale_date_string(this: &Date, locale: JsString, options: JsValue) -> JsString {
|
|
|
|
this.to_locale_date_string(locale, options)
|
|
|
|
}
|
|
|
|
"#)
|
2018-07-05 06:37:09 +03:00
|
|
|
.file("test.js", r#"
|
2018-06-25 11:16:04 +03:00
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
|
|
|
|
let options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
|
|
|
|
|
2018-07-04 17:47:51 +03:00
|
|
|
let output = wasm.to_locale_date_string(date, 'de-DE', options)
|
|
|
|
assert.equal(typeof output, 'string');
|
|
|
|
assert.ok(output.length > 0);
|
2018-06-25 11:16:04 +03:00
|
|
|
}
|
|
|
|
"#)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-06-25 11:15:02 +03:00
|
|
|
#[test]
|
|
|
|
fn to_locale_string() {
|
|
|
|
project()
|
|
|
|
.file("src/lib.rs", r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-06-25 11:15:02 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use JsValue;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::{Date, JsString};
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn to_locale_string(this: &Date, locale: JsString, options: JsValue) -> JsString {
|
|
|
|
this.to_locale_string(locale, options)
|
|
|
|
}
|
|
|
|
"#)
|
2018-07-05 06:37:09 +03:00
|
|
|
.file("test.js", r#"
|
2018-06-25 11:15:02 +03:00
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
|
2018-07-04 17:47:51 +03:00
|
|
|
let output = wasm.to_locale_string(date, 'en-GB', { timeZone: 'UTC' });
|
|
|
|
assert.equal(typeof output, 'string');
|
|
|
|
assert.ok(output.length > 0);
|
2018-06-25 11:15:02 +03:00
|
|
|
}
|
|
|
|
"#)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-06-25 11:14:27 +03:00
|
|
|
#[test]
|
|
|
|
fn to_locale_time_string() {
|
|
|
|
project()
|
2018-06-28 08:42:34 +03:00
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-06-25 11:14:27 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::{Date, JsString};
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn to_locale_time_string(this: &Date, locale: JsString) -> JsString {
|
|
|
|
this.to_locale_time_string(locale)
|
|
|
|
}
|
2018-06-28 08:42:34 +03:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
2018-07-05 06:37:09 +03:00
|
|
|
"test.js",
|
2018-06-28 08:42:34 +03:00
|
|
|
r#"
|
2018-06-25 11:14:27 +03:00
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date = new Date('August 19, 1975 23:15:30');
|
|
|
|
assert.equal(wasm.to_locale_time_string(date, 'en-US'), "11:15:30 PM");
|
|
|
|
}
|
2018-06-28 08:42:34 +03:00
|
|
|
"#,
|
|
|
|
)
|
2018-06-25 11:14:27 +03:00
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-06-25 11:14:00 +03:00
|
|
|
#[test]
|
|
|
|
fn to_string() {
|
|
|
|
project()
|
2018-06-28 08:42:34 +03:00
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-06-25 11:14:00 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::{Date, JsString};
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn to_string(this: &Date) -> JsString {
|
|
|
|
this.to_string()
|
|
|
|
}
|
2018-06-28 08:42:34 +03:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
2018-07-05 06:37:09 +03:00
|
|
|
"test.js",
|
2018-06-28 08:42:34 +03:00
|
|
|
r#"
|
2018-06-25 11:14:00 +03:00
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date = new Date('August 19, 1975 23:15:30');
|
|
|
|
assert.equal(wasm.to_string(date).substring(0, 15), "Tue Aug 19 1975");
|
|
|
|
}
|
2018-06-28 08:42:34 +03:00
|
|
|
"#,
|
|
|
|
)
|
2018-06-25 11:14:00 +03:00
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-06-25 11:13:32 +03:00
|
|
|
#[test]
|
|
|
|
fn to_time_string() {
|
|
|
|
project()
|
2018-06-28 08:42:34 +03:00
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-06-25 11:13:32 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::{Date, JsString};
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn to_time_string(this: &Date) -> JsString {
|
|
|
|
this.to_time_string()
|
|
|
|
}
|
2018-06-28 08:42:34 +03:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
2018-07-05 06:37:09 +03:00
|
|
|
"test.js",
|
2018-06-28 08:42:34 +03:00
|
|
|
r#"
|
2018-06-25 11:13:32 +03:00
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date = new Date('August 19, 1975 23:15:30');
|
|
|
|
assert.equal(wasm.to_time_string(date).substring(0, 8), "23:15:30");
|
|
|
|
}
|
2018-06-28 08:42:34 +03:00
|
|
|
"#,
|
|
|
|
)
|
2018-06-25 11:13:32 +03:00
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-06-25 11:13:01 +03:00
|
|
|
#[test]
|
|
|
|
fn to_utc_string() {
|
|
|
|
project()
|
2018-06-28 08:42:34 +03:00
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-06-25 11:13:01 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::{Date, JsString};
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn to_utc_string(this: &Date) -> JsString {
|
|
|
|
this.to_utc_string()
|
|
|
|
}
|
2018-06-28 08:42:34 +03:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
2018-07-05 06:37:09 +03:00
|
|
|
"test.js",
|
2018-06-28 08:42:34 +03:00
|
|
|
r#"
|
2018-06-25 11:13:01 +03:00
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date = new Date('14 Jun 2017 00:00:00 PDT');
|
|
|
|
assert.equal(wasm.to_utc_string(date), "Wed, 14 Jun 2017 07:00:00 GMT");
|
|
|
|
}
|
2018-06-28 08:42:34 +03:00
|
|
|
"#,
|
|
|
|
)
|
2018-06-25 11:13:01 +03:00
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-06-27 10:41:16 +03:00
|
|
|
#[test]
|
|
|
|
fn utc() {
|
|
|
|
project()
|
|
|
|
.file("src/lib.rs", r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-06-27 10:41:16 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
2018-07-03 15:26:00 +03:00
|
|
|
use wasm_bindgen::js::Date;
|
2018-06-27 10:41:16 +03:00
|
|
|
|
|
|
|
#[wasm_bindgen]
|
2018-07-03 15:26:00 +03:00
|
|
|
pub fn utc() -> f64 {
|
|
|
|
Date::utc(2018f64, 6f64)
|
2018-06-27 10:41:16 +03:00
|
|
|
}
|
|
|
|
"#)
|
2018-07-05 06:37:09 +03:00
|
|
|
.file("test.js", r#"
|
2018-06-27 10:41:16 +03:00
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
assert.equal(wasm.utc(), 1530403200000);
|
|
|
|
}
|
|
|
|
"#)
|
|
|
|
.test()
|
|
|
|
}
|
|
|
|
|
2018-06-25 11:12:27 +03:00
|
|
|
#[test]
|
|
|
|
fn value_of() {
|
|
|
|
project()
|
2018-06-28 08:42:34 +03:00
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-06-25 11:12:27 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js::Date;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn js_value_of(this: &Date) -> Date {
|
|
|
|
this.value_of()
|
|
|
|
}
|
2018-06-28 08:42:34 +03:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
2018-07-05 06:37:09 +03:00
|
|
|
"test.js",
|
2018-06-28 08:42:34 +03:00
|
|
|
r#"
|
2018-06-25 11:12:27 +03:00
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
let date = new Date(Date.UTC(96, 1, 2, 3, 4, 5));
|
|
|
|
assert.equal(wasm.js_value_of(date), 823230245000);
|
|
|
|
}
|
2018-06-28 08:42:34 +03:00
|
|
|
"#,
|
|
|
|
)
|
2018-06-25 11:12:27 +03:00
|
|
|
.test()
|
|
|
|
}
|