mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 02:00:51 +00:00
binding for Date.prototype.setMilliseconds()
This commit is contained in:
parent
524628e1e1
commit
11a58a1bd0
@ -1042,6 +1042,12 @@ extern "C" {
|
||||
#[wasm_bindgen(method, js_name = setHours)]
|
||||
pub fn set_hours(this: &Date, hours: u32) -> f64;
|
||||
|
||||
/// The setMilliseconds() method sets the milliseconds for a specified date according to local time.
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds
|
||||
#[wasm_bindgen(method, js_name = setMilliseconds)]
|
||||
pub fn set_milliseconds(this: &Date, milliseconds: u32) -> f64;
|
||||
|
||||
/// The toDateString() method returns the date portion of a Date object
|
||||
/// in human readable form in American English.
|
||||
///
|
||||
|
@ -843,6 +843,43 @@ fn set_hours() {
|
||||
.test()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_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 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);
|
||||
|
||||
assert.equal(eventMsFromUnixEpoch, 177689730456);
|
||||
assert.equal(event.getMilliseconds(), 456);
|
||||
}
|
||||
"#,
|
||||
)
|
||||
.test()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn to_date_string() {
|
||||
project()
|
||||
|
Loading…
x
Reference in New Issue
Block a user