diff --git a/src/js.rs b/src/js.rs index 9ee03e18..6246197f 100644 --- a/src/js.rs +++ b/src/js.rs @@ -939,6 +939,12 @@ extern "C" { #[wasm_bindgen(method, js_name = getUTCMonth)] pub fn get_utc_month(this: &Date) -> u32; + /// The getUTCSeconds() method returns the seconds in the specified date according to universal time. + /// + /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds + #[wasm_bindgen(method, js_name = getUTCSeconds)] + pub fn get_utc_seconds(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. diff --git a/tests/all/js_globals/Date.rs b/tests/all/js_globals/Date.rs index 946aa7a9..b6cf0dab 100755 --- a/tests/all/js_globals/Date.rs +++ b/tests/all/js_globals/Date.rs @@ -598,6 +598,40 @@ fn get_utc_month() { .test() } +#[test] +fn get_utc_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 get_utc_seconds(this: &Date) -> u32 { + this.get_utc_seconds() + } + "#, + ) + .file( + "test.js", + r#" + import * as assert from "assert"; + import * as wasm from "./out"; + + export function test() { + let date = new Date('July 20, 1969, 20:18:04 UTC'); + + assert.equal(wasm.get_utc_seconds(date), 4); + } + "#, + ) + .test() +} + #[test] fn new() { project()