mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-25 11:02:11 +03:00
binding for Date.prototype.setMinutes()
This commit is contained in:
parent
11a58a1bd0
commit
a81827caf9
@ -1048,6 +1048,12 @@ extern "C" {
|
||||
#[wasm_bindgen(method, js_name = setMilliseconds)]
|
||||
pub fn set_milliseconds(this: &Date, milliseconds: u32) -> f64;
|
||||
|
||||
/// The setMinutes() method sets the minutes for a specified date according to local time.
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes
|
||||
#[wasm_bindgen(method, js_name = setMinutes)]
|
||||
pub fn set_minutes(this: &Date, minutes: u32) -> f64;
|
||||
|
||||
/// The toDateString() method returns the date portion of a Date object
|
||||
/// in human readable form in American English.
|
||||
///
|
||||
|
@ -880,6 +880,45 @@ fn set_milliseconds() {
|
||||
.test()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_minutes() {
|
||||
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_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);
|
||||
|
||||
assert.equal(eventMsFromUnixEpoch, 177691530000);
|
||||
assert.equal(event1.getTime(), event2.valueOf());
|
||||
assert.equal(event1.getMinutes(), 45);
|
||||
}
|
||||
"#,
|
||||
)
|
||||
.test()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn to_date_string() {
|
||||
project()
|
||||
|
Loading…
Reference in New Issue
Block a user