mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 02:00:51 +00:00
binding for Date.prototype.getUTCDay()
This commit is contained in:
parent
792baefc22
commit
ea19848691
@ -900,6 +900,13 @@ extern "C" {
|
||||
#[wasm_bindgen(method, js_name = getUTCDate)]
|
||||
pub fn get_utc_date(this: &Date) -> u32;
|
||||
|
||||
/// The getUTCDay() method returns the day of the week in the specified date according to universal time,
|
||||
/// where 0 represents Sunday.
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDay
|
||||
#[wasm_bindgen(method, js_name = getUTCDay)]
|
||||
pub fn get_utc_day(this: &Date) -> u32;
|
||||
|
||||
/// Creates a JavaScript Date instance that represents
|
||||
/// a single moment in time. Date objects are based on a time value that is
|
||||
/// the number of milliseconds since 1 January 1970 UTC.
|
||||
|
@ -384,6 +384,42 @@ fn get_utc_date() {
|
||||
.test()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_utc_day() {
|
||||
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_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()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new() {
|
||||
project()
|
||||
|
Loading…
x
Reference in New Issue
Block a user