@@ -248,6 +248,11 @@ f_negative_p(VALUE x)
248248#define date_sg_t double
249249#endif
250250
251+ #define JULIAN_EPOCH_DATE "-4712-01-01"
252+ #define JULIAN_EPOCH_DATETIME JULIAN_EPOCH_DATE "T00:00:00+00:00"
253+ #define JULIAN_EPOCH_DATETIME_RFC3339 "Mon, 1 Jan -4712 00:00:00 +0000"
254+ #define JULIAN_EPOCH_DATETIME_HTTPDATE "Mon, 01 Jan -4712 00:00:00 GMT"
255+
251256/* A set of nth, jd, df and sf denote ajd + 1/2. Each ajd begin at
252257 * noon of GMT (assume equal to UTC). However, this begins at
253258 * midnight.
@@ -4425,7 +4430,7 @@ date_s_strptime(int argc, VALUE *argv, VALUE klass)
44254430
44264431 switch (argc ) {
44274432 case 0 :
4428- str = rb_str_new2 ("-4712-01-01" );
4433+ str = rb_str_new2 (JULIAN_EPOCH_DATE );
44294434 case 1 :
44304435 fmt = rb_str_new2 ("%F" );
44314436 case 2 :
@@ -4569,7 +4574,7 @@ date_s_parse(int argc, VALUE *argv, VALUE klass)
45694574
45704575 switch (argc ) {
45714576 case 0 :
4572- str = rb_str_new2 ("-4712-01-01" );
4577+ str = rb_str_new2 (JULIAN_EPOCH_DATE );
45734578 case 1 :
45744579 comp = Qtrue ;
45754580 case 2 :
@@ -4648,7 +4653,7 @@ date_s_iso8601(int argc, VALUE *argv, VALUE klass)
46484653
46494654 switch (argc ) {
46504655 case 0 :
4651- str = rb_str_new2 ("-4712-01-01" );
4656+ str = rb_str_new2 (JULIAN_EPOCH_DATE );
46524657 case 1 :
46534658 sg = INT2FIX (DEFAULT_SG );
46544659 }
@@ -4718,7 +4723,7 @@ date_s_rfc3339(int argc, VALUE *argv, VALUE klass)
47184723
47194724 switch (argc ) {
47204725 case 0 :
4721- str = rb_str_new2 ("-4712-01-01T00:00:00+00:00" );
4726+ str = rb_str_new2 (JULIAN_EPOCH_DATETIME );
47224727 case 1 :
47234728 sg = INT2FIX (DEFAULT_SG );
47244729 }
@@ -4786,7 +4791,7 @@ date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
47864791
47874792 switch (argc ) {
47884793 case 0 :
4789- str = rb_str_new2 ("-4712-01-01" );
4794+ str = rb_str_new2 (JULIAN_EPOCH_DATE );
47904795 case 1 :
47914796 sg = INT2FIX (DEFAULT_SG );
47924797 }
@@ -4856,7 +4861,7 @@ date_s_rfc2822(int argc, VALUE *argv, VALUE klass)
48564861
48574862 switch (argc ) {
48584863 case 0 :
4859- str = rb_str_new2 ("Mon, 1 Jan -4712 00:00:00 +0000" );
4864+ str = rb_str_new2 (JULIAN_EPOCH_DATETIME_RFC3339 );
48604865 case 1 :
48614866 sg = INT2FIX (DEFAULT_SG );
48624867 }
@@ -4924,7 +4929,7 @@ date_s_httpdate(int argc, VALUE *argv, VALUE klass)
49244929
49254930 switch (argc ) {
49264931 case 0 :
4927- str = rb_str_new2 ("Mon, 01 Jan -4712 00:00:00 GMT" );
4932+ str = rb_str_new2 (JULIAN_EPOCH_DATETIME_HTTPDATE );
49284933 case 1 :
49294934 sg = INT2FIX (DEFAULT_SG );
49304935 }
@@ -4996,7 +5001,7 @@ date_s_jisx0301(int argc, VALUE *argv, VALUE klass)
49965001
49975002 switch (argc ) {
49985003 case 0 :
4999- str = rb_str_new2 ("-4712-01-01" );
5004+ str = rb_str_new2 (JULIAN_EPOCH_DATE );
50005005 case 1 :
50015006 sg = INT2FIX (DEFAULT_SG );
50025007 }
@@ -8369,7 +8374,7 @@ datetime_s_strptime(int argc, VALUE *argv, VALUE klass)
83698374
83708375 switch (argc ) {
83718376 case 0 :
8372- str = rb_str_new2 ("-4712-01-01T00:00:00+00:00" );
8377+ str = rb_str_new2 (JULIAN_EPOCH_DATETIME );
83738378 case 1 :
83748379 fmt = rb_str_new2 ("%FT%T%z" );
83758380 case 2 :
@@ -8421,7 +8426,7 @@ datetime_s_parse(int argc, VALUE *argv, VALUE klass)
84218426
84228427 switch (argc ) {
84238428 case 0 :
8424- str = rb_str_new2 ("-4712-01-01T00:00:00+00:00" );
8429+ str = rb_str_new2 (JULIAN_EPOCH_DATETIME );
84258430 case 1 :
84268431 comp = Qtrue ;
84278432 case 2 :
@@ -8467,7 +8472,7 @@ datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
84678472
84688473 switch (argc ) {
84698474 case 0 :
8470- str = rb_str_new2 ("-4712-01-01T00:00:00+00:00" );
8475+ str = rb_str_new2 (JULIAN_EPOCH_DATETIME );
84718476 case 1 :
84728477 sg = INT2FIX (DEFAULT_SG );
84738478 }
@@ -8506,7 +8511,7 @@ datetime_s_rfc3339(int argc, VALUE *argv, VALUE klass)
85068511
85078512 switch (argc ) {
85088513 case 0 :
8509- str = rb_str_new2 ("-4712-01-01T00:00:00+00:00" );
8514+ str = rb_str_new2 (JULIAN_EPOCH_DATETIME );
85108515 case 1 :
85118516 sg = INT2FIX (DEFAULT_SG );
85128517 }
@@ -8545,7 +8550,7 @@ datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass)
85458550
85468551 switch (argc ) {
85478552 case 0 :
8548- str = rb_str_new2 ("-4712-01-01T00:00:00+00:00" );
8553+ str = rb_str_new2 (JULIAN_EPOCH_DATETIME );
85498554 case 1 :
85508555 sg = INT2FIX (DEFAULT_SG );
85518556 }
@@ -8585,7 +8590,7 @@ datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
85858590
85868591 switch (argc ) {
85878592 case 0 :
8588- str = rb_str_new2 ("Mon, 1 Jan -4712 00:00:00 +0000" );
8593+ str = rb_str_new2 (JULIAN_EPOCH_DATETIME_RFC3339 );
85898594 case 1 :
85908595 sg = INT2FIX (DEFAULT_SG );
85918596 }
@@ -8624,7 +8629,7 @@ datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)
86248629
86258630 switch (argc ) {
86268631 case 0 :
8627- str = rb_str_new2 ("Mon, 01 Jan -4712 00:00:00 GMT" );
8632+ str = rb_str_new2 (JULIAN_EPOCH_DATETIME_HTTPDATE );
86288633 case 1 :
86298634 sg = INT2FIX (DEFAULT_SG );
86308635 }
@@ -8668,7 +8673,7 @@ datetime_s_jisx0301(int argc, VALUE *argv, VALUE klass)
86688673
86698674 switch (argc ) {
86708675 case 0 :
8671- str = rb_str_new2 ("-4712-01-01T00:00:00+00:00" );
8676+ str = rb_str_new2 (JULIAN_EPOCH_DATETIME );
86728677 case 1 :
86738678 sg = INT2FIX (DEFAULT_SG );
86748679 }
0 commit comments