mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-10 14:16:06 +00:00
binding for Date.prototype.getUTCMilliseconds()
This commit is contained in:
parent
6aa3661e11
commit
c260ac7c3e
@ -919,6 +919,13 @@ extern "C" {
|
|||||||
#[wasm_bindgen(method, js_name = getUTCHours)]
|
#[wasm_bindgen(method, js_name = getUTCHours)]
|
||||||
pub fn get_utc_hours(this: &Date) -> u32;
|
pub fn get_utc_hours(this: &Date) -> u32;
|
||||||
|
|
||||||
|
/// The getUTCMilliseconds() method returns the milliseconds in the specified date
|
||||||
|
/// according to universal time.
|
||||||
|
///
|
||||||
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds
|
||||||
|
#[wasm_bindgen(method, js_name = getUTCMilliseconds)]
|
||||||
|
pub fn get_utc_milliseconds(this: &Date) -> u32;
|
||||||
|
|
||||||
/// Creates a JavaScript Date instance that represents
|
/// Creates a JavaScript Date instance that represents
|
||||||
/// a single moment in time. Date objects are based on a time value that is
|
/// a single moment in time. Date objects are based on a time value that is
|
||||||
/// the number of milliseconds since 1 January 1970 UTC.
|
/// the number of milliseconds since 1 January 1970 UTC.
|
||||||
|
@ -492,6 +492,40 @@ fn get_utc_hours() {
|
|||||||
.test()
|
.test()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn get_utc_milliseconds() {
|
||||||
|
project()
|
||||||
|
.file(
|
||||||
|
"src/lib.rs",
|
||||||
|
r#"
|
||||||
|
#![feature(proc_macro, wasm_custom_section)]
|
||||||
|
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn new() {
|
fn new() {
|
||||||
project()
|
project()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user