mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-22 12:42:14 +00:00
binding for Date.prototype.getUTCMonth()
This commit is contained in:
parent
2e85bbd9e0
commit
15d9f743ec
@ -932,6 +932,13 @@ extern "C" {
|
|||||||
#[wasm_bindgen(method, js_name = getUTCMinutes)]
|
#[wasm_bindgen(method, js_name = getUTCMinutes)]
|
||||||
pub fn get_utc_minutes(this: &Date) -> u32;
|
pub fn get_utc_minutes(this: &Date) -> u32;
|
||||||
|
|
||||||
|
/// The getUTCMonth() returns the month of the specified date according to universal time,
|
||||||
|
/// as a zero-based value (where zero indicates the first month of the year).
|
||||||
|
///
|
||||||
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth
|
||||||
|
#[wasm_bindgen(method, js_name = getUTCMonth)]
|
||||||
|
pub fn get_utc_month(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.
|
||||||
|
@ -562,6 +562,42 @@ fn get_utc_minutes() {
|
|||||||
.test()
|
.test()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn get_utc_month() {
|
||||||
|
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_month(this: &Date) -> u32 {
|
||||||
|
this.get_utc_month()
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file(
|
||||||
|
"test.js",
|
||||||
|
r#"
|
||||||
|
import * as assert from "assert";
|
||||||
|
import * as wasm from "./out";
|
||||||
|
|
||||||
|
export function test() {
|
||||||
|
let date1 = new Date('December 31, 1975, 23:15:30 GMT+11:00');
|
||||||
|
let date2 = new Date('December 31, 1975, 23:15:30 GMT-11:00');
|
||||||
|
|
||||||
|
assert.equal(wasm.get_utc_month(date1), 11);
|
||||||
|
assert.equal(wasm.get_utc_month(date2), 0);
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.test()
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn new() {
|
fn new() {
|
||||||
project()
|
project()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user