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 @@ -1054,6 +1054,12 @@ extern "C" {
1054
1054
#[ wasm_bindgen( method, js_name = setMinutes) ]
1055
1055
pub fn set_minutes ( this : & Date , minutes : u32 ) -> f64 ;
1056
1056
1057
+ /// The setMonth() method sets the month for a specified date according to the currently set year.
1058
+ ///
1059
+ /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth
1060
+ #[ wasm_bindgen( method, js_name = setMonth) ]
1061
+ pub fn set_month ( this : & Date , month : u32 ) -> f64 ;
1062
+
1057
1063
/// The toDateString() method returns the date portion of a Date object
1058
1064
/// in human readable form in American English.
1059
1065
///
Original file line number Diff line number Diff line change @@ -919,6 +919,45 @@ fn set_minutes() {
919
919
. test ( )
920
920
}
921
921
922
+ #[ test]
923
+ fn set_month ( ) {
924
+ project ( )
925
+ . file (
926
+ "src/lib.rs" ,
927
+ r#"
928
+ #![feature(proc_macro, wasm_custom_section)]
929
+
930
+ extern crate wasm_bindgen;
931
+ use wasm_bindgen::prelude::*;
932
+ use wasm_bindgen::js::Date;
933
+
934
+ #[wasm_bindgen]
935
+ pub fn set_month(this: &Date, month: u32) -> f64 {
936
+ this.set_month(month)
937
+ }
938
+ "# ,
939
+ )
940
+ . file (
941
+ "test.js" ,
942
+ r#"
943
+ import * as assert from "assert";
944
+ import * as wasm from "./out";
945
+
946
+ export function test() {
947
+ let event1 = new Date('August 19, 1975 23:15:30');
948
+ let event2 = new Date('April 19, 1975 23:15:30');
949
+
950
+ let eventMsFromUnixEpoch = wasm.set_month(event1, 3);
951
+
952
+ assert.equal(eventMsFromUnixEpoch, 167148930000);
953
+ assert.equal(event1.getTime(), event2.valueOf());
954
+ assert.equal(event1.getMonth(), 3);
955
+ }
956
+ "# ,
957
+ )
958
+ . test ( )
959
+ }
960
+
922
961
#[ test]
923
962
fn to_date_string ( ) {
924
963
project ( )
You can’t perform that action at this time.
0 commit comments