@@ -7202,11 +7202,14 @@ d_lite_marshal_load(VALUE self, VALUE a)
7202
7202
7203
7203
if (simple_dat_p (dat )) {
7204
7204
if (df || !f_zero_p (sf ) || of ) {
7205
- rb_raise (rb_eArgError ,
7206
- "cannot load complex into simple" );
7205
+ /* loading a fractional date; promote to complex */
7206
+ dat = ruby_xrealloc (dat , sizeof (struct ComplexDateData ));
7207
+ RTYPEDDATA (self )-> data = dat ;
7208
+ goto complex_data ;
7207
7209
}
7208
7210
set_to_simple (self , & dat -> s , nth , jd , sg , 0 , 0 , 0 , HAVE_JD );
7209
7211
} else {
7212
+ complex_data :
7210
7213
set_to_complex (self , & dat -> c , nth , jd , df , sf , of , sg ,
7211
7214
0 , 0 , 0 , 0 , 0 , 0 ,
7212
7215
HAVE_JD | HAVE_DF );
@@ -9318,7 +9321,7 @@ Init_date_core(void)
9318
9321
*/
9319
9322
rb_define_const (cDate , "GREGORIAN" , DBL2NUM (GREGORIAN ));
9320
9323
9321
- rb_define_alloc_func (cDate , d_lite_s_alloc_complex );
9324
+ rb_define_alloc_func (cDate , d_lite_s_alloc_simple );
9322
9325
9323
9326
#ifndef NDEBUG
9324
9327
rb_define_private_method (CLASS_OF (cDate ), "_valid_jd?" ,
@@ -9368,7 +9371,6 @@ Init_date_core(void)
9368
9371
rb_define_singleton_method (cDate , "jd" , date_s_jd , -1 );
9369
9372
rb_define_singleton_method (cDate , "ordinal" , date_s_ordinal , -1 );
9370
9373
rb_define_singleton_method (cDate , "civil" , date_s_civil , -1 );
9371
- rb_define_singleton_method (cDate , "new" , date_s_civil , -1 );
9372
9374
rb_define_singleton_method (cDate , "commercial" , date_s_commercial , -1 );
9373
9375
9374
9376
#ifndef NDEBUG
@@ -9396,6 +9398,7 @@ Init_date_core(void)
9396
9398
rb_define_singleton_method (cDate , "_jisx0301" , date_s__jisx0301 , 1 );
9397
9399
rb_define_singleton_method (cDate , "jisx0301" , date_s_jisx0301 , -1 );
9398
9400
9401
+ rb_define_method (cDate , "initialize" , date_initialize , -1 );
9399
9402
rb_define_method (cDate , "initialize_copy" , d_lite_initialize_copy , 1 );
9400
9403
9401
9404
#ifndef NDEBUG
0 commit comments