mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-25 19:11:45 +03:00
binding for Date.prototype.setSeconds()
This commit is contained in:
parent
609d457301
commit
c185897eff
@ -1060,6 +1060,12 @@ extern "C" {
|
|||||||
#[wasm_bindgen(method, js_name = setMonth)]
|
#[wasm_bindgen(method, js_name = setMonth)]
|
||||||
pub fn set_month(this: &Date, month: u32) -> f64;
|
pub fn set_month(this: &Date, month: u32) -> f64;
|
||||||
|
|
||||||
|
/// The setSeconds() method sets the seconds for a specified date according to local time.
|
||||||
|
///
|
||||||
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds
|
||||||
|
#[wasm_bindgen(method, js_name = setSeconds)]
|
||||||
|
pub fn set_seconds(this: &Date, seconds: u32) -> f64;
|
||||||
|
|
||||||
/// The toDateString() method returns the date portion of a Date object
|
/// The toDateString() method returns the date portion of a Date object
|
||||||
/// in human readable form in American English.
|
/// in human readable form in American English.
|
||||||
///
|
///
|
||||||
|
@ -958,6 +958,45 @@ fn set_month() {
|
|||||||
.test()
|
.test()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn set_seconds() {
|
||||||
|
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_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);
|
||||||
|
|
||||||
|
assert.equal(eventMsFromUnixEpoch, 177689742000);
|
||||||
|
assert.equal(event1.getTime(), event2.valueOf());
|
||||||
|
assert.equal(event1.getSeconds(), 42);
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.test()
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn to_date_string() {
|
fn to_date_string() {
|
||||||
project()
|
project()
|
||||||
|
Loading…
Reference in New Issue
Block a user