mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-26 11:34:22 +03:00
binding for Date.prototype.getUTCDate()
This commit is contained in:
parent
d3a17d4014
commit
792baefc22
@ -893,6 +893,13 @@ extern "C" {
|
|||||||
#[wasm_bindgen(method, js_name = getTimezoneOffset)]
|
#[wasm_bindgen(method, js_name = getTimezoneOffset)]
|
||||||
pub fn get_timezone_offset(this: &Date) -> f64;
|
pub fn get_timezone_offset(this: &Date) -> f64;
|
||||||
|
|
||||||
|
/// The getUTCDate() method returns the day (date) of the month in the specified date
|
||||||
|
/// according to universal time.
|
||||||
|
///
|
||||||
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDate
|
||||||
|
#[wasm_bindgen(method, js_name = getUTCDate)]
|
||||||
|
pub fn get_utc_date(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.
|
||||||
|
@ -348,6 +348,42 @@ fn get_timezone_offset() {
|
|||||||
.test()
|
.test()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn get_utc_date() {
|
||||||
|
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_date(this: &Date) -> u32 {
|
||||||
|
this.get_utc_date()
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.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_date(date1), 19);
|
||||||
|
assert.equal(wasm.get_utc_date(date2), 20);
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.test()
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn new() {
|
fn new() {
|
||||||
project()
|
project()
|
||||||
|
Loading…
Reference in New Issue
Block a user