File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -1060,6 +1060,12 @@ extern "C" {
1060
1060
#[ wasm_bindgen( method, js_name = setMonth) ]
1061
1061
pub fn set_month ( this : & Date , month : u32 ) -> f64 ;
1062
1062
1063
+ /// The setSeconds() method sets the seconds for a specified date according to local time.
1064
+ ///
1065
+ /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds
1066
+ #[ wasm_bindgen( method, js_name = setSeconds) ]
1067
+ pub fn set_seconds ( this : & Date , seconds : u32 ) -> f64 ;
1068
+
1063
1069
/// The toDateString() method returns the date portion of a Date object
1064
1070
/// in human readable form in American English.
1065
1071
///
Original file line number Diff line number Diff line change @@ -958,6 +958,45 @@ fn set_month() {
958
958
. test ( )
959
959
}
960
960
961
+ #[ test]
962
+ fn set_seconds ( ) {
963
+ project ( )
964
+ . file (
965
+ "src/lib.rs" ,
966
+ r#"
967
+ #![feature(proc_macro, wasm_custom_section)]
968
+
969
+ extern crate wasm_bindgen;
970
+ use wasm_bindgen::prelude::*;
971
+ use wasm_bindgen::js::Date;
972
+
973
+ #[wasm_bindgen]
974
+ pub fn set_seconds(this: &Date, seconds: u32) -> f64 {
975
+ this.set_seconds(seconds)
976
+ }
977
+ "# ,
978
+ )
979
+ . file (
980
+ "test.js" ,
981
+ r#"
982
+ import * as assert from "assert";
983
+ import * as wasm from "./out";
984
+
985
+ export function test() {
986
+ let event1 = new Date('August 19, 1975 23:15:30');
987
+ let event2 = new Date('August 19, 1975 23:15:42');
988
+
989
+ let eventMsFromUnixEpoch = wasm.set_seconds(event1, 42);
990
+
991
+ assert.equal(eventMsFromUnixEpoch, 177689742000);
992
+ assert.equal(event1.getTime(), event2.valueOf());
993
+ assert.equal(event1.getSeconds(), 42);
994
+ }
995
+ "# ,
996
+ )
997
+ . test ( )
998
+ }
999
+
961
1000
#[ test]
962
1001
fn to_date_string ( ) {
963
1002
project ( )
You can’t perform that action at this time.
0 commit comments