@@ -143,6 +143,69 @@ fn new() {
143
143
assert ! ( JsValue :: from( Date :: new( & JsValue :: undefined( ) ) ) . is_object( ) ) ;
144
144
}
145
145
146
+ #[ wasm_bindgen_test]
147
+ fn new_with_year_month ( ) {
148
+ let date1 = Date :: new_with_year_month ( 1975 , 7 ) ;
149
+
150
+ assert_eq ! ( date1. get_full_year( ) , 1975 ) ;
151
+ assert_eq ! ( date1. get_month( ) , 7 ) ;
152
+ }
153
+
154
+ #[ wasm_bindgen_test]
155
+ fn new_with_year_month_day ( ) {
156
+ let date1 = Date :: new_with_year_month_day ( 1975 , 7 , 8 ) ;
157
+
158
+ assert_eq ! ( date1. get_full_year( ) , 1975 ) ;
159
+ assert_eq ! ( date1. get_month( ) , 7 ) ;
160
+ assert_eq ! ( date1. get_date( ) , 8 ) ;
161
+ }
162
+
163
+ #[ wasm_bindgen_test]
164
+ fn new_with_year_month_day_hr ( ) {
165
+ let date1 = Date :: new_with_year_month_day_hr ( 1975 , 7 , 8 , 4 ) ;
166
+
167
+ assert_eq ! ( date1. get_full_year( ) , 1975 ) ;
168
+ assert_eq ! ( date1. get_month( ) , 7 ) ;
169
+ assert_eq ! ( date1. get_date( ) , 8 ) ;
170
+ assert_eq ! ( date1. get_hours( ) , 4 ) ;
171
+ }
172
+
173
+ #[ wasm_bindgen_test]
174
+ fn new_with_year_month_day_hr_min ( ) {
175
+ let date1 = Date :: new_with_year_month_day_hr_min ( 1975 , 7 , 8 , 4 , 35 ) ;
176
+
177
+ assert_eq ! ( date1. get_full_year( ) , 1975 ) ;
178
+ assert_eq ! ( date1. get_month( ) , 7 ) ;
179
+ assert_eq ! ( date1. get_date( ) , 8 ) ;
180
+ assert_eq ! ( date1. get_hours( ) , 4 ) ;
181
+ assert_eq ! ( date1. get_minutes( ) , 35 ) ;
182
+ }
183
+
184
+ #[ wasm_bindgen_test]
185
+ fn new_with_year_month_day_hr_min_sec ( ) {
186
+ let date1 = Date :: new_with_year_month_day_hr_min_sec ( 1975 , 7 , 8 , 4 , 35 , 25 ) ;
187
+
188
+ assert_eq ! ( date1. get_full_year( ) , 1975 ) ;
189
+ assert_eq ! ( date1. get_month( ) , 7 ) ;
190
+ assert_eq ! ( date1. get_date( ) , 8 ) ;
191
+ assert_eq ! ( date1. get_hours( ) , 4 ) ;
192
+ assert_eq ! ( date1. get_minutes( ) , 35 ) ;
193
+ assert_eq ! ( date1. get_seconds( ) , 25 ) ;
194
+ }
195
+
196
+ #[ wasm_bindgen_test]
197
+ fn new_with_year_month_day_hr_min_sec_milli ( ) {
198
+ let date1 = Date :: new_with_year_month_day_hr_min_sec_milli ( 1975 , 7 , 8 , 4 , 35 , 25 , 300 ) ;
199
+
200
+ assert_eq ! ( date1. get_full_year( ) , 1975 ) ;
201
+ assert_eq ! ( date1. get_month( ) , 7 ) ;
202
+ assert_eq ! ( date1. get_date( ) , 8 ) ;
203
+ assert_eq ! ( date1. get_hours( ) , 4 ) ;
204
+ assert_eq ! ( date1. get_minutes( ) , 35 ) ;
205
+ assert_eq ! ( date1. get_seconds( ) , 25 ) ;
206
+ assert_eq ! ( date1. get_milliseconds( ) , 300 ) ;
207
+ }
208
+
146
209
#[ wasm_bindgen_test]
147
210
fn now ( ) {
148
211
assert ! ( Date :: now( ) > 0. ) ;
@@ -181,6 +244,27 @@ fn set_full_year() {
181
244
assert_eq ! ( event1. get_full_year( ) , 1976 ) ;
182
245
}
183
246
247
+ #[ wasm_bindgen_test]
248
+ fn set_full_year_with_month ( ) {
249
+ let event1 = Date :: new ( & "August 19, 1976 23:15:30" . into ( ) ) ;
250
+
251
+ event1. set_full_year_with_month ( 1979 , 4 ) ;
252
+
253
+ assert_eq ! ( event1. get_full_year( ) , 1979 ) ;
254
+ assert_eq ! ( event1. get_month( ) , 4 ) ;
255
+ }
256
+
257
+ #[ wasm_bindgen_test]
258
+ fn set_full_year_with_month_date ( ) {
259
+ let event1 = Date :: new ( & "August 19, 1976 23:15:30" . into ( ) ) ;
260
+
261
+ event1. set_full_year_with_month_date ( 1979 , -1 , 25 ) ;
262
+
263
+ assert_eq ! ( event1. get_full_year( ) , 1978 ) ;
264
+ assert_eq ! ( event1. get_month( ) , 11 ) ;
265
+ assert_eq ! ( event1. get_date( ) , 25 ) ;
266
+ }
267
+
184
268
#[ wasm_bindgen_test]
185
269
fn set_hours ( ) {
186
270
let event1 = Date :: new ( & "August 19, 1975 23:15:30" . into ( ) ) ;
@@ -274,6 +358,27 @@ fn set_utc_full_year() {
274
358
assert_eq ! ( event1. get_utc_full_year( ) , 1975 ) ;
275
359
}
276
360
361
+ #[ wasm_bindgen_test]
362
+ fn set_utc_full_year_with_month ( ) {
363
+ let event1 = Date :: new ( & "December 31, 1975 23:15:30 GMT-3:00" . into ( ) ) ;
364
+
365
+ event1. set_utc_full_year_with_month ( 1975 , 6 ) ;
366
+
367
+ assert_eq ! ( event1. get_utc_full_year( ) , 1975 ) ;
368
+ assert_eq ! ( event1. get_utc_month( ) , 6 ) ;
369
+ }
370
+
371
+ #[ wasm_bindgen_test]
372
+ fn set_utc_full_year_with_month_date ( ) {
373
+ let event1 = Date :: new ( & "December 31, 1975 23:15:30 GMT-3:00" . into ( ) ) ;
374
+
375
+ event1. set_utc_full_year_with_month_date ( 1975 , -2 , 21 ) ;
376
+
377
+ assert_eq ! ( event1. get_utc_full_year( ) , 1974 ) ;
378
+ assert_eq ! ( event1. get_utc_month( ) , 10 ) ;
379
+ assert_eq ! ( event1. get_utc_date( ) , 21 ) ;
380
+ }
381
+
277
382
#[ wasm_bindgen_test]
278
383
fn set_utc_hours ( ) {
279
384
let event1 = Date :: new ( & "August 19, 1975 23:15:30 GMT-3:00" . into ( ) ) ;
0 commit comments