date 3.2.1 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +102 -0
- data/ext/date/date_core.c +922 -961
- data/ext/date/date_parse.c +89 -42
- data/ext/date/extconf.rb +1 -0
- data/ext/date/zonetab.h +2 -2
- data/ext/date/zonetab.list +1 -1
- data/lib/date.rb +5 -0
- metadata +8 -7
data/ext/date/date_core.c
CHANGED
|
@@ -465,6 +465,7 @@ c_find_ldoy(int y, double sg, int *rjd, int *ns)
|
|
|
465
465
|
}
|
|
466
466
|
|
|
467
467
|
#ifndef NDEBUG
|
|
468
|
+
/* :nodoc: */
|
|
468
469
|
static int
|
|
469
470
|
c_find_fdom(int y, int m, double sg, int *rjd, int *ns)
|
|
470
471
|
{
|
|
@@ -621,6 +622,7 @@ c_jd_to_weeknum(int jd, int f, double sg, int *ry, int *rw, int *rd)
|
|
|
621
622
|
}
|
|
622
623
|
|
|
623
624
|
#ifndef NDEBUG
|
|
625
|
+
/* :nodoc: */
|
|
624
626
|
static void
|
|
625
627
|
c_nth_kday_to_jd(int y, int m, int n, int k, double sg, int *rjd, int *ns)
|
|
626
628
|
{
|
|
@@ -646,6 +648,7 @@ c_jd_to_wday(int jd)
|
|
|
646
648
|
}
|
|
647
649
|
|
|
648
650
|
#ifndef NDEBUG
|
|
651
|
+
/* :nodoc: */
|
|
649
652
|
static void
|
|
650
653
|
c_jd_to_nth_kday(int jd, double sg, int *ry, int *rm, int *rn, int *rk)
|
|
651
654
|
{
|
|
@@ -758,6 +761,8 @@ c_valid_civil_p(int y, int m, int d, double sg,
|
|
|
758
761
|
|
|
759
762
|
if (m < 0)
|
|
760
763
|
m += 13;
|
|
764
|
+
if (m < 1 || m > 12)
|
|
765
|
+
return 0;
|
|
761
766
|
if (d < 0) {
|
|
762
767
|
if (!c_find_ldom(y, m, sg, rjd, ns))
|
|
763
768
|
return 0;
|
|
@@ -822,6 +827,7 @@ c_valid_weeknum_p(int y, int w, int d, int f, double sg,
|
|
|
822
827
|
}
|
|
823
828
|
|
|
824
829
|
#ifndef NDEBUG
|
|
830
|
+
/* :nodoc: */
|
|
825
831
|
static int
|
|
826
832
|
c_valid_nth_kday_p(int y, int m, int n, int k, double sg,
|
|
827
833
|
int *rm, int *rn, int *rk, int *rjd, int *ns)
|
|
@@ -963,6 +969,7 @@ ns_to_day(VALUE n)
|
|
|
963
969
|
}
|
|
964
970
|
|
|
965
971
|
#ifndef NDEBUG
|
|
972
|
+
/* :nodoc: */
|
|
966
973
|
static VALUE
|
|
967
974
|
ms_to_sec(VALUE m)
|
|
968
975
|
{
|
|
@@ -981,6 +988,7 @@ ns_to_sec(VALUE n)
|
|
|
981
988
|
}
|
|
982
989
|
|
|
983
990
|
#ifndef NDEBUG
|
|
991
|
+
/* :nodoc: */
|
|
984
992
|
inline static VALUE
|
|
985
993
|
ins_to_day(int n)
|
|
986
994
|
{
|
|
@@ -1016,6 +1024,7 @@ day_to_sec(VALUE d)
|
|
|
1016
1024
|
}
|
|
1017
1025
|
|
|
1018
1026
|
#ifndef NDEBUG
|
|
1027
|
+
/* :nodoc: */
|
|
1019
1028
|
static VALUE
|
|
1020
1029
|
day_to_ns(VALUE d)
|
|
1021
1030
|
{
|
|
@@ -1040,6 +1049,7 @@ sec_to_ns(VALUE s)
|
|
|
1040
1049
|
}
|
|
1041
1050
|
|
|
1042
1051
|
#ifndef NDEBUG
|
|
1052
|
+
/* :nodoc: */
|
|
1043
1053
|
static VALUE
|
|
1044
1054
|
isec_to_ns(int s)
|
|
1045
1055
|
{
|
|
@@ -1066,6 +1076,7 @@ div_df(VALUE d, VALUE *f)
|
|
|
1066
1076
|
}
|
|
1067
1077
|
|
|
1068
1078
|
#ifndef NDEBUG
|
|
1079
|
+
/* :nodoc: */
|
|
1069
1080
|
static VALUE
|
|
1070
1081
|
div_sf(VALUE s, VALUE *f)
|
|
1071
1082
|
{
|
|
@@ -1500,6 +1511,7 @@ m_df(union DateData *x)
|
|
|
1500
1511
|
}
|
|
1501
1512
|
|
|
1502
1513
|
#ifndef NDEBUG
|
|
1514
|
+
/* :nodoc: */
|
|
1503
1515
|
static VALUE
|
|
1504
1516
|
m_df_in_day(union DateData *x)
|
|
1505
1517
|
{
|
|
@@ -1997,6 +2009,7 @@ expect_numeric(VALUE x)
|
|
|
1997
2009
|
}
|
|
1998
2010
|
|
|
1999
2011
|
#ifndef NDEBUG
|
|
2012
|
+
/* :nodoc: */
|
|
2000
2013
|
static void
|
|
2001
2014
|
civil_to_jd(VALUE y, int m, int d, double sg,
|
|
2002
2015
|
VALUE *nth, int *ry,
|
|
@@ -2309,6 +2322,7 @@ valid_weeknum_p(VALUE y, int w, int d, int f, double sg,
|
|
|
2309
2322
|
}
|
|
2310
2323
|
|
|
2311
2324
|
#ifndef NDEBUG
|
|
2325
|
+
/* :nodoc: */
|
|
2312
2326
|
static int
|
|
2313
2327
|
valid_nth_kday_p(VALUE y, int m, int n, int k, double sg,
|
|
2314
2328
|
VALUE *nth, int *ry,
|
|
@@ -2446,6 +2460,7 @@ valid_jd_sub(int argc, VALUE *argv, VALUE klass, int need_jd)
|
|
|
2446
2460
|
}
|
|
2447
2461
|
|
|
2448
2462
|
#ifndef NDEBUG
|
|
2463
|
+
/* :nodoc: */
|
|
2449
2464
|
static VALUE
|
|
2450
2465
|
date_s__valid_jd_p(int argc, VALUE *argv, VALUE klass)
|
|
2451
2466
|
{
|
|
@@ -2466,13 +2481,16 @@ date_s__valid_jd_p(int argc, VALUE *argv, VALUE klass)
|
|
|
2466
2481
|
|
|
2467
2482
|
/*
|
|
2468
2483
|
* call-seq:
|
|
2469
|
-
*
|
|
2484
|
+
* Date.valid_jd?(jd, start = Date::ITALY) -> true
|
|
2470
2485
|
*
|
|
2471
|
-
*
|
|
2486
|
+
* Implemented for compatibility;
|
|
2487
|
+
* returns +true+ unless +jd+ is invalid (i.e., not a Numeric).
|
|
2472
2488
|
*
|
|
2473
|
-
*
|
|
2489
|
+
* Date.valid_jd?(2451944) # => true
|
|
2474
2490
|
*
|
|
2475
|
-
* See
|
|
2491
|
+
* See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
|
|
2492
|
+
*
|
|
2493
|
+
* Related: Date.jd.
|
|
2476
2494
|
*/
|
|
2477
2495
|
static VALUE
|
|
2478
2496
|
date_s_valid_jd_p(int argc, VALUE *argv, VALUE klass)
|
|
@@ -2532,6 +2550,7 @@ valid_civil_sub(int argc, VALUE *argv, VALUE klass, int need_jd)
|
|
|
2532
2550
|
}
|
|
2533
2551
|
|
|
2534
2552
|
#ifndef NDEBUG
|
|
2553
|
+
/* :nodoc: */
|
|
2535
2554
|
static VALUE
|
|
2536
2555
|
date_s__valid_civil_p(int argc, VALUE *argv, VALUE klass)
|
|
2537
2556
|
{
|
|
@@ -2554,18 +2573,20 @@ date_s__valid_civil_p(int argc, VALUE *argv, VALUE klass)
|
|
|
2554
2573
|
|
|
2555
2574
|
/*
|
|
2556
2575
|
* call-seq:
|
|
2557
|
-
*
|
|
2558
|
-
*
|
|
2576
|
+
* Date.valid_civil?(year, month, mday, start = Date::ITALY) -> true or false
|
|
2577
|
+
*
|
|
2578
|
+
* Returns +true+ if the arguments define a valid ordinal date,
|
|
2579
|
+
* +false+ otherwise:
|
|
2580
|
+
*
|
|
2581
|
+
* Date.valid_date?(2001, 2, 3) # => true
|
|
2582
|
+
* Date.valid_date?(2001, 2, 29) # => false
|
|
2583
|
+
* Date.valid_date?(2001, 2, -1) # => true
|
|
2559
2584
|
*
|
|
2560
|
-
*
|
|
2561
|
-
* Valid in this context is whether the arguments passed to this
|
|
2562
|
-
* method would be accepted by ::new.
|
|
2585
|
+
* See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
|
|
2563
2586
|
*
|
|
2564
|
-
*
|
|
2565
|
-
* Date.valid_date?(2001,2,29) #=> false
|
|
2566
|
-
* Date.valid_date?(2001,2,-1) #=> true
|
|
2587
|
+
* Date.valid_date? is an alias for Date.valid_civil?.
|
|
2567
2588
|
*
|
|
2568
|
-
*
|
|
2589
|
+
* Related: Date.jd, Date.new.
|
|
2569
2590
|
*/
|
|
2570
2591
|
static VALUE
|
|
2571
2592
|
date_s_valid_civil_p(int argc, VALUE *argv, VALUE klass)
|
|
@@ -2621,6 +2642,7 @@ valid_ordinal_sub(int argc, VALUE *argv, VALUE klass, int need_jd)
|
|
|
2621
2642
|
}
|
|
2622
2643
|
|
|
2623
2644
|
#ifndef NDEBUG
|
|
2645
|
+
/* :nodoc: */
|
|
2624
2646
|
static VALUE
|
|
2625
2647
|
date_s__valid_ordinal_p(int argc, VALUE *argv, VALUE klass)
|
|
2626
2648
|
{
|
|
@@ -2642,14 +2664,17 @@ date_s__valid_ordinal_p(int argc, VALUE *argv, VALUE klass)
|
|
|
2642
2664
|
|
|
2643
2665
|
/*
|
|
2644
2666
|
* call-seq:
|
|
2645
|
-
*
|
|
2667
|
+
* Date.valid_ordinal?(year, yday, start = Date::ITALY) -> true or false
|
|
2668
|
+
*
|
|
2669
|
+
* Returns +true+ if the arguments define a valid ordinal date,
|
|
2670
|
+
* +false+ otherwise:
|
|
2646
2671
|
*
|
|
2647
|
-
*
|
|
2672
|
+
* Date.valid_ordinal?(2001, 34) # => true
|
|
2673
|
+
* Date.valid_ordinal?(2001, 366) # => false
|
|
2648
2674
|
*
|
|
2649
|
-
*
|
|
2650
|
-
* Date.valid_ordinal?(2001,366) #=> false
|
|
2675
|
+
* See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
|
|
2651
2676
|
*
|
|
2652
|
-
*
|
|
2677
|
+
* Related: Date.jd, Date.ordinal.
|
|
2653
2678
|
*/
|
|
2654
2679
|
static VALUE
|
|
2655
2680
|
date_s_valid_ordinal_p(int argc, VALUE *argv, VALUE klass)
|
|
@@ -2704,6 +2729,7 @@ valid_commercial_sub(int argc, VALUE *argv, VALUE klass, int need_jd)
|
|
|
2704
2729
|
}
|
|
2705
2730
|
|
|
2706
2731
|
#ifndef NDEBUG
|
|
2732
|
+
/* :nodoc: */
|
|
2707
2733
|
static VALUE
|
|
2708
2734
|
date_s__valid_commercial_p(int argc, VALUE *argv, VALUE klass)
|
|
2709
2735
|
{
|
|
@@ -2726,14 +2752,19 @@ date_s__valid_commercial_p(int argc, VALUE *argv, VALUE klass)
|
|
|
2726
2752
|
|
|
2727
2753
|
/*
|
|
2728
2754
|
* call-seq:
|
|
2729
|
-
*
|
|
2755
|
+
* Date.valid_commercial?(cwyear, cweek, cwday, start = Date::ITALY) -> true or false
|
|
2756
|
+
*
|
|
2757
|
+
* Returns +true+ if the arguments define a valid commercial date,
|
|
2758
|
+
* +false+ otherwise:
|
|
2759
|
+
*
|
|
2760
|
+
* Date.valid_commercial?(2001, 5, 6) # => true
|
|
2761
|
+
* Date.valid_commercial?(2001, 5, 8) # => false
|
|
2730
2762
|
*
|
|
2731
|
-
*
|
|
2763
|
+
* See Date.commercial.
|
|
2732
2764
|
*
|
|
2733
|
-
*
|
|
2734
|
-
* Date.valid_commercial?(2001,5,8) #=> false
|
|
2765
|
+
* See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
|
|
2735
2766
|
*
|
|
2736
|
-
*
|
|
2767
|
+
* Related: Date.jd, Date.commercial.
|
|
2737
2768
|
*/
|
|
2738
2769
|
static VALUE
|
|
2739
2770
|
date_s_valid_commercial_p(int argc, VALUE *argv, VALUE klass)
|
|
@@ -2760,6 +2791,7 @@ date_s_valid_commercial_p(int argc, VALUE *argv, VALUE klass)
|
|
|
2760
2791
|
}
|
|
2761
2792
|
|
|
2762
2793
|
#ifndef NDEBUG
|
|
2794
|
+
/* :nodoc: */
|
|
2763
2795
|
static VALUE
|
|
2764
2796
|
valid_weeknum_sub(int argc, VALUE *argv, VALUE klass, int need_jd)
|
|
2765
2797
|
{
|
|
@@ -2791,6 +2823,7 @@ valid_weeknum_sub(int argc, VALUE *argv, VALUE klass, int need_jd)
|
|
|
2791
2823
|
}
|
|
2792
2824
|
}
|
|
2793
2825
|
|
|
2826
|
+
/* :nodoc: */
|
|
2794
2827
|
static VALUE
|
|
2795
2828
|
date_s__valid_weeknum_p(int argc, VALUE *argv, VALUE klass)
|
|
2796
2829
|
{
|
|
@@ -2811,6 +2844,7 @@ date_s__valid_weeknum_p(int argc, VALUE *argv, VALUE klass)
|
|
|
2811
2844
|
return valid_weeknum_sub(5, argv2, klass, 1);
|
|
2812
2845
|
}
|
|
2813
2846
|
|
|
2847
|
+
/* :nodoc: */
|
|
2814
2848
|
static VALUE
|
|
2815
2849
|
date_s_valid_weeknum_p(int argc, VALUE *argv, VALUE klass)
|
|
2816
2850
|
{
|
|
@@ -2862,6 +2896,7 @@ valid_nth_kday_sub(int argc, VALUE *argv, VALUE klass, int need_jd)
|
|
|
2862
2896
|
}
|
|
2863
2897
|
}
|
|
2864
2898
|
|
|
2899
|
+
/* :nodoc: */
|
|
2865
2900
|
static VALUE
|
|
2866
2901
|
date_s__valid_nth_kday_p(int argc, VALUE *argv, VALUE klass)
|
|
2867
2902
|
{
|
|
@@ -2882,6 +2917,7 @@ date_s__valid_nth_kday_p(int argc, VALUE *argv, VALUE klass)
|
|
|
2882
2917
|
return valid_nth_kday_sub(5, argv2, klass, 1);
|
|
2883
2918
|
}
|
|
2884
2919
|
|
|
2920
|
+
/* :nodoc: */
|
|
2885
2921
|
static VALUE
|
|
2886
2922
|
date_s_valid_nth_kday_p(int argc, VALUE *argv, VALUE klass)
|
|
2887
2923
|
{
|
|
@@ -2904,6 +2940,7 @@ date_s_valid_nth_kday_p(int argc, VALUE *argv, VALUE klass)
|
|
|
2904
2940
|
return Qtrue;
|
|
2905
2941
|
}
|
|
2906
2942
|
|
|
2943
|
+
/* :nodoc: */
|
|
2907
2944
|
static VALUE
|
|
2908
2945
|
date_s_zone_to_diff(VALUE klass, VALUE str)
|
|
2909
2946
|
{
|
|
@@ -2913,13 +2950,15 @@ date_s_zone_to_diff(VALUE klass, VALUE str)
|
|
|
2913
2950
|
|
|
2914
2951
|
/*
|
|
2915
2952
|
* call-seq:
|
|
2916
|
-
*
|
|
2953
|
+
* Date.julian_leap?(year) -> true or false
|
|
2954
|
+
*
|
|
2955
|
+
* Returns +true+ if the given year is a leap year
|
|
2956
|
+
* in the {proleptic Julian calendar}[https://en.wikipedia.org/wiki/Proleptic_Julian_calendar], +false+ otherwise:
|
|
2917
2957
|
*
|
|
2918
|
-
*
|
|
2919
|
-
*
|
|
2958
|
+
* Date.julian_leap?(1900) # => true
|
|
2959
|
+
* Date.julian_leap?(1901) # => false
|
|
2920
2960
|
*
|
|
2921
|
-
*
|
|
2922
|
-
* Date.julian_leap?(1901) #=> false
|
|
2961
|
+
* Related: Date.gregorian_leap?.
|
|
2923
2962
|
*/
|
|
2924
2963
|
static VALUE
|
|
2925
2964
|
date_s_julian_leap_p(VALUE klass, VALUE y)
|
|
@@ -2934,14 +2973,17 @@ date_s_julian_leap_p(VALUE klass, VALUE y)
|
|
|
2934
2973
|
|
|
2935
2974
|
/*
|
|
2936
2975
|
* call-seq:
|
|
2937
|
-
*
|
|
2938
|
-
*
|
|
2976
|
+
* Date.gregorian_leap?(year) -> true or false
|
|
2977
|
+
*
|
|
2978
|
+
* Returns +true+ if the given year is a leap year
|
|
2979
|
+
* in the {proleptic Gregorian calendar}[https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar], +false+ otherwise:
|
|
2980
|
+
*
|
|
2981
|
+
* Date.gregorian_leap?(2000) # => true
|
|
2982
|
+
* Date.gregorian_leap?(2001) # => false
|
|
2939
2983
|
*
|
|
2940
|
-
*
|
|
2941
|
-
* Gregorian calendar.
|
|
2984
|
+
* Date.leap? is an alias for Date.gregorian_leap?.
|
|
2942
2985
|
*
|
|
2943
|
-
*
|
|
2944
|
-
* Date.gregorian_leap?(2000) #=> true
|
|
2986
|
+
* Related: Date.julian_leap?.
|
|
2945
2987
|
*/
|
|
2946
2988
|
static VALUE
|
|
2947
2989
|
date_s_gregorian_leap_p(VALUE klass, VALUE y)
|
|
@@ -3094,6 +3136,7 @@ old_to_new(VALUE ajd, VALUE of, VALUE sg,
|
|
|
3094
3136
|
}
|
|
3095
3137
|
|
|
3096
3138
|
#ifndef NDEBUG
|
|
3139
|
+
/* :nodoc: */
|
|
3097
3140
|
static VALUE
|
|
3098
3141
|
date_s_new_bang(int argc, VALUE *argv, VALUE klass)
|
|
3099
3142
|
{
|
|
@@ -3281,16 +3324,29 @@ static VALUE d_lite_plus(VALUE, VALUE);
|
|
|
3281
3324
|
|
|
3282
3325
|
/*
|
|
3283
3326
|
* call-seq:
|
|
3284
|
-
*
|
|
3327
|
+
* Date.jd(jd = 0, start = Date::ITALY) -> date
|
|
3328
|
+
*
|
|
3329
|
+
* Returns a new \Date object formed from the arguments:
|
|
3330
|
+
*
|
|
3331
|
+
* Date.jd(2451944).to_s # => "2001-02-03"
|
|
3332
|
+
* Date.jd(2451945).to_s # => "2001-02-04"
|
|
3333
|
+
* Date.jd(0).to_s # => "-4712-01-01"
|
|
3334
|
+
*
|
|
3335
|
+
* The returned date is:
|
|
3285
3336
|
*
|
|
3286
|
-
*
|
|
3287
|
-
* number.
|
|
3337
|
+
* - Gregorian, if the argument is greater than or equal to +start+:
|
|
3288
3338
|
*
|
|
3289
|
-
*
|
|
3290
|
-
*
|
|
3291
|
-
*
|
|
3339
|
+
* Date::ITALY # => 2299161
|
|
3340
|
+
* Date.jd(Date::ITALY).gregorian? # => true
|
|
3341
|
+
* Date.jd(Date::ITALY + 1).gregorian? # => true
|
|
3292
3342
|
*
|
|
3293
|
-
*
|
|
3343
|
+
* - Julian, otherwise
|
|
3344
|
+
*
|
|
3345
|
+
* Date.jd(Date::ITALY - 1).julian? # => true
|
|
3346
|
+
*
|
|
3347
|
+
* See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
|
|
3348
|
+
*
|
|
3349
|
+
* Related: Date.new.
|
|
3294
3350
|
*/
|
|
3295
3351
|
static VALUE
|
|
3296
3352
|
date_s_jd(int argc, VALUE *argv, VALUE klass)
|
|
@@ -3329,19 +3385,33 @@ date_s_jd(int argc, VALUE *argv, VALUE klass)
|
|
|
3329
3385
|
|
|
3330
3386
|
/*
|
|
3331
3387
|
* call-seq:
|
|
3332
|
-
*
|
|
3388
|
+
* Date.ordinal(year = -4712, yday = 1, start = Date::ITALY) -> date
|
|
3389
|
+
*
|
|
3390
|
+
* Returns a new \Date object formed fom the arguments.
|
|
3391
|
+
*
|
|
3392
|
+
* With no arguments, returns the date for January 1, -4712:
|
|
3393
|
+
*
|
|
3394
|
+
* Date.ordinal.to_s # => "-4712-01-01"
|
|
3395
|
+
*
|
|
3396
|
+
* With argument +year+, returns the date for January 1 of that year:
|
|
3397
|
+
*
|
|
3398
|
+
* Date.ordinal(2001).to_s # => "2001-01-01"
|
|
3399
|
+
* Date.ordinal(-2001).to_s # => "-2001-01-01"
|
|
3400
|
+
*
|
|
3401
|
+
* With positive argument +yday+ == +n+,
|
|
3402
|
+
* returns the date for the +nth+ day of the given year:
|
|
3403
|
+
*
|
|
3404
|
+
* Date.ordinal(2001, 14).to_s # => "2001-01-14"
|
|
3333
3405
|
*
|
|
3334
|
-
*
|
|
3406
|
+
* With negative argument +yday+, counts backward from the end of the year:
|
|
3335
3407
|
*
|
|
3336
|
-
*
|
|
3337
|
-
* relative day from the end of year when negative). It should not be
|
|
3338
|
-
* zero.
|
|
3408
|
+
* Date.ordinal(2001, -14).to_s # => "2001-12-18"
|
|
3339
3409
|
*
|
|
3340
|
-
*
|
|
3341
|
-
* Date.ordinal(2001,34) #=> #<Date: 2001-02-03 ...>
|
|
3342
|
-
* Date.ordinal(2001,-1) #=> #<Date: 2001-12-31 ...>
|
|
3410
|
+
* Raises an exception if +yday+ is zero or out of range.
|
|
3343
3411
|
*
|
|
3344
|
-
* See
|
|
3412
|
+
* See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
|
|
3413
|
+
*
|
|
3414
|
+
* Related: Date.jd, Date.new.
|
|
3345
3415
|
*/
|
|
3346
3416
|
static VALUE
|
|
3347
3417
|
date_s_ordinal(int argc, VALUE *argv, VALUE klass)
|
|
@@ -3389,29 +3459,7 @@ date_s_ordinal(int argc, VALUE *argv, VALUE klass)
|
|
|
3389
3459
|
}
|
|
3390
3460
|
|
|
3391
3461
|
/*
|
|
3392
|
-
*
|
|
3393
|
-
* Date.civil([year=-4712[, month=1[, mday=1[, start=Date::ITALY]]]]) -> date
|
|
3394
|
-
* Date.new([year=-4712[, month=1[, mday=1[, start=Date::ITALY]]]]) -> date
|
|
3395
|
-
*
|
|
3396
|
-
* Creates a date object denoting the given calendar date.
|
|
3397
|
-
*
|
|
3398
|
-
* In this class, BCE years are counted astronomically. Thus, the
|
|
3399
|
-
* year before the year 1 is the year zero, and the year preceding the
|
|
3400
|
-
* year zero is the year -1. The month and the day of month should be
|
|
3401
|
-
* a negative or a positive number (as a relative month/day from the
|
|
3402
|
-
* end of year/month when negative). They should not be zero.
|
|
3403
|
-
*
|
|
3404
|
-
* The last argument should be a Julian day number which denotes the
|
|
3405
|
-
* day of calendar reform. Date::ITALY (2299161=1582-10-15),
|
|
3406
|
-
* Date::ENGLAND (2361222=1752-09-14), Date::GREGORIAN (the proleptic
|
|
3407
|
-
* Gregorian calendar) and Date::JULIAN (the proleptic Julian
|
|
3408
|
-
* calendar) can be specified as a day of calendar reform.
|
|
3409
|
-
*
|
|
3410
|
-
* Date.new(2001) #=> #<Date: 2001-01-01 ...>
|
|
3411
|
-
* Date.new(2001,2,3) #=> #<Date: 2001-02-03 ...>
|
|
3412
|
-
* Date.new(2001,2,-1) #=> #<Date: 2001-02-28 ...>
|
|
3413
|
-
*
|
|
3414
|
-
* See also ::jd.
|
|
3462
|
+
* Same as Date.new.
|
|
3415
3463
|
*/
|
|
3416
3464
|
static VALUE
|
|
3417
3465
|
date_s_civil(int argc, VALUE *argv, VALUE klass)
|
|
@@ -3419,6 +3467,31 @@ date_s_civil(int argc, VALUE *argv, VALUE klass)
|
|
|
3419
3467
|
return date_initialize(argc, argv, d_lite_s_alloc_simple(klass));
|
|
3420
3468
|
}
|
|
3421
3469
|
|
|
3470
|
+
/*
|
|
3471
|
+
* call-seq:
|
|
3472
|
+
* Date.new(year = -4712, month = 1, mday = 1, start = Date::ITALY) -> date
|
|
3473
|
+
*
|
|
3474
|
+
* Returns a new \Date object constructed from the given arguments:
|
|
3475
|
+
*
|
|
3476
|
+
* Date.new(2022).to_s # => "2022-01-01"
|
|
3477
|
+
* Date.new(2022, 2).to_s # => "2022-02-01"
|
|
3478
|
+
* Date.new(2022, 2, 4).to_s # => "2022-02-04"
|
|
3479
|
+
*
|
|
3480
|
+
* Argument +month+ should be in range (1..12) or range (-12..-1);
|
|
3481
|
+
* when the argument is negative, counts backward from the end of the year:
|
|
3482
|
+
*
|
|
3483
|
+
* Date.new(2022, -11, 4).to_s # => "2022-02-04"
|
|
3484
|
+
*
|
|
3485
|
+
* Argument +mday+ should be in range (1..n) or range (-n..-1)
|
|
3486
|
+
* where +n+ is the number of days in the month;
|
|
3487
|
+
* when the argument is negative, counts backward from the end of the month.
|
|
3488
|
+
*
|
|
3489
|
+
* See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
|
|
3490
|
+
*
|
|
3491
|
+
* Date.civil is an alias for Date.new.
|
|
3492
|
+
*
|
|
3493
|
+
* Related: Date.jd.
|
|
3494
|
+
*/
|
|
3422
3495
|
static VALUE
|
|
3423
3496
|
date_initialize(int argc, VALUE *argv, VALUE self)
|
|
3424
3497
|
{
|
|
@@ -3483,19 +3556,47 @@ date_initialize(int argc, VALUE *argv, VALUE self)
|
|
|
3483
3556
|
|
|
3484
3557
|
/*
|
|
3485
3558
|
* call-seq:
|
|
3486
|
-
*
|
|
3559
|
+
* Date.commercial(cwyear = -4712, cweek = 1, cwday = 1, start = Date::ITALY) -> date
|
|
3560
|
+
*
|
|
3561
|
+
* Returns a new \Date object constructed from the arguments.
|
|
3562
|
+
*
|
|
3563
|
+
* Argument +cwyear+ gives the year, and should be an integer.
|
|
3564
|
+
*
|
|
3565
|
+
* Argument +cweek+ gives the index of the week within the year,
|
|
3566
|
+
* and should be in range (1..53) or (-53..-1);
|
|
3567
|
+
* in some years, 53 or -53 will be out-of-range;
|
|
3568
|
+
* if negative, counts backward from the end of the year:
|
|
3569
|
+
*
|
|
3570
|
+
* Date.commercial(2022, 1, 1).to_s # => "2022-01-03"
|
|
3571
|
+
* Date.commercial(2022, 52, 1).to_s # => "2022-12-26"
|
|
3572
|
+
*
|
|
3573
|
+
* Argument +cwday+ gives the indes of the weekday within the week,
|
|
3574
|
+
* and should be in range (1..7) or (-7..-1);
|
|
3575
|
+
* 1 or -7 is Monday;
|
|
3576
|
+
* if negative, counts backward from the end of the week:
|
|
3577
|
+
*
|
|
3578
|
+
* Date.commercial(2022, 1, 1).to_s # => "2022-01-03"
|
|
3579
|
+
* Date.commercial(2022, 1, -7).to_s # => "2022-01-03"
|
|
3580
|
+
*
|
|
3581
|
+
* When +cweek+ is 1:
|
|
3582
|
+
*
|
|
3583
|
+
* - If January 1 is a Friday, Saturday, or Sunday,
|
|
3584
|
+
* the first week begins in the week after:
|
|
3585
|
+
*
|
|
3586
|
+
* Date::ABBR_DAYNAMES[Date.new(2023, 1, 1).wday] # => "Sun"
|
|
3587
|
+
* Date.commercial(2023, 1, 1).to_s # => "2023-01-02"
|
|
3588
|
+
Date.commercial(2023, 1, 7).to_s # => "2023-01-08"
|
|
3487
3589
|
*
|
|
3488
|
-
*
|
|
3590
|
+
* - Otherwise, the first week is the week of January 1,
|
|
3591
|
+
* which may mean some of the days fall on the year before:
|
|
3489
3592
|
*
|
|
3490
|
-
*
|
|
3491
|
-
*
|
|
3492
|
-
|
|
3593
|
+
* Date::ABBR_DAYNAMES[Date.new(2020, 1, 1).wday] # => "Wed"
|
|
3594
|
+
* Date.commercial(2020, 1, 1).to_s # => "2019-12-30"
|
|
3595
|
+
Date.commercial(2020, 1, 7).to_s # => "2020-01-05"
|
|
3493
3596
|
*
|
|
3494
|
-
*
|
|
3495
|
-
* Date.commercial(2002) #=> #<Date: 2001-12-31 ...>
|
|
3496
|
-
* Date.commercial(2001,5,6) #=> #<Date: 2001-02-03 ...>
|
|
3597
|
+
* See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
|
|
3497
3598
|
*
|
|
3498
|
-
*
|
|
3599
|
+
* Related: Date.jd, Date.new, Date.ordinal.
|
|
3499
3600
|
*/
|
|
3500
3601
|
static VALUE
|
|
3501
3602
|
date_s_commercial(int argc, VALUE *argv, VALUE klass)
|
|
@@ -3547,6 +3648,7 @@ date_s_commercial(int argc, VALUE *argv, VALUE klass)
|
|
|
3547
3648
|
}
|
|
3548
3649
|
|
|
3549
3650
|
#ifndef NDEBUG
|
|
3651
|
+
/* :nodoc: */
|
|
3550
3652
|
static VALUE
|
|
3551
3653
|
date_s_weeknum(int argc, VALUE *argv, VALUE klass)
|
|
3552
3654
|
{
|
|
@@ -3596,6 +3698,7 @@ date_s_weeknum(int argc, VALUE *argv, VALUE klass)
|
|
|
3596
3698
|
return ret;
|
|
3597
3699
|
}
|
|
3598
3700
|
|
|
3701
|
+
/* :nodoc: */
|
|
3599
3702
|
static VALUE
|
|
3600
3703
|
date_s_nth_kday(int argc, VALUE *argv, VALUE klass)
|
|
3601
3704
|
{
|
|
@@ -3670,11 +3773,14 @@ static void set_sg(union DateData *, double);
|
|
|
3670
3773
|
|
|
3671
3774
|
/*
|
|
3672
3775
|
* call-seq:
|
|
3673
|
-
*
|
|
3776
|
+
* Date.today(start = Date::ITALY) -> date
|
|
3777
|
+
*
|
|
3778
|
+
* Returns a new \Date object constructed from the present date:
|
|
3674
3779
|
*
|
|
3675
|
-
*
|
|
3780
|
+
* Date.today.to_s # => "2022-07-06"
|
|
3781
|
+
*
|
|
3782
|
+
* See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
|
|
3676
3783
|
*
|
|
3677
|
-
* Date.today #=> #<Date: 2011-06-11 ...>
|
|
3678
3784
|
*/
|
|
3679
3785
|
static VALUE
|
|
3680
3786
|
date_s_today(int argc, VALUE *argv, VALUE klass)
|
|
@@ -4265,16 +4371,20 @@ date_s__strptime_internal(int argc, VALUE *argv, VALUE klass,
|
|
|
4265
4371
|
|
|
4266
4372
|
/*
|
|
4267
4373
|
* call-seq:
|
|
4268
|
-
*
|
|
4374
|
+
* Date._strptime(string, format = '%F') -> hash
|
|
4269
4375
|
*
|
|
4270
|
-
*
|
|
4271
|
-
*
|
|
4272
|
-
* not support specification of flags and width unlike strftime.
|
|
4376
|
+
* Returns a hash of values parsed from +string+
|
|
4377
|
+
* according to the given +format+:
|
|
4273
4378
|
*
|
|
4274
|
-
*
|
|
4275
|
-
* #=> {:year=>2001, :mon=>2, :mday=>3}
|
|
4379
|
+
* Date._strptime('2001-02-03', '%Y-%m-%d') # => {:year=>2001, :mon=>2, :mday=>3}
|
|
4276
4380
|
*
|
|
4277
|
-
*
|
|
4381
|
+
* For other formats, see
|
|
4382
|
+
* {Formats for Dates and Times}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html].
|
|
4383
|
+
* (Unlike Date.strftime, does not support flags and width.)
|
|
4384
|
+
*
|
|
4385
|
+
* See also {strptime(3)}[https://man7.org/linux/man-pages/man3/strptime.3.html].
|
|
4386
|
+
*
|
|
4387
|
+
* Related: Date.strptime (returns a \Date object).
|
|
4278
4388
|
*/
|
|
4279
4389
|
static VALUE
|
|
4280
4390
|
date_s__strptime(int argc, VALUE *argv, VALUE klass)
|
|
@@ -4284,21 +4394,28 @@ date_s__strptime(int argc, VALUE *argv, VALUE klass)
|
|
|
4284
4394
|
|
|
4285
4395
|
/*
|
|
4286
4396
|
* call-seq:
|
|
4287
|
-
*
|
|
4397
|
+
* Date.strptime(string = '-4712-01-01', format = '%F', start = Date::ITALY) -> date
|
|
4288
4398
|
*
|
|
4289
|
-
*
|
|
4290
|
-
*
|
|
4291
|
-
* specification of flags and width unlike strftime.
|
|
4399
|
+
* Returns a new \Date object with values parsed from +string+,
|
|
4400
|
+
* according to the given +format+:
|
|
4292
4401
|
*
|
|
4293
|
-
*
|
|
4294
|
-
*
|
|
4295
|
-
*
|
|
4296
|
-
*
|
|
4297
|
-
*
|
|
4298
|
-
*
|
|
4299
|
-
*
|
|
4402
|
+
* Date.strptime('2001-02-03', '%Y-%m-%d') # => #<Date: 2001-02-03>
|
|
4403
|
+
* Date.strptime('03-02-2001', '%d-%m-%Y') # => #<Date: 2001-02-03>
|
|
4404
|
+
* Date.strptime('2001-034', '%Y-%j') # => #<Date: 2001-02-03>
|
|
4405
|
+
* Date.strptime('2001-W05-6', '%G-W%V-%u') # => #<Date: 2001-02-03>
|
|
4406
|
+
* Date.strptime('2001 04 6', '%Y %U %w') # => #<Date: 2001-02-03>
|
|
4407
|
+
* Date.strptime('2001 05 6', '%Y %W %u') # => #<Date: 2001-02-03>
|
|
4408
|
+
* Date.strptime('sat3feb01', '%a%d%b%y') # => #<Date: 2001-02-03>
|
|
4300
4409
|
*
|
|
4301
|
-
*
|
|
4410
|
+
* For other formats, see
|
|
4411
|
+
* {Formats for Dates and Times}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html].
|
|
4412
|
+
* (Unlike Date.strftime, does not support flags and width.)
|
|
4413
|
+
*
|
|
4414
|
+
* See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
|
|
4415
|
+
*
|
|
4416
|
+
* See also {strptime(3)}[https://man7.org/linux/man-pages/man3/strptime.3.html].
|
|
4417
|
+
*
|
|
4418
|
+
* Related: Date._strptime (returns a hash).
|
|
4302
4419
|
*/
|
|
4303
4420
|
static VALUE
|
|
4304
4421
|
date_s_strptime(int argc, VALUE *argv, VALUE klass)
|
|
@@ -4339,12 +4456,24 @@ get_limit(VALUE opt)
|
|
|
4339
4456
|
return 128;
|
|
4340
4457
|
}
|
|
4341
4458
|
|
|
4459
|
+
#ifndef HAVE_RB_CATEGORY_WARN
|
|
4460
|
+
#define rb_category_warn(category, fmt) rb_warn(fmt)
|
|
4461
|
+
#endif
|
|
4462
|
+
|
|
4342
4463
|
static void
|
|
4343
4464
|
check_limit(VALUE str, VALUE opt)
|
|
4344
4465
|
{
|
|
4466
|
+
size_t slen, limit;
|
|
4467
|
+
if (NIL_P(str)) return;
|
|
4468
|
+
if (SYMBOL_P(str)) {
|
|
4469
|
+
rb_category_warn(RB_WARN_CATEGORY_DEPRECATED,
|
|
4470
|
+
"The ability to parse Symbol is an unintentional bug and is deprecated");
|
|
4471
|
+
str = rb_sym2str(str);
|
|
4472
|
+
}
|
|
4473
|
+
|
|
4345
4474
|
StringValue(str);
|
|
4346
|
-
|
|
4347
|
-
|
|
4475
|
+
slen = RSTRING_LEN(str);
|
|
4476
|
+
limit = get_limit(opt);
|
|
4348
4477
|
if (slen > limit) {
|
|
4349
4478
|
rb_raise(rb_eArgError,
|
|
4350
4479
|
"string length (%"PRI_SIZE_PREFIX"u) exceeds the limit %"PRI_SIZE_PREFIX"u", slen, limit);
|
|
@@ -4373,25 +4502,32 @@ date_s__parse_internal(int argc, VALUE *argv, VALUE klass)
|
|
|
4373
4502
|
|
|
4374
4503
|
/*
|
|
4375
4504
|
* call-seq:
|
|
4376
|
-
*
|
|
4505
|
+
* Date._parse(string, comp = true, limit: 128) -> hash
|
|
4377
4506
|
*
|
|
4378
|
-
*
|
|
4379
|
-
*
|
|
4507
|
+
* <b>Note</b>:
|
|
4508
|
+
* This method recognizes many forms in +string+,
|
|
4509
|
+
* but it is not a validator.
|
|
4510
|
+
* For formats, see
|
|
4511
|
+
* {"Specialized Format Strings" in Formats for Dates and Times}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-Specialized+Format+Strings]
|
|
4380
4512
|
*
|
|
4381
|
-
*
|
|
4382
|
-
*
|
|
4383
|
-
*
|
|
4384
|
-
* `DateTime._strptime` instead of this method as possible.
|
|
4513
|
+
* If +string+ does not specify a valid date,
|
|
4514
|
+
* the result is unpredictable;
|
|
4515
|
+
* consider using Date._strptime instead.
|
|
4385
4516
|
*
|
|
4386
|
-
*
|
|
4387
|
-
* the range "00" to "99", considers the year a 2-digit form and makes
|
|
4388
|
-
* it full.
|
|
4517
|
+
* Returns a hash of values parsed from +string+:
|
|
4389
4518
|
*
|
|
4390
|
-
*
|
|
4519
|
+
* Date._parse('2001-02-03') # => {:year=>2001, :mon=>2, :mday=>3}
|
|
4391
4520
|
*
|
|
4392
|
-
*
|
|
4393
|
-
*
|
|
4394
|
-
*
|
|
4521
|
+
* If +comp+ is +true+ and the given year is in the range <tt>(0..99)</tt>,
|
|
4522
|
+
* the current century is supplied;
|
|
4523
|
+
* otherwise, the year is taken as given:
|
|
4524
|
+
*
|
|
4525
|
+
* Date._parse('01-02-03', true) # => {:year=>2001, :mon=>2, :mday=>3}
|
|
4526
|
+
* Date._parse('01-02-03', false) # => {:year=>1, :mon=>2, :mday=>3}
|
|
4527
|
+
*
|
|
4528
|
+
* See argument {limit}[rdoc-ref:Date@Argument+limit].
|
|
4529
|
+
*
|
|
4530
|
+
* Related: Date.parse(returns a \Date object).
|
|
4395
4531
|
*/
|
|
4396
4532
|
static VALUE
|
|
4397
4533
|
date_s__parse(int argc, VALUE *argv, VALUE klass)
|
|
@@ -4401,27 +4537,36 @@ date_s__parse(int argc, VALUE *argv, VALUE klass)
|
|
|
4401
4537
|
|
|
4402
4538
|
/*
|
|
4403
4539
|
* call-seq:
|
|
4404
|
-
*
|
|
4540
|
+
* Date.parse(string = '-4712-01-01', comp = true, start = Date::ITALY, limit: 128) -> date
|
|
4405
4541
|
*
|
|
4406
|
-
*
|
|
4407
|
-
*
|
|
4542
|
+
* <b>Note</b>:
|
|
4543
|
+
* This method recognizes many forms in +string+,
|
|
4544
|
+
* but it is not a validator.
|
|
4545
|
+
* For formats, see
|
|
4546
|
+
* {"Specialized Format Strings" in Formats for Dates and Times}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-Specialized+Format+Strings]
|
|
4547
|
+
* If +string+ does not specify a valid date,
|
|
4548
|
+
* the result is unpredictable;
|
|
4549
|
+
* consider using Date._strptime instead.
|
|
4408
4550
|
*
|
|
4409
|
-
*
|
|
4410
|
-
* string does not match valid formats strictly, you may get a cryptic
|
|
4411
|
-
* result. Should consider to use `Date.strptime` instead of this
|
|
4412
|
-
* method as possible.
|
|
4551
|
+
* Returns a new \Date object with values parsed from +string+:
|
|
4413
4552
|
*
|
|
4414
|
-
*
|
|
4415
|
-
*
|
|
4416
|
-
*
|
|
4553
|
+
* Date.parse('2001-02-03') # => #<Date: 2001-02-03>
|
|
4554
|
+
* Date.parse('20010203') # => #<Date: 2001-02-03>
|
|
4555
|
+
* Date.parse('3rd Feb 2001') # => #<Date: 2001-02-03>
|
|
4417
4556
|
*
|
|
4418
|
-
*
|
|
4419
|
-
*
|
|
4420
|
-
*
|
|
4557
|
+
* If +comp+ is +true+ and the given year is in the range <tt>(0..99)</tt>,
|
|
4558
|
+
* the current century is supplied;
|
|
4559
|
+
* otherwise, the year is taken as given:
|
|
4421
4560
|
*
|
|
4422
|
-
*
|
|
4423
|
-
*
|
|
4424
|
-
*
|
|
4561
|
+
* Date.parse('01-02-03', true) # => #<Date: 2001-02-03>
|
|
4562
|
+
* Date.parse('01-02-03', false) # => #<Date: 0001-02-03>
|
|
4563
|
+
*
|
|
4564
|
+
* See:
|
|
4565
|
+
*
|
|
4566
|
+
* - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
|
|
4567
|
+
* - Argument {limit}[rdoc-ref:Date@Argument+limit].
|
|
4568
|
+
*
|
|
4569
|
+
* Related: Date._parse (returns a hash).
|
|
4425
4570
|
*/
|
|
4426
4571
|
static VALUE
|
|
4427
4572
|
date_s_parse(int argc, VALUE *argv, VALUE klass)
|
|
@@ -4442,11 +4587,11 @@ date_s_parse(int argc, VALUE *argv, VALUE klass)
|
|
|
4442
4587
|
|
|
4443
4588
|
{
|
|
4444
4589
|
int argc2 = 2;
|
|
4445
|
-
VALUE argv2[3];
|
|
4590
|
+
VALUE argv2[3], hash;
|
|
4446
4591
|
argv2[0] = str;
|
|
4447
4592
|
argv2[1] = comp;
|
|
4448
4593
|
if (!NIL_P(opt)) argv2[argc2++] = opt;
|
|
4449
|
-
|
|
4594
|
+
hash = date_s__parse(argc2, argv2, klass);
|
|
4450
4595
|
return d_new_by_frags(klass, hash, sg);
|
|
4451
4596
|
}
|
|
4452
4597
|
}
|
|
@@ -4460,13 +4605,18 @@ VALUE date__jisx0301(VALUE);
|
|
|
4460
4605
|
|
|
4461
4606
|
/*
|
|
4462
4607
|
* call-seq:
|
|
4463
|
-
*
|
|
4608
|
+
* Date._iso8601(string, limit: 128) -> hash
|
|
4464
4609
|
*
|
|
4465
|
-
* Returns a hash of parsed
|
|
4610
|
+
* Returns a hash of values parsed from +string+, which should contain
|
|
4611
|
+
* an {ISO 8601 formatted date}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-ISO+8601+Format+Specifications]:
|
|
4466
4612
|
*
|
|
4467
|
-
*
|
|
4468
|
-
*
|
|
4469
|
-
*
|
|
4613
|
+
* d = Date.new(2001, 2, 3)
|
|
4614
|
+
* s = d.iso8601 # => "2001-02-03"
|
|
4615
|
+
* Date._iso8601(s) # => {:mday=>3, :year=>2001, :mon=>2}
|
|
4616
|
+
*
|
|
4617
|
+
* See argument {limit}[rdoc-ref:Date@Argument+limit].
|
|
4618
|
+
*
|
|
4619
|
+
* Related: Date.iso8601 (returns a \Date object).
|
|
4470
4620
|
*/
|
|
4471
4621
|
static VALUE
|
|
4472
4622
|
date_s__iso8601(int argc, VALUE *argv, VALUE klass)
|
|
@@ -4481,18 +4631,22 @@ date_s__iso8601(int argc, VALUE *argv, VALUE klass)
|
|
|
4481
4631
|
|
|
4482
4632
|
/*
|
|
4483
4633
|
* call-seq:
|
|
4484
|
-
*
|
|
4634
|
+
* Date.iso8601(string = '-4712-01-01', start = Date::ITALY, limit: 128) -> date
|
|
4485
4635
|
*
|
|
4486
|
-
*
|
|
4487
|
-
*
|
|
4636
|
+
* Returns a new \Date object with values parsed from +string+,
|
|
4637
|
+
* which should contain
|
|
4638
|
+
* an {ISO 8601 formatted date}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-ISO+8601+Format+Specifications]:
|
|
4488
4639
|
*
|
|
4489
|
-
*
|
|
4490
|
-
*
|
|
4491
|
-
*
|
|
4640
|
+
* d = Date.new(2001, 2, 3)
|
|
4641
|
+
* s = d.iso8601 # => "2001-02-03"
|
|
4642
|
+
* Date.iso8601(s) # => #<Date: 2001-02-03>
|
|
4492
4643
|
*
|
|
4493
|
-
*
|
|
4494
|
-
*
|
|
4495
|
-
*
|
|
4644
|
+
* See:
|
|
4645
|
+
*
|
|
4646
|
+
* - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
|
|
4647
|
+
* - Argument {limit}[rdoc-ref:Date@Argument+limit].
|
|
4648
|
+
*
|
|
4649
|
+
* Related: Date._iso8601 (returns a hash).
|
|
4496
4650
|
*/
|
|
4497
4651
|
static VALUE
|
|
4498
4652
|
date_s_iso8601(int argc, VALUE *argv, VALUE klass)
|
|
@@ -4511,23 +4665,29 @@ date_s_iso8601(int argc, VALUE *argv, VALUE klass)
|
|
|
4511
4665
|
|
|
4512
4666
|
{
|
|
4513
4667
|
int argc2 = 1;
|
|
4514
|
-
VALUE argv2[2];
|
|
4668
|
+
VALUE argv2[2], hash;
|
|
4515
4669
|
argv2[0] = str;
|
|
4516
4670
|
if (!NIL_P(opt)) argv2[argc2++] = opt;
|
|
4517
|
-
|
|
4671
|
+
hash = date_s__iso8601(argc2, argv2, klass);
|
|
4518
4672
|
return d_new_by_frags(klass, hash, sg);
|
|
4519
4673
|
}
|
|
4520
4674
|
}
|
|
4521
4675
|
|
|
4522
4676
|
/*
|
|
4523
4677
|
* call-seq:
|
|
4524
|
-
*
|
|
4678
|
+
* Date._rfc3339(string, limit: 128) -> hash
|
|
4525
4679
|
*
|
|
4526
|
-
* Returns a hash of parsed
|
|
4680
|
+
* Returns a hash of values parsed from +string+, which should be a valid
|
|
4681
|
+
* {RFC 3339 format}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-RFC+3339+Format]:
|
|
4527
4682
|
*
|
|
4528
|
-
*
|
|
4529
|
-
*
|
|
4530
|
-
*
|
|
4683
|
+
* d = Date.new(2001, 2, 3)
|
|
4684
|
+
* s = d.rfc3339 # => "2001-02-03T00:00:00+00:00"
|
|
4685
|
+
* Date._rfc3339(s)
|
|
4686
|
+
* # => {:year=>2001, :mon=>2, :mday=>3, :hour=>0, :min=>0, :sec=>0, :zone=>"+00:00", :offset=>0}
|
|
4687
|
+
*
|
|
4688
|
+
* See argument {limit}[rdoc-ref:Date@Argument+limit].
|
|
4689
|
+
*
|
|
4690
|
+
* Related: Date.rfc3339 (returns a \Date object).
|
|
4531
4691
|
*/
|
|
4532
4692
|
static VALUE
|
|
4533
4693
|
date_s__rfc3339(int argc, VALUE *argv, VALUE klass)
|
|
@@ -4542,16 +4702,22 @@ date_s__rfc3339(int argc, VALUE *argv, VALUE klass)
|
|
|
4542
4702
|
|
|
4543
4703
|
/*
|
|
4544
4704
|
* call-seq:
|
|
4545
|
-
*
|
|
4705
|
+
* Date.rfc3339(string = '-4712-01-01T00:00:00+00:00', start = Date::ITALY, limit: 128) -> date
|
|
4546
4706
|
*
|
|
4547
|
-
*
|
|
4548
|
-
*
|
|
4707
|
+
* Returns a new \Date object with values parsed from +string+,
|
|
4708
|
+
* which should be a valid
|
|
4709
|
+
* {RFC 3339 format}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-RFC+3339+Format]:
|
|
4549
4710
|
*
|
|
4550
|
-
*
|
|
4711
|
+
* d = Date.new(2001, 2, 3)
|
|
4712
|
+
* s = d.rfc3339 # => "2001-02-03T00:00:00+00:00"
|
|
4713
|
+
* Date.rfc3339(s) # => #<Date: 2001-02-03>
|
|
4551
4714
|
*
|
|
4552
|
-
*
|
|
4553
|
-
*
|
|
4554
|
-
*
|
|
4715
|
+
* See:
|
|
4716
|
+
*
|
|
4717
|
+
* - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
|
|
4718
|
+
* - Argument {limit}[rdoc-ref:Date@Argument+limit].
|
|
4719
|
+
*
|
|
4720
|
+
* Related: Date._rfc3339 (returns a hash).
|
|
4555
4721
|
*/
|
|
4556
4722
|
static VALUE
|
|
4557
4723
|
date_s_rfc3339(int argc, VALUE *argv, VALUE klass)
|
|
@@ -4570,23 +4736,28 @@ date_s_rfc3339(int argc, VALUE *argv, VALUE klass)
|
|
|
4570
4736
|
|
|
4571
4737
|
{
|
|
4572
4738
|
int argc2 = 1;
|
|
4573
|
-
VALUE argv2[2];
|
|
4739
|
+
VALUE argv2[2], hash;
|
|
4574
4740
|
argv2[0] = str;
|
|
4575
4741
|
if (!NIL_P(opt)) argv2[argc2++] = opt;
|
|
4576
|
-
|
|
4742
|
+
hash = date_s__rfc3339(argc2, argv2, klass);
|
|
4577
4743
|
return d_new_by_frags(klass, hash, sg);
|
|
4578
4744
|
}
|
|
4579
4745
|
}
|
|
4580
4746
|
|
|
4581
4747
|
/*
|
|
4582
4748
|
* call-seq:
|
|
4583
|
-
*
|
|
4749
|
+
* Date._xmlschema(string, limit: 128) -> hash
|
|
4584
4750
|
*
|
|
4585
|
-
* Returns a hash of parsed
|
|
4751
|
+
* Returns a hash of values parsed from +string+, which should be a valid
|
|
4752
|
+
* XML date format:
|
|
4586
4753
|
*
|
|
4587
|
-
*
|
|
4588
|
-
*
|
|
4589
|
-
*
|
|
4754
|
+
* d = Date.new(2001, 2, 3)
|
|
4755
|
+
* s = d.xmlschema # => "2001-02-03"
|
|
4756
|
+
* Date._xmlschema(s) # => {:year=>2001, :mon=>2, :mday=>3}
|
|
4757
|
+
*
|
|
4758
|
+
* See argument {limit}[rdoc-ref:Date@Argument+limit].
|
|
4759
|
+
*
|
|
4760
|
+
* Related: Date.xmlschema (returns a \Date object).
|
|
4590
4761
|
*/
|
|
4591
4762
|
static VALUE
|
|
4592
4763
|
date_s__xmlschema(int argc, VALUE *argv, VALUE klass)
|
|
@@ -4601,16 +4772,21 @@ date_s__xmlschema(int argc, VALUE *argv, VALUE klass)
|
|
|
4601
4772
|
|
|
4602
4773
|
/*
|
|
4603
4774
|
* call-seq:
|
|
4604
|
-
*
|
|
4775
|
+
* Date.xmlschema(string = '-4712-01-01', start = Date::ITALY, limit: 128) -> date
|
|
4605
4776
|
*
|
|
4606
|
-
*
|
|
4607
|
-
*
|
|
4777
|
+
* Returns a new \Date object with values parsed from +string+,
|
|
4778
|
+
* which should be a valid XML date format:
|
|
4608
4779
|
*
|
|
4609
|
-
*
|
|
4780
|
+
* d = Date.new(2001, 2, 3)
|
|
4781
|
+
* s = d.xmlschema # => "2001-02-03"
|
|
4782
|
+
* Date.xmlschema(s) # => #<Date: 2001-02-03>
|
|
4610
4783
|
*
|
|
4611
|
-
*
|
|
4612
|
-
*
|
|
4613
|
-
*
|
|
4784
|
+
* See:
|
|
4785
|
+
*
|
|
4786
|
+
* - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
|
|
4787
|
+
* - Argument {limit}[rdoc-ref:Date@Argument+limit].
|
|
4788
|
+
*
|
|
4789
|
+
* Related: Date._xmlschema (returns a hash).
|
|
4614
4790
|
*/
|
|
4615
4791
|
static VALUE
|
|
4616
4792
|
date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
|
|
@@ -4629,24 +4805,31 @@ date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
|
|
|
4629
4805
|
|
|
4630
4806
|
{
|
|
4631
4807
|
int argc2 = 1;
|
|
4632
|
-
VALUE argv2[2];
|
|
4808
|
+
VALUE argv2[2], hash;
|
|
4633
4809
|
argv2[0] = str;
|
|
4634
4810
|
if (!NIL_P(opt)) argv2[argc2++] = opt;
|
|
4635
|
-
|
|
4811
|
+
hash = date_s__xmlschema(argc2, argv2, klass);
|
|
4636
4812
|
return d_new_by_frags(klass, hash, sg);
|
|
4637
4813
|
}
|
|
4638
4814
|
}
|
|
4639
4815
|
|
|
4640
4816
|
/*
|
|
4641
4817
|
* call-seq:
|
|
4642
|
-
*
|
|
4643
|
-
* Date._rfc822(string, limit: 128) -> hash
|
|
4818
|
+
* Date._rfc2822(string, limit: 128) -> hash
|
|
4644
4819
|
*
|
|
4645
|
-
* Returns a hash of parsed
|
|
4820
|
+
* Returns a hash of values parsed from +string+, which should be a valid
|
|
4821
|
+
* {RFC 2822 date format}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-RFC+2822+Format]:
|
|
4646
4822
|
*
|
|
4647
|
-
*
|
|
4648
|
-
*
|
|
4649
|
-
*
|
|
4823
|
+
* d = Date.new(2001, 2, 3)
|
|
4824
|
+
* s = d.rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
|
|
4825
|
+
* Date._rfc2822(s)
|
|
4826
|
+
* # => {:wday=>6, :mday=>3, :mon=>2, :year=>2001, :hour=>0, :min=>0, :sec=>0, :zone=>"+0000", :offset=>0}
|
|
4827
|
+
*
|
|
4828
|
+
* See argument {limit}[rdoc-ref:Date@Argument+limit].
|
|
4829
|
+
*
|
|
4830
|
+
* Date._rfc822 is an alias for Date._rfc2822.
|
|
4831
|
+
*
|
|
4832
|
+
* Related: Date.rfc2822 (returns a \Date object).
|
|
4650
4833
|
*/
|
|
4651
4834
|
static VALUE
|
|
4652
4835
|
date_s__rfc2822(int argc, VALUE *argv, VALUE klass)
|
|
@@ -4661,18 +4844,24 @@ date_s__rfc2822(int argc, VALUE *argv, VALUE klass)
|
|
|
4661
4844
|
|
|
4662
4845
|
/*
|
|
4663
4846
|
* call-seq:
|
|
4664
|
-
*
|
|
4665
|
-
* Date.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> date
|
|
4847
|
+
* Date.rfc2822(string = 'Mon, 1 Jan -4712 00:00:00 +0000', start = Date::ITALY, limit: 128) -> date
|
|
4666
4848
|
*
|
|
4667
|
-
*
|
|
4668
|
-
*
|
|
4849
|
+
* Returns a new \Date object with values parsed from +string+,
|
|
4850
|
+
* which should be a valid
|
|
4851
|
+
* {RFC 2822 date format}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-RFC+2822+Format]:
|
|
4669
4852
|
*
|
|
4670
|
-
*
|
|
4671
|
-
*
|
|
4853
|
+
* d = Date.new(2001, 2, 3)
|
|
4854
|
+
* s = d.rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
|
|
4855
|
+
* Date.rfc2822(s) # => #<Date: 2001-02-03>
|
|
4672
4856
|
*
|
|
4673
|
-
*
|
|
4674
|
-
*
|
|
4675
|
-
*
|
|
4857
|
+
* See:
|
|
4858
|
+
*
|
|
4859
|
+
* - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
|
|
4860
|
+
* - Argument {limit}[rdoc-ref:Date@Argument+limit].
|
|
4861
|
+
*
|
|
4862
|
+
* Date.rfc822 is an alias for Date.rfc2822.
|
|
4863
|
+
*
|
|
4864
|
+
* Related: Date._rfc2822 (returns a hash).
|
|
4676
4865
|
*/
|
|
4677
4866
|
static VALUE
|
|
4678
4867
|
date_s_rfc2822(int argc, VALUE *argv, VALUE klass)
|
|
@@ -4690,23 +4879,27 @@ date_s_rfc2822(int argc, VALUE *argv, VALUE klass)
|
|
|
4690
4879
|
|
|
4691
4880
|
{
|
|
4692
4881
|
int argc2 = 1;
|
|
4693
|
-
VALUE argv2[2];
|
|
4882
|
+
VALUE argv2[2], hash;
|
|
4694
4883
|
argv2[0] = str;
|
|
4695
4884
|
if (!NIL_P(opt)) argv2[argc2++] = opt;
|
|
4696
|
-
|
|
4885
|
+
hash = date_s__rfc2822(argc2, argv2, klass);
|
|
4697
4886
|
return d_new_by_frags(klass, hash, sg);
|
|
4698
4887
|
}
|
|
4699
4888
|
}
|
|
4700
4889
|
|
|
4701
4890
|
/*
|
|
4702
4891
|
* call-seq:
|
|
4703
|
-
*
|
|
4892
|
+
* Date._httpdate(string, limit: 128) -> hash
|
|
4704
4893
|
*
|
|
4705
|
-
* Returns a hash of parsed
|
|
4894
|
+
* Returns a hash of values parsed from +string+, which should be a valid
|
|
4895
|
+
* {HTTP date format}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-HTTP+Format]:
|
|
4706
4896
|
*
|
|
4707
|
-
*
|
|
4708
|
-
*
|
|
4709
|
-
*
|
|
4897
|
+
* d = Date.new(2001, 2, 3)
|
|
4898
|
+
* s = d.httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT"
|
|
4899
|
+
* Date._httpdate(s)
|
|
4900
|
+
* # => {:wday=>6, :mday=>3, :mon=>2, :year=>2001, :hour=>0, :min=>0, :sec=>0, :zone=>"GMT", :offset=>0}
|
|
4901
|
+
*
|
|
4902
|
+
* Related: Date.httpdate (returns a \Date object).
|
|
4710
4903
|
*/
|
|
4711
4904
|
static VALUE
|
|
4712
4905
|
date_s__httpdate(int argc, VALUE *argv, VALUE klass)
|
|
@@ -4721,17 +4914,22 @@ date_s__httpdate(int argc, VALUE *argv, VALUE klass)
|
|
|
4721
4914
|
|
|
4722
4915
|
/*
|
|
4723
4916
|
* call-seq:
|
|
4724
|
-
*
|
|
4917
|
+
* Date.httpdate(string = 'Mon, 01 Jan -4712 00:00:00 GMT', start = Date::ITALY, limit: 128) -> date
|
|
4725
4918
|
*
|
|
4726
|
-
*
|
|
4727
|
-
*
|
|
4919
|
+
* Returns a new \Date object with values parsed from +string+,
|
|
4920
|
+
* which should be a valid
|
|
4921
|
+
* {HTTP date format}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-HTTP+Format]:
|
|
4728
4922
|
*
|
|
4729
|
-
*
|
|
4730
|
-
|
|
4923
|
+
* d = Date.new(2001, 2, 3)
|
|
4924
|
+
s = d.httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT"
|
|
4925
|
+
Date.httpdate(s) # => #<Date: 2001-02-03>
|
|
4731
4926
|
*
|
|
4732
|
-
*
|
|
4733
|
-
*
|
|
4734
|
-
*
|
|
4927
|
+
* See:
|
|
4928
|
+
*
|
|
4929
|
+
* - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
|
|
4930
|
+
* - Argument {limit}[rdoc-ref:Date@Argument+limit].
|
|
4931
|
+
*
|
|
4932
|
+
* Related: Date._httpdate (returns a hash).
|
|
4735
4933
|
*/
|
|
4736
4934
|
static VALUE
|
|
4737
4935
|
date_s_httpdate(int argc, VALUE *argv, VALUE klass)
|
|
@@ -4749,23 +4947,28 @@ date_s_httpdate(int argc, VALUE *argv, VALUE klass)
|
|
|
4749
4947
|
|
|
4750
4948
|
{
|
|
4751
4949
|
int argc2 = 1;
|
|
4752
|
-
VALUE argv2[2];
|
|
4950
|
+
VALUE argv2[2], hash;
|
|
4753
4951
|
argv2[0] = str;
|
|
4754
4952
|
if (!NIL_P(opt)) argv2[argc2++] = opt;
|
|
4755
|
-
|
|
4953
|
+
hash = date_s__httpdate(argc2, argv2, klass);
|
|
4756
4954
|
return d_new_by_frags(klass, hash, sg);
|
|
4757
4955
|
}
|
|
4758
4956
|
}
|
|
4759
4957
|
|
|
4760
4958
|
/*
|
|
4761
4959
|
* call-seq:
|
|
4762
|
-
*
|
|
4960
|
+
* Date._jisx0301(string, limit: 128) -> hash
|
|
4763
4961
|
*
|
|
4764
|
-
* Returns a hash of parsed
|
|
4962
|
+
* Returns a hash of values parsed from +string+, which should be a valid
|
|
4963
|
+
* {JIS X 0301 date format}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-JIS+X+0301+Format]:
|
|
4765
4964
|
*
|
|
4766
|
-
*
|
|
4767
|
-
*
|
|
4768
|
-
*
|
|
4965
|
+
* d = Date.new(2001, 2, 3)
|
|
4966
|
+
* s = d.jisx0301 # => "H13.02.03"
|
|
4967
|
+
* Date._jisx0301(s) # => {:year=>2001, :mon=>2, :mday=>3}
|
|
4968
|
+
*
|
|
4969
|
+
* See argument {limit}[rdoc-ref:Date@Argument+limit].
|
|
4970
|
+
*
|
|
4971
|
+
* Related: Date.jisx0301 (returns a \Date object).
|
|
4769
4972
|
*/
|
|
4770
4973
|
static VALUE
|
|
4771
4974
|
date_s__jisx0301(int argc, VALUE *argv, VALUE klass)
|
|
@@ -4780,20 +4983,25 @@ date_s__jisx0301(int argc, VALUE *argv, VALUE klass)
|
|
|
4780
4983
|
|
|
4781
4984
|
/*
|
|
4782
4985
|
* call-seq:
|
|
4783
|
-
*
|
|
4986
|
+
* Date.jisx0301(string = '-4712-01-01', start = Date::ITALY, limit: 128) -> date
|
|
4784
4987
|
*
|
|
4785
|
-
*
|
|
4786
|
-
*
|
|
4988
|
+
* Returns a new \Date object with values parsed from +string+,
|
|
4989
|
+
* which should be a valid {JIS X 0301 format}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-JIS+X+0301+Format]:
|
|
4787
4990
|
*
|
|
4788
|
-
*
|
|
4991
|
+
* d = Date.new(2001, 2, 3)
|
|
4992
|
+
* s = d.jisx0301 # => "H13.02.03"
|
|
4993
|
+
* Date.jisx0301(s) # => #<Date: 2001-02-03>
|
|
4789
4994
|
*
|
|
4790
4995
|
* For no-era year, legacy format, Heisei is assumed.
|
|
4791
4996
|
*
|
|
4792
|
-
*
|
|
4997
|
+
* Date.jisx0301('13.02.03') # => #<Date: 2001-02-03>
|
|
4793
4998
|
*
|
|
4794
|
-
*
|
|
4795
|
-
*
|
|
4796
|
-
*
|
|
4999
|
+
* See:
|
|
5000
|
+
*
|
|
5001
|
+
* - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
|
|
5002
|
+
* - Argument {limit}[rdoc-ref:Date@Argument+limit].
|
|
5003
|
+
*
|
|
5004
|
+
* Related: Date._jisx0301 (returns a hash).
|
|
4797
5005
|
*/
|
|
4798
5006
|
static VALUE
|
|
4799
5007
|
date_s_jisx0301(int argc, VALUE *argv, VALUE klass)
|
|
@@ -4812,10 +5020,10 @@ date_s_jisx0301(int argc, VALUE *argv, VALUE klass)
|
|
|
4812
5020
|
|
|
4813
5021
|
{
|
|
4814
5022
|
int argc2 = 1;
|
|
4815
|
-
VALUE argv2[2];
|
|
5023
|
+
VALUE argv2[2], hash;
|
|
4816
5024
|
argv2[0] = str;
|
|
4817
5025
|
if (!NIL_P(opt)) argv2[argc2++] = opt;
|
|
4818
|
-
|
|
5026
|
+
hash = date_s__jisx0301(argc2, argv2, klass);
|
|
4819
5027
|
return d_new_by_frags(klass, hash, sg);
|
|
4820
5028
|
}
|
|
4821
5029
|
}
|
|
@@ -4985,6 +5193,7 @@ d_lite_initialize_copy(VALUE copy, VALUE date)
|
|
|
4985
5193
|
}
|
|
4986
5194
|
|
|
4987
5195
|
#ifndef NDEBUG
|
|
5196
|
+
/* :nodoc: */
|
|
4988
5197
|
static VALUE
|
|
4989
5198
|
d_lite_fill(VALUE self)
|
|
4990
5199
|
{
|
|
@@ -5074,12 +5283,15 @@ d_lite_mjd(VALUE self)
|
|
|
5074
5283
|
|
|
5075
5284
|
/*
|
|
5076
5285
|
* call-seq:
|
|
5077
|
-
*
|
|
5286
|
+
* ld -> integer
|
|
5078
5287
|
*
|
|
5079
|
-
* Returns the
|
|
5080
|
-
*
|
|
5288
|
+
* Returns the
|
|
5289
|
+
* {Lilian day number}[https://en.wikipedia.org/wiki/Lilian_date],
|
|
5290
|
+
* which is the number of days since the beginning of the Gregorian
|
|
5291
|
+
* calendar, October 15, 1582.
|
|
5292
|
+
*
|
|
5293
|
+
* Date.new(2001, 2, 3).ld # => 152784
|
|
5081
5294
|
*
|
|
5082
|
-
* Date.new(2001,2,3).ld #=> 152784
|
|
5083
5295
|
*/
|
|
5084
5296
|
static VALUE
|
|
5085
5297
|
d_lite_ld(VALUE self)
|
|
@@ -5090,12 +5302,13 @@ d_lite_ld(VALUE self)
|
|
|
5090
5302
|
|
|
5091
5303
|
/*
|
|
5092
5304
|
* call-seq:
|
|
5093
|
-
*
|
|
5305
|
+
* year -> integer
|
|
5306
|
+
*
|
|
5307
|
+
* Returns the year:
|
|
5094
5308
|
*
|
|
5095
|
-
*
|
|
5309
|
+
* Date.new(2001, 2, 3).year # => 2001
|
|
5310
|
+
* (Date.new(1, 1, 1) - 1).year # => 0
|
|
5096
5311
|
*
|
|
5097
|
-
* Date.new(2001,2,3).year #=> 2001
|
|
5098
|
-
* (Date.new(1,1,1) - 1).year #=> 0
|
|
5099
5312
|
*/
|
|
5100
5313
|
static VALUE
|
|
5101
5314
|
d_lite_year(VALUE self)
|
|
@@ -5106,11 +5319,12 @@ d_lite_year(VALUE self)
|
|
|
5106
5319
|
|
|
5107
5320
|
/*
|
|
5108
5321
|
* call-seq:
|
|
5109
|
-
*
|
|
5322
|
+
* yday -> integer
|
|
5110
5323
|
*
|
|
5111
|
-
* Returns the day of the year (1
|
|
5324
|
+
* Returns the day of the year, in range (1..366):
|
|
5325
|
+
*
|
|
5326
|
+
* Date.new(2001, 2, 3).yday # => 34
|
|
5112
5327
|
*
|
|
5113
|
-
* Date.new(2001,2,3).yday #=> 34
|
|
5114
5328
|
*/
|
|
5115
5329
|
static VALUE
|
|
5116
5330
|
d_lite_yday(VALUE self)
|
|
@@ -5121,12 +5335,13 @@ d_lite_yday(VALUE self)
|
|
|
5121
5335
|
|
|
5122
5336
|
/*
|
|
5123
5337
|
* call-seq:
|
|
5124
|
-
*
|
|
5125
|
-
*
|
|
5338
|
+
* mon -> integer
|
|
5339
|
+
*
|
|
5340
|
+
* Returns the month in range (1..12):
|
|
5126
5341
|
*
|
|
5127
|
-
*
|
|
5342
|
+
* Date.new(2001, 2, 3).mon # => 2
|
|
5128
5343
|
*
|
|
5129
|
-
*
|
|
5344
|
+
* Date#month is an alias for Date#mon.
|
|
5130
5345
|
*/
|
|
5131
5346
|
static VALUE
|
|
5132
5347
|
d_lite_mon(VALUE self)
|
|
@@ -5137,12 +5352,13 @@ d_lite_mon(VALUE self)
|
|
|
5137
5352
|
|
|
5138
5353
|
/*
|
|
5139
5354
|
* call-seq:
|
|
5140
|
-
*
|
|
5141
|
-
* d.day -> fixnum
|
|
5355
|
+
* mday -> integer
|
|
5142
5356
|
*
|
|
5143
|
-
* Returns the day of the month (1
|
|
5357
|
+
* Returns the day of the month in range (1..31):
|
|
5144
5358
|
*
|
|
5145
|
-
*
|
|
5359
|
+
* Date.new(2001, 2, 3).mday # => 3
|
|
5360
|
+
*
|
|
5361
|
+
* Date#day is an alias for Date#mday.
|
|
5146
5362
|
*/
|
|
5147
5363
|
static VALUE
|
|
5148
5364
|
d_lite_mday(VALUE self)
|
|
@@ -5153,11 +5369,12 @@ d_lite_mday(VALUE self)
|
|
|
5153
5369
|
|
|
5154
5370
|
/*
|
|
5155
5371
|
* call-seq:
|
|
5156
|
-
*
|
|
5372
|
+
* day_fraction -> rational
|
|
5373
|
+
*
|
|
5374
|
+
* Returns the fractional part of the day in range (Rational(0, 1)...Rational(1, 1)):
|
|
5157
5375
|
*
|
|
5158
|
-
*
|
|
5376
|
+
* DateTime.new(2001,2,3,12).day_fraction # => (1/2)
|
|
5159
5377
|
*
|
|
5160
|
-
* DateTime.new(2001,2,3,12).day_fraction #=> (1/2)
|
|
5161
5378
|
*/
|
|
5162
5379
|
static VALUE
|
|
5163
5380
|
d_lite_day_fraction(VALUE self)
|
|
@@ -5170,12 +5387,14 @@ d_lite_day_fraction(VALUE self)
|
|
|
5170
5387
|
|
|
5171
5388
|
/*
|
|
5172
5389
|
* call-seq:
|
|
5173
|
-
*
|
|
5390
|
+
* cwyear -> integer
|
|
5391
|
+
*
|
|
5392
|
+
* Returns commercial-date year for +self+
|
|
5393
|
+
* (see Date.commercial):
|
|
5174
5394
|
*
|
|
5175
|
-
*
|
|
5395
|
+
* Date.new(2001, 2, 3).cwyear # => 2001
|
|
5396
|
+
* Date.new(2000, 1, 1).cwyear # => 1999
|
|
5176
5397
|
*
|
|
5177
|
-
* Date.new(2001,2,3).cwyear #=> 2001
|
|
5178
|
-
* Date.new(2000,1,1).cwyear #=> 1999
|
|
5179
5398
|
*/
|
|
5180
5399
|
static VALUE
|
|
5181
5400
|
d_lite_cwyear(VALUE self)
|
|
@@ -5186,11 +5405,13 @@ d_lite_cwyear(VALUE self)
|
|
|
5186
5405
|
|
|
5187
5406
|
/*
|
|
5188
5407
|
* call-seq:
|
|
5189
|
-
*
|
|
5408
|
+
* cweek -> integer
|
|
5190
5409
|
*
|
|
5191
|
-
* Returns
|
|
5410
|
+
* Returns commercial-date week index for +self+
|
|
5411
|
+
* (see Date.commercial):
|
|
5412
|
+
*
|
|
5413
|
+
* Date.new(2001, 2, 3).cweek # => 5
|
|
5192
5414
|
*
|
|
5193
|
-
* Date.new(2001,2,3).cweek #=> 5
|
|
5194
5415
|
*/
|
|
5195
5416
|
static VALUE
|
|
5196
5417
|
d_lite_cweek(VALUE self)
|
|
@@ -5201,11 +5422,14 @@ d_lite_cweek(VALUE self)
|
|
|
5201
5422
|
|
|
5202
5423
|
/*
|
|
5203
5424
|
* call-seq:
|
|
5204
|
-
*
|
|
5425
|
+
* cwday -> integer
|
|
5426
|
+
*
|
|
5427
|
+
* Returns the commercial-date weekday index for +self+
|
|
5428
|
+
* (see Date.commercial);
|
|
5429
|
+
* 1 is Monday:
|
|
5205
5430
|
*
|
|
5206
|
-
*
|
|
5431
|
+
* Date.new(2001, 2, 3).cwday # => 6
|
|
5207
5432
|
*
|
|
5208
|
-
* Date.new(2001,2,3).cwday #=> 6
|
|
5209
5433
|
*/
|
|
5210
5434
|
static VALUE
|
|
5211
5435
|
d_lite_cwday(VALUE self)
|
|
@@ -5215,6 +5439,7 @@ d_lite_cwday(VALUE self)
|
|
|
5215
5439
|
}
|
|
5216
5440
|
|
|
5217
5441
|
#ifndef NDEBUG
|
|
5442
|
+
/* :nodoc: */
|
|
5218
5443
|
static VALUE
|
|
5219
5444
|
d_lite_wnum0(VALUE self)
|
|
5220
5445
|
{
|
|
@@ -5222,6 +5447,7 @@ d_lite_wnum0(VALUE self)
|
|
|
5222
5447
|
return INT2FIX(m_wnum0(dat));
|
|
5223
5448
|
}
|
|
5224
5449
|
|
|
5450
|
+
/* :nodoc: */
|
|
5225
5451
|
static VALUE
|
|
5226
5452
|
d_lite_wnum1(VALUE self)
|
|
5227
5453
|
{
|
|
@@ -5232,11 +5458,12 @@ d_lite_wnum1(VALUE self)
|
|
|
5232
5458
|
|
|
5233
5459
|
/*
|
|
5234
5460
|
* call-seq:
|
|
5235
|
-
*
|
|
5461
|
+
* wday -> integer
|
|
5236
5462
|
*
|
|
5237
|
-
* Returns the day of week (0
|
|
5463
|
+
* Returns the day of week in range (0..6); Sunday is 0:
|
|
5464
|
+
*
|
|
5465
|
+
* Date.new(2001, 2, 3).wday # => 6
|
|
5238
5466
|
*
|
|
5239
|
-
* Date.new(2001,2,3).wday #=> 6
|
|
5240
5467
|
*/
|
|
5241
5468
|
static VALUE
|
|
5242
5469
|
d_lite_wday(VALUE self)
|
|
@@ -5247,9 +5474,9 @@ d_lite_wday(VALUE self)
|
|
|
5247
5474
|
|
|
5248
5475
|
/*
|
|
5249
5476
|
* call-seq:
|
|
5250
|
-
*
|
|
5477
|
+
* sunday? -> true or false
|
|
5251
5478
|
*
|
|
5252
|
-
* Returns true if
|
|
5479
|
+
* Returns +true+ if +self+ is a Sunday, +false+ otherwise.
|
|
5253
5480
|
*/
|
|
5254
5481
|
static VALUE
|
|
5255
5482
|
d_lite_sunday_p(VALUE self)
|
|
@@ -5260,9 +5487,9 @@ d_lite_sunday_p(VALUE self)
|
|
|
5260
5487
|
|
|
5261
5488
|
/*
|
|
5262
5489
|
* call-seq:
|
|
5263
|
-
*
|
|
5490
|
+
* monday? -> true or false
|
|
5264
5491
|
*
|
|
5265
|
-
* Returns true if
|
|
5492
|
+
* Returns +true+ if +self+ is a Monday, +false+ otherwise.
|
|
5266
5493
|
*/
|
|
5267
5494
|
static VALUE
|
|
5268
5495
|
d_lite_monday_p(VALUE self)
|
|
@@ -5273,9 +5500,9 @@ d_lite_monday_p(VALUE self)
|
|
|
5273
5500
|
|
|
5274
5501
|
/*
|
|
5275
5502
|
* call-seq:
|
|
5276
|
-
*
|
|
5503
|
+
* tuesday? -> true or false
|
|
5277
5504
|
*
|
|
5278
|
-
* Returns true if
|
|
5505
|
+
* Returns +true+ if +self+ is a Tuesday, +false+ otherwise.
|
|
5279
5506
|
*/
|
|
5280
5507
|
static VALUE
|
|
5281
5508
|
d_lite_tuesday_p(VALUE self)
|
|
@@ -5286,9 +5513,9 @@ d_lite_tuesday_p(VALUE self)
|
|
|
5286
5513
|
|
|
5287
5514
|
/*
|
|
5288
5515
|
* call-seq:
|
|
5289
|
-
*
|
|
5516
|
+
* wednesday? -> true or false
|
|
5290
5517
|
*
|
|
5291
|
-
* Returns true if
|
|
5518
|
+
* Returns +true+ if +self+ is a Wednesday, +false+ otherwise.
|
|
5292
5519
|
*/
|
|
5293
5520
|
static VALUE
|
|
5294
5521
|
d_lite_wednesday_p(VALUE self)
|
|
@@ -5299,9 +5526,9 @@ d_lite_wednesday_p(VALUE self)
|
|
|
5299
5526
|
|
|
5300
5527
|
/*
|
|
5301
5528
|
* call-seq:
|
|
5302
|
-
*
|
|
5529
|
+
* thursday? -> true or false
|
|
5303
5530
|
*
|
|
5304
|
-
* Returns true if
|
|
5531
|
+
* Returns +true+ if +self+ is a Thursday, +false+ otherwise.
|
|
5305
5532
|
*/
|
|
5306
5533
|
static VALUE
|
|
5307
5534
|
d_lite_thursday_p(VALUE self)
|
|
@@ -5312,9 +5539,9 @@ d_lite_thursday_p(VALUE self)
|
|
|
5312
5539
|
|
|
5313
5540
|
/*
|
|
5314
5541
|
* call-seq:
|
|
5315
|
-
*
|
|
5542
|
+
* friday? -> true or false
|
|
5316
5543
|
*
|
|
5317
|
-
* Returns true if
|
|
5544
|
+
* Returns +true+ if +self+ is a Friday, +false+ otherwise.
|
|
5318
5545
|
*/
|
|
5319
5546
|
static VALUE
|
|
5320
5547
|
d_lite_friday_p(VALUE self)
|
|
@@ -5325,9 +5552,9 @@ d_lite_friday_p(VALUE self)
|
|
|
5325
5552
|
|
|
5326
5553
|
/*
|
|
5327
5554
|
* call-seq:
|
|
5328
|
-
*
|
|
5555
|
+
* saturday? -> true or false
|
|
5329
5556
|
*
|
|
5330
|
-
* Returns true if
|
|
5557
|
+
* Returns +true+ if +self+ is a Saturday, +false+ otherwise.
|
|
5331
5558
|
*/
|
|
5332
5559
|
static VALUE
|
|
5333
5560
|
d_lite_saturday_p(VALUE self)
|
|
@@ -5337,6 +5564,7 @@ d_lite_saturday_p(VALUE self)
|
|
|
5337
5564
|
}
|
|
5338
5565
|
|
|
5339
5566
|
#ifndef NDEBUG
|
|
5567
|
+
/* :nodoc: */
|
|
5340
5568
|
static VALUE
|
|
5341
5569
|
d_lite_nth_kday_p(VALUE self, VALUE n, VALUE k)
|
|
5342
5570
|
{
|
|
@@ -5358,11 +5586,12 @@ d_lite_nth_kday_p(VALUE self, VALUE n, VALUE k)
|
|
|
5358
5586
|
|
|
5359
5587
|
/*
|
|
5360
5588
|
* call-seq:
|
|
5361
|
-
*
|
|
5589
|
+
* hour -> integer
|
|
5362
5590
|
*
|
|
5363
|
-
* Returns the hour (0
|
|
5591
|
+
* Returns the hour in range (0..23):
|
|
5592
|
+
*
|
|
5593
|
+
* DateTime.new(2001, 2, 3, 4, 5, 6).hour # => 4
|
|
5364
5594
|
*
|
|
5365
|
-
* DateTime.new(2001,2,3,4,5,6).hour #=> 4
|
|
5366
5595
|
*/
|
|
5367
5596
|
static VALUE
|
|
5368
5597
|
d_lite_hour(VALUE self)
|
|
@@ -5373,12 +5602,13 @@ d_lite_hour(VALUE self)
|
|
|
5373
5602
|
|
|
5374
5603
|
/*
|
|
5375
5604
|
* call-seq:
|
|
5376
|
-
*
|
|
5377
|
-
*
|
|
5605
|
+
* min -> integer
|
|
5606
|
+
*
|
|
5607
|
+
* Returns the minute in range (0..59):
|
|
5378
5608
|
*
|
|
5379
|
-
*
|
|
5609
|
+
* DateTime.new(2001, 2, 3, 4, 5, 6).min # => 5
|
|
5380
5610
|
*
|
|
5381
|
-
*
|
|
5611
|
+
* Date#minute is an alias for Date#min.
|
|
5382
5612
|
*/
|
|
5383
5613
|
static VALUE
|
|
5384
5614
|
d_lite_min(VALUE self)
|
|
@@ -5389,12 +5619,13 @@ d_lite_min(VALUE self)
|
|
|
5389
5619
|
|
|
5390
5620
|
/*
|
|
5391
5621
|
* call-seq:
|
|
5392
|
-
*
|
|
5393
|
-
*
|
|
5622
|
+
* sec -> integer
|
|
5623
|
+
*
|
|
5624
|
+
* Returns the second in range (0..59):
|
|
5394
5625
|
*
|
|
5395
|
-
*
|
|
5626
|
+
* DateTime.new(2001, 2, 3, 4, 5, 6).sec # => 6
|
|
5396
5627
|
*
|
|
5397
|
-
*
|
|
5628
|
+
* Date#second is an alias for Date#sec.
|
|
5398
5629
|
*/
|
|
5399
5630
|
static VALUE
|
|
5400
5631
|
d_lite_sec(VALUE self)
|
|
@@ -5405,12 +5636,14 @@ d_lite_sec(VALUE self)
|
|
|
5405
5636
|
|
|
5406
5637
|
/*
|
|
5407
5638
|
* call-seq:
|
|
5408
|
-
*
|
|
5409
|
-
* d.second_fraction -> rational
|
|
5639
|
+
* sec_fraction -> rational
|
|
5410
5640
|
*
|
|
5411
|
-
* Returns the fractional part of the second
|
|
5641
|
+
* Returns the fractional part of the second in range
|
|
5642
|
+
* (Rational(0, 1)...Rational(1, 1)):
|
|
5412
5643
|
*
|
|
5413
|
-
*
|
|
5644
|
+
* DateTime.new(2001, 2, 3, 4, 5, 6.5).sec_fraction # => (1/2)
|
|
5645
|
+
*
|
|
5646
|
+
* Date#second_fraction is an alias for Date#sec_fraction.
|
|
5414
5647
|
*/
|
|
5415
5648
|
static VALUE
|
|
5416
5649
|
d_lite_sec_fraction(VALUE self)
|
|
@@ -5451,12 +5684,14 @@ d_lite_zone(VALUE self)
|
|
|
5451
5684
|
|
|
5452
5685
|
/*
|
|
5453
5686
|
* call-seq:
|
|
5454
|
-
*
|
|
5687
|
+
* d.julian? -> true or false
|
|
5688
|
+
*
|
|
5689
|
+
* Returns +true+ if the date is before the date of calendar reform,
|
|
5690
|
+
* +false+ otherwise:
|
|
5455
5691
|
*
|
|
5456
|
-
*
|
|
5692
|
+
* (Date.new(1582, 10, 15) - 1).julian? # => true
|
|
5693
|
+
* Date.new(1582, 10, 15).julian? # => false
|
|
5457
5694
|
*
|
|
5458
|
-
* Date.new(1582,10,15).julian? #=> false
|
|
5459
|
-
* (Date.new(1582,10,15) - 1).julian? #=> true
|
|
5460
5695
|
*/
|
|
5461
5696
|
static VALUE
|
|
5462
5697
|
d_lite_julian_p(VALUE self)
|
|
@@ -5467,12 +5702,14 @@ d_lite_julian_p(VALUE self)
|
|
|
5467
5702
|
|
|
5468
5703
|
/*
|
|
5469
5704
|
* call-seq:
|
|
5470
|
-
*
|
|
5705
|
+
* gregorian? -> true or false
|
|
5471
5706
|
*
|
|
5472
|
-
* Returns true if the date is on or after
|
|
5707
|
+
* Returns +true+ if the date is on or after
|
|
5708
|
+
* the date of calendar reform, +false+ otherwise:
|
|
5709
|
+
*
|
|
5710
|
+
* Date.new(1582, 10, 15).gregorian? # => true
|
|
5711
|
+
* (Date.new(1582, 10, 15) - 1).gregorian? # => false
|
|
5473
5712
|
*
|
|
5474
|
-
* Date.new(1582,10,15).gregorian? #=> true
|
|
5475
|
-
* (Date.new(1582,10,15) - 1).gregorian? #=> false
|
|
5476
5713
|
*/
|
|
5477
5714
|
static VALUE
|
|
5478
5715
|
d_lite_gregorian_p(VALUE self)
|
|
@@ -5483,12 +5720,13 @@ d_lite_gregorian_p(VALUE self)
|
|
|
5483
5720
|
|
|
5484
5721
|
/*
|
|
5485
5722
|
* call-seq:
|
|
5486
|
-
*
|
|
5723
|
+
* leap? -> true or false
|
|
5724
|
+
*
|
|
5725
|
+
* Returns +true+ if the year is a leap year, +false+ otherwise:
|
|
5487
5726
|
*
|
|
5488
|
-
*
|
|
5727
|
+
* Date.new(2000).leap? # => true
|
|
5728
|
+
* Date.new(2001).leap? # => false
|
|
5489
5729
|
*
|
|
5490
|
-
* Date.new(2000).leap? #=> true
|
|
5491
|
-
* Date.new(2001).leap? #=> false
|
|
5492
5730
|
*/
|
|
5493
5731
|
static VALUE
|
|
5494
5732
|
d_lite_leap_p(VALUE self)
|
|
@@ -5507,12 +5745,25 @@ d_lite_leap_p(VALUE self)
|
|
|
5507
5745
|
|
|
5508
5746
|
/*
|
|
5509
5747
|
* call-seq:
|
|
5510
|
-
*
|
|
5748
|
+
* start -> float
|
|
5749
|
+
*
|
|
5750
|
+
* Returns the Julian start date for calendar reform;
|
|
5751
|
+
* if not an infinity, the returned value is suitable
|
|
5752
|
+
* for passing to Date#jd:
|
|
5753
|
+
*
|
|
5754
|
+
* d = Date.new(2001, 2, 3, Date::ITALY)
|
|
5755
|
+
* s = d.start # => 2299161.0
|
|
5756
|
+
* Date.jd(s).to_s # => "1582-10-15"
|
|
5511
5757
|
*
|
|
5512
|
-
*
|
|
5758
|
+
* d = Date.new(2001, 2, 3, Date::ENGLAND)
|
|
5759
|
+
* s = d.start # => 2361222.0
|
|
5760
|
+
* Date.jd(s).to_s # => "1752-09-14"
|
|
5761
|
+
*
|
|
5762
|
+
* Date.new(2001, 2, 3, Date::GREGORIAN).start # => -Infinity
|
|
5763
|
+
* Date.new(2001, 2, 3, Date::JULIAN).start # => Infinity
|
|
5764
|
+
*
|
|
5765
|
+
* See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
|
|
5513
5766
|
*
|
|
5514
|
-
* Date.new(2001,2,3).start #=> 2299161.0
|
|
5515
|
-
* Date.new(2001,2,3,Date::GREGORIAN).start #=> -Infinity
|
|
5516
5767
|
*/
|
|
5517
5768
|
static VALUE
|
|
5518
5769
|
d_lite_start(VALUE self)
|
|
@@ -5577,12 +5828,17 @@ dup_obj_with_new_start(VALUE obj, double sg)
|
|
|
5577
5828
|
|
|
5578
5829
|
/*
|
|
5579
5830
|
* call-seq:
|
|
5580
|
-
*
|
|
5831
|
+
* new_start(start = Date::ITALY]) -> new_date
|
|
5832
|
+
*
|
|
5833
|
+
* Returns a copy of +self+ with the given +start+ value:
|
|
5581
5834
|
*
|
|
5582
|
-
*
|
|
5835
|
+
* d0 = Date.new(2000, 2, 3)
|
|
5836
|
+
* d0.julian? # => false
|
|
5837
|
+
* d1 = d0.new_start(Date::JULIAN)
|
|
5838
|
+
* d1.julian? # => true
|
|
5839
|
+
*
|
|
5840
|
+
* See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
|
|
5583
5841
|
*
|
|
5584
|
-
* d = Date.new(1582,10,15)
|
|
5585
|
-
* d.new_start(Date::JULIAN) #=> #<Date: 1582-10-05 ...>
|
|
5586
5842
|
*/
|
|
5587
5843
|
static VALUE
|
|
5588
5844
|
d_lite_new_start(int argc, VALUE *argv, VALUE self)
|
|
@@ -5601,9 +5857,10 @@ d_lite_new_start(int argc, VALUE *argv, VALUE self)
|
|
|
5601
5857
|
|
|
5602
5858
|
/*
|
|
5603
5859
|
* call-seq:
|
|
5604
|
-
*
|
|
5860
|
+
* italy -> new_date
|
|
5861
|
+
*
|
|
5862
|
+
* Equivalent to Date#new_start with argument Date::ITALY.
|
|
5605
5863
|
*
|
|
5606
|
-
* This method is equivalent to new_start(Date::ITALY).
|
|
5607
5864
|
*/
|
|
5608
5865
|
static VALUE
|
|
5609
5866
|
d_lite_italy(VALUE self)
|
|
@@ -5613,9 +5870,9 @@ d_lite_italy(VALUE self)
|
|
|
5613
5870
|
|
|
5614
5871
|
/*
|
|
5615
5872
|
* call-seq:
|
|
5616
|
-
*
|
|
5873
|
+
* england -> new_date
|
|
5617
5874
|
*
|
|
5618
|
-
*
|
|
5875
|
+
* Equivalent to Date#new_start with argument Date::ENGLAND.
|
|
5619
5876
|
*/
|
|
5620
5877
|
static VALUE
|
|
5621
5878
|
d_lite_england(VALUE self)
|
|
@@ -5625,9 +5882,9 @@ d_lite_england(VALUE self)
|
|
|
5625
5882
|
|
|
5626
5883
|
/*
|
|
5627
5884
|
* call-seq:
|
|
5628
|
-
*
|
|
5885
|
+
* julian -> new_date
|
|
5629
5886
|
*
|
|
5630
|
-
*
|
|
5887
|
+
* Equivalent to Date#new_start with argument Date::JULIAN.
|
|
5631
5888
|
*/
|
|
5632
5889
|
static VALUE
|
|
5633
5890
|
d_lite_julian(VALUE self)
|
|
@@ -5637,9 +5894,9 @@ d_lite_julian(VALUE self)
|
|
|
5637
5894
|
|
|
5638
5895
|
/*
|
|
5639
5896
|
* call-seq:
|
|
5640
|
-
*
|
|
5897
|
+
* gregorian -> new_date
|
|
5641
5898
|
*
|
|
5642
|
-
*
|
|
5899
|
+
* Equivalent to Date#new_start with argument Date::GREGORIAN.
|
|
5643
5900
|
*/
|
|
5644
5901
|
static VALUE
|
|
5645
5902
|
d_lite_gregorian(VALUE self)
|
|
@@ -6120,9 +6377,9 @@ d_lite_minus(VALUE self, VALUE other)
|
|
|
6120
6377
|
|
|
6121
6378
|
/*
|
|
6122
6379
|
* call-seq:
|
|
6123
|
-
*
|
|
6380
|
+
* next_day(n = 1) -> new_date
|
|
6124
6381
|
*
|
|
6125
|
-
*
|
|
6382
|
+
* Equivalent to Date#+ with argument +n+.
|
|
6126
6383
|
*/
|
|
6127
6384
|
static VALUE
|
|
6128
6385
|
d_lite_next_day(int argc, VALUE *argv, VALUE self)
|
|
@@ -6137,9 +6394,9 @@ d_lite_next_day(int argc, VALUE *argv, VALUE self)
|
|
|
6137
6394
|
|
|
6138
6395
|
/*
|
|
6139
6396
|
* call-seq:
|
|
6140
|
-
*
|
|
6397
|
+
* prev_day(n = 1) -> new_date
|
|
6141
6398
|
*
|
|
6142
|
-
*
|
|
6399
|
+
* Equivalent to Date#- with argument +n+.
|
|
6143
6400
|
*/
|
|
6144
6401
|
static VALUE
|
|
6145
6402
|
d_lite_prev_day(int argc, VALUE *argv, VALUE self)
|
|
@@ -6154,10 +6411,15 @@ d_lite_prev_day(int argc, VALUE *argv, VALUE self)
|
|
|
6154
6411
|
|
|
6155
6412
|
/*
|
|
6156
6413
|
* call-seq:
|
|
6157
|
-
*
|
|
6158
|
-
* d.next -> date
|
|
6414
|
+
* d.next -> new_date
|
|
6159
6415
|
*
|
|
6160
|
-
* Returns a
|
|
6416
|
+
* Returns a new \Date object representing the following day:
|
|
6417
|
+
*
|
|
6418
|
+
* d = Date.new(2001, 2, 3)
|
|
6419
|
+
* d.to_s # => "2001-02-03"
|
|
6420
|
+
* d.next.to_s # => "2001-02-04"
|
|
6421
|
+
*
|
|
6422
|
+
* Date#succ is an alias for Date#next.
|
|
6161
6423
|
*/
|
|
6162
6424
|
static VALUE
|
|
6163
6425
|
d_lite_next(VALUE self)
|
|
@@ -6167,26 +6429,30 @@ d_lite_next(VALUE self)
|
|
|
6167
6429
|
|
|
6168
6430
|
/*
|
|
6169
6431
|
* call-seq:
|
|
6170
|
-
*
|
|
6432
|
+
* d >> n -> new_date
|
|
6171
6433
|
*
|
|
6172
|
-
* Returns a
|
|
6173
|
-
*
|
|
6434
|
+
* Returns a new \Date object representing the date
|
|
6435
|
+
* +n+ months later; +n+ should be a numeric:
|
|
6174
6436
|
*
|
|
6175
|
-
*
|
|
6176
|
-
*
|
|
6437
|
+
* (Date.new(2001, 2, 3) >> 1).to_s # => "2001-03-03"
|
|
6438
|
+
* (Date.new(2001, 2, 3) >> -2).to_s # => "2000-12-03"
|
|
6177
6439
|
*
|
|
6178
|
-
* When the same day does not exist for the
|
|
6179
|
-
* the last day of
|
|
6440
|
+
* When the same day does not exist for the new month,
|
|
6441
|
+
* the last day of that month is used instead:
|
|
6180
6442
|
*
|
|
6181
|
-
*
|
|
6182
|
-
*
|
|
6443
|
+
* (Date.new(2001, 1, 31) >> 1).to_s # => "2001-02-28"
|
|
6444
|
+
* (Date.new(2001, 1, 31) >> -4).to_s # => "2000-09-30"
|
|
6183
6445
|
*
|
|
6184
|
-
* This
|
|
6446
|
+
* This results in the following, possibly unexpected, behaviors:
|
|
6185
6447
|
*
|
|
6186
|
-
*
|
|
6187
|
-
*
|
|
6448
|
+
* d0 = Date.new(2001, 1, 31)
|
|
6449
|
+
* d1 = d0 >> 1 # => #<Date: 2001-02-28>
|
|
6450
|
+
* d2 = d1 >> 1 # => #<Date: 2001-03-28>
|
|
6451
|
+
*
|
|
6452
|
+
* d0 = Date.new(2001, 1, 31)
|
|
6453
|
+
* d1 = d0 >> 1 # => #<Date: 2001-02-28>
|
|
6454
|
+
* d2 = d1 >> -1 # => #<Date: 2001-01-28>
|
|
6188
6455
|
*
|
|
6189
|
-
* Date.new(2001,1,31) >> 1 >> -1 #=> #<Date: 2001-01-28 ...>
|
|
6190
6456
|
*/
|
|
6191
6457
|
static VALUE
|
|
6192
6458
|
d_lite_rshift(VALUE self, VALUE other)
|
|
@@ -6231,24 +6497,28 @@ d_lite_rshift(VALUE self, VALUE other)
|
|
|
6231
6497
|
* call-seq:
|
|
6232
6498
|
* d << n -> date
|
|
6233
6499
|
*
|
|
6234
|
-
* Returns a
|
|
6235
|
-
*
|
|
6500
|
+
* Returns a new \Date object representing the date
|
|
6501
|
+
* +n+ months earlier; +n+ should be a numeric:
|
|
6502
|
+
*
|
|
6503
|
+
* (Date.new(2001, 2, 3) << 1).to_s # => "2001-01-03"
|
|
6504
|
+
* (Date.new(2001, 2, 3) << -2).to_s # => "2001-04-03"
|
|
6236
6505
|
*
|
|
6237
|
-
*
|
|
6238
|
-
*
|
|
6506
|
+
* When the same day does not exist for the new month,
|
|
6507
|
+
* the last day of that month is used instead:
|
|
6239
6508
|
*
|
|
6240
|
-
*
|
|
6241
|
-
*
|
|
6509
|
+
* (Date.new(2001, 3, 31) << 1).to_s # => "2001-02-28"
|
|
6510
|
+
* (Date.new(2001, 3, 31) << -6).to_s # => "2001-09-30"
|
|
6242
6511
|
*
|
|
6243
|
-
*
|
|
6244
|
-
* Date.new(2001,3,31) << 1 #=> #<Date: 2001-02-28 ...>
|
|
6512
|
+
* This results in the following, possibly unexpected, behaviors:
|
|
6245
6513
|
*
|
|
6246
|
-
*
|
|
6514
|
+
* d0 = Date.new(2001, 3, 31)
|
|
6515
|
+
* d0 << 2 # => #<Date: 2001-01-31>
|
|
6516
|
+
* d0 << 1 << 1 # => #<Date: 2001-01-28>
|
|
6247
6517
|
*
|
|
6248
|
-
*
|
|
6249
|
-
*
|
|
6518
|
+
* d0 = Date.new(2001, 3, 31)
|
|
6519
|
+
* d1 = d0 << 1 # => #<Date: 2001-02-28>
|
|
6520
|
+
* d2 = d1 << -1 # => #<Date: 2001-03-28>
|
|
6250
6521
|
*
|
|
6251
|
-
* Date.new(2001,3,31) << 1 << -1 #=> #<Date: 2001-03-28 ...>
|
|
6252
6522
|
*/
|
|
6253
6523
|
static VALUE
|
|
6254
6524
|
d_lite_lshift(VALUE self, VALUE other)
|
|
@@ -6259,11 +6529,9 @@ d_lite_lshift(VALUE self, VALUE other)
|
|
|
6259
6529
|
|
|
6260
6530
|
/*
|
|
6261
6531
|
* call-seq:
|
|
6262
|
-
*
|
|
6532
|
+
* next_month(n = 1) -> new_date
|
|
6263
6533
|
*
|
|
6264
|
-
*
|
|
6265
|
-
*
|
|
6266
|
-
* See Date#>> for examples.
|
|
6534
|
+
* Equivalent to #>> with argument +n+.
|
|
6267
6535
|
*/
|
|
6268
6536
|
static VALUE
|
|
6269
6537
|
d_lite_next_month(int argc, VALUE *argv, VALUE self)
|
|
@@ -6278,11 +6546,9 @@ d_lite_next_month(int argc, VALUE *argv, VALUE self)
|
|
|
6278
6546
|
|
|
6279
6547
|
/*
|
|
6280
6548
|
* call-seq:
|
|
6281
|
-
*
|
|
6282
|
-
*
|
|
6283
|
-
* This method is equivalent to d << n.
|
|
6549
|
+
* prev_month(n = 1) -> new_date
|
|
6284
6550
|
*
|
|
6285
|
-
*
|
|
6551
|
+
* Equivalent to #<< with argument +n+.
|
|
6286
6552
|
*/
|
|
6287
6553
|
static VALUE
|
|
6288
6554
|
d_lite_prev_month(int argc, VALUE *argv, VALUE self)
|
|
@@ -6297,15 +6563,9 @@ d_lite_prev_month(int argc, VALUE *argv, VALUE self)
|
|
|
6297
6563
|
|
|
6298
6564
|
/*
|
|
6299
6565
|
* call-seq:
|
|
6300
|
-
*
|
|
6301
|
-
*
|
|
6302
|
-
* This method is equivalent to d >> (n * 12).
|
|
6566
|
+
* next_year(n = 1) -> new_date
|
|
6303
6567
|
*
|
|
6304
|
-
*
|
|
6305
|
-
* Date.new(2008,2,29).next_year #=> #<Date: 2009-02-28 ...>
|
|
6306
|
-
* Date.new(2008,2,29).next_year(4) #=> #<Date: 2012-02-29 ...>
|
|
6307
|
-
*
|
|
6308
|
-
* See also Date#>>.
|
|
6568
|
+
* Equivalent to #>> with argument <tt>n * 12</tt>.
|
|
6309
6569
|
*/
|
|
6310
6570
|
static VALUE
|
|
6311
6571
|
d_lite_next_year(int argc, VALUE *argv, VALUE self)
|
|
@@ -6320,15 +6580,9 @@ d_lite_next_year(int argc, VALUE *argv, VALUE self)
|
|
|
6320
6580
|
|
|
6321
6581
|
/*
|
|
6322
6582
|
* call-seq:
|
|
6323
|
-
*
|
|
6324
|
-
*
|
|
6325
|
-
* This method is equivalent to d << (n * 12).
|
|
6583
|
+
* prev_year(n = 1) -> new_date
|
|
6326
6584
|
*
|
|
6327
|
-
*
|
|
6328
|
-
* Date.new(2008,2,29).prev_year #=> #<Date: 2007-02-28 ...>
|
|
6329
|
-
* Date.new(2008,2,29).prev_year(4) #=> #<Date: 2004-02-29 ...>
|
|
6330
|
-
*
|
|
6331
|
-
* See also Date#<<.
|
|
6585
|
+
* Equivalent to #<< with argument <tt>n * 12</tt>.
|
|
6332
6586
|
*/
|
|
6333
6587
|
static VALUE
|
|
6334
6588
|
d_lite_prev_year(int argc, VALUE *argv, VALUE self)
|
|
@@ -6345,14 +6599,33 @@ static VALUE d_lite_cmp(VALUE, VALUE);
|
|
|
6345
6599
|
|
|
6346
6600
|
/*
|
|
6347
6601
|
* call-seq:
|
|
6348
|
-
*
|
|
6349
|
-
*
|
|
6602
|
+
* step(limit, step = 1){|date| ... } -> self
|
|
6603
|
+
*
|
|
6604
|
+
* Calls the block with specified dates;
|
|
6605
|
+
* returns +self+.
|
|
6606
|
+
*
|
|
6607
|
+
* - The first +date+ is +self+.
|
|
6608
|
+
* - Each successive +date+ is <tt>date + step</tt>,
|
|
6609
|
+
* where +step+ is the numeric step size in days.
|
|
6610
|
+
* - The last date is the last one that is before or equal to +limit+,
|
|
6611
|
+
* which should be a \Date object.
|
|
6612
|
+
*
|
|
6613
|
+
* Example:
|
|
6614
|
+
*
|
|
6615
|
+
* limit = Date.new(2001, 12, 31)
|
|
6616
|
+
* Date.new(2001).step(limit){|date| p date.to_s if date.mday == 31 }
|
|
6350
6617
|
*
|
|
6351
|
-
*
|
|
6352
|
-
* The limit should be a date object.
|
|
6618
|
+
* Output:
|
|
6353
6619
|
*
|
|
6354
|
-
*
|
|
6355
|
-
*
|
|
6620
|
+
* "2001-01-31"
|
|
6621
|
+
* "2001-03-31"
|
|
6622
|
+
* "2001-05-31"
|
|
6623
|
+
* "2001-07-31"
|
|
6624
|
+
* "2001-08-31"
|
|
6625
|
+
* "2001-10-31"
|
|
6626
|
+
* "2001-12-31"
|
|
6627
|
+
*
|
|
6628
|
+
* Returns an Enumerator if no block is given.
|
|
6356
6629
|
*/
|
|
6357
6630
|
static VALUE
|
|
6358
6631
|
d_lite_step(int argc, VALUE *argv, VALUE self)
|
|
@@ -6395,10 +6668,9 @@ d_lite_step(int argc, VALUE *argv, VALUE self)
|
|
|
6395
6668
|
|
|
6396
6669
|
/*
|
|
6397
6670
|
* call-seq:
|
|
6398
|
-
*
|
|
6399
|
-
* d.upto(max){|date| ...} -> self
|
|
6671
|
+
* upto(max){|date| ... } -> self
|
|
6400
6672
|
*
|
|
6401
|
-
*
|
|
6673
|
+
* Equivalent to #step with arguments +max+ and +1+.
|
|
6402
6674
|
*/
|
|
6403
6675
|
static VALUE
|
|
6404
6676
|
d_lite_upto(VALUE self, VALUE max)
|
|
@@ -6417,10 +6689,9 @@ d_lite_upto(VALUE self, VALUE max)
|
|
|
6417
6689
|
|
|
6418
6690
|
/*
|
|
6419
6691
|
* call-seq:
|
|
6420
|
-
*
|
|
6421
|
-
* d.downto(min){|date| ...} -> self
|
|
6692
|
+
* downto(min){|date| ... } -> self
|
|
6422
6693
|
*
|
|
6423
|
-
*
|
|
6694
|
+
* Equivalent to #step with arguments +min+ and <tt>-1</tt>.
|
|
6424
6695
|
*/
|
|
6425
6696
|
static VALUE
|
|
6426
6697
|
d_lite_downto(VALUE self, VALUE min)
|
|
@@ -6508,19 +6779,43 @@ cmp_dd(VALUE self, VALUE other)
|
|
|
6508
6779
|
|
|
6509
6780
|
/*
|
|
6510
6781
|
* call-seq:
|
|
6511
|
-
*
|
|
6782
|
+
* self <=> other -> -1, 0, 1 or nil
|
|
6783
|
+
*
|
|
6784
|
+
* Compares +self+ and +other+, returning:
|
|
6785
|
+
*
|
|
6786
|
+
* - <tt>-1</tt> if +other+ is larger.
|
|
6787
|
+
* - <tt>0</tt> if the two are equal.
|
|
6788
|
+
* - <tt>1</tt> if +other+ is smaller.
|
|
6789
|
+
* - +nil+ if the two are incomparable.
|
|
6790
|
+
*
|
|
6791
|
+
* Argument +other+ may be:
|
|
6792
|
+
*
|
|
6793
|
+
* - Another \Date object:
|
|
6794
|
+
*
|
|
6795
|
+
* d = Date.new(2022, 7, 27) # => #<Date: 2022-07-27 ((2459788j,0s,0n),+0s,2299161j)>
|
|
6796
|
+
* prev_date = d.prev_day # => #<Date: 2022-07-26 ((2459787j,0s,0n),+0s,2299161j)>
|
|
6797
|
+
* next_date = d.next_day # => #<Date: 2022-07-28 ((2459789j,0s,0n),+0s,2299161j)>
|
|
6798
|
+
* d <=> next_date # => -1
|
|
6799
|
+
* d <=> d # => 0
|
|
6800
|
+
* d <=> prev_date # => 1
|
|
6801
|
+
*
|
|
6802
|
+
* - A DateTime object:
|
|
6803
|
+
*
|
|
6804
|
+
* d <=> DateTime.new(2022, 7, 26) # => 1
|
|
6805
|
+
* d <=> DateTime.new(2022, 7, 27) # => 0
|
|
6806
|
+
* d <=> DateTime.new(2022, 7, 28) # => -1
|
|
6807
|
+
*
|
|
6808
|
+
* - A numeric (compares <tt>self.ajd</tt> to +other+):
|
|
6512
6809
|
*
|
|
6513
|
-
*
|
|
6514
|
-
*
|
|
6515
|
-
*
|
|
6810
|
+
* d <=> 2459788 # => -1
|
|
6811
|
+
* d <=> 2459787 # => 1
|
|
6812
|
+
* d <=> 2459786 # => 1
|
|
6813
|
+
* d <=> d.ajd # => 0
|
|
6516
6814
|
*
|
|
6517
|
-
*
|
|
6518
|
-
*
|
|
6519
|
-
*
|
|
6520
|
-
* Date.new(2001,2,3) <=> Object.new #=> nil
|
|
6521
|
-
* Date.new(2001,2,3) <=> Rational(4903887,2) #=> 0
|
|
6815
|
+
* - Any other object:
|
|
6816
|
+
*
|
|
6817
|
+
* d <=> Object.new # => nil
|
|
6522
6818
|
*
|
|
6523
|
-
* See also Comparable.
|
|
6524
6819
|
*/
|
|
6525
6820
|
static VALUE
|
|
6526
6821
|
d_lite_cmp(VALUE self, VALUE other)
|
|
@@ -6580,20 +6875,39 @@ equal_gen(VALUE self, VALUE other)
|
|
|
6580
6875
|
|
|
6581
6876
|
/*
|
|
6582
6877
|
* call-seq:
|
|
6583
|
-
*
|
|
6584
|
-
*
|
|
6585
|
-
* Returns true if
|
|
6586
|
-
*
|
|
6587
|
-
*
|
|
6588
|
-
*
|
|
6589
|
-
*
|
|
6590
|
-
*
|
|
6591
|
-
*
|
|
6592
|
-
*
|
|
6593
|
-
*
|
|
6594
|
-
*
|
|
6595
|
-
*
|
|
6596
|
-
*
|
|
6878
|
+
* self === other -> true, false, or nil.
|
|
6879
|
+
*
|
|
6880
|
+
* Returns +true+ if +self+ and +other+ represent the same date,
|
|
6881
|
+
* +false+ if not, +nil+ if the two are not comparable.
|
|
6882
|
+
*
|
|
6883
|
+
* Argument +other+ may be:
|
|
6884
|
+
*
|
|
6885
|
+
* - Another \Date object:
|
|
6886
|
+
*
|
|
6887
|
+
* d = Date.new(2022, 7, 27) # => #<Date: 2022-07-27 ((2459788j,0s,0n),+0s,2299161j)>
|
|
6888
|
+
* prev_date = d.prev_day # => #<Date: 2022-07-26 ((2459787j,0s,0n),+0s,2299161j)>
|
|
6889
|
+
* next_date = d.next_day # => #<Date: 2022-07-28 ((2459789j,0s,0n),+0s,2299161j)>
|
|
6890
|
+
* d === prev_date # => false
|
|
6891
|
+
* d === d # => true
|
|
6892
|
+
* d === next_date # => false
|
|
6893
|
+
*
|
|
6894
|
+
* - A DateTime object:
|
|
6895
|
+
*
|
|
6896
|
+
* d === DateTime.new(2022, 7, 26) # => false
|
|
6897
|
+
* d === DateTime.new(2022, 7, 27) # => true
|
|
6898
|
+
* d === DateTime.new(2022, 7, 28) # => false
|
|
6899
|
+
*
|
|
6900
|
+
* - A numeric (compares <tt>self.jd</tt> to +other+):
|
|
6901
|
+
*
|
|
6902
|
+
* d === 2459788 # => true
|
|
6903
|
+
* d === 2459787 # => false
|
|
6904
|
+
* d === 2459786 # => false
|
|
6905
|
+
* d === d.jd # => true
|
|
6906
|
+
*
|
|
6907
|
+
* - An object not comparable:
|
|
6908
|
+
*
|
|
6909
|
+
* d === Object.new # => nil
|
|
6910
|
+
*
|
|
6597
6911
|
*/
|
|
6598
6912
|
static VALUE
|
|
6599
6913
|
d_lite_equal(VALUE self, VALUE other)
|
|
@@ -6656,12 +6970,14 @@ static VALUE strftimev(const char *, VALUE,
|
|
|
6656
6970
|
|
|
6657
6971
|
/*
|
|
6658
6972
|
* call-seq:
|
|
6659
|
-
*
|
|
6973
|
+
* to_s -> string
|
|
6660
6974
|
*
|
|
6661
|
-
* Returns a string
|
|
6662
|
-
*
|
|
6975
|
+
* Returns a string representation of the date in +self+
|
|
6976
|
+
* in {ISO 8601 extended date format}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-ISO+8601+Format+Specifications]
|
|
6977
|
+
* (<tt>'%Y-%m-%d'</tt>):
|
|
6978
|
+
*
|
|
6979
|
+
* Date.new(2001, 2, 3).to_s # => "2001-02-03"
|
|
6663
6980
|
*
|
|
6664
|
-
* Date.new(2001,2,3).to_s #=> "2001-02-03"
|
|
6665
6981
|
*/
|
|
6666
6982
|
static VALUE
|
|
6667
6983
|
d_lite_to_s(VALUE self)
|
|
@@ -6670,6 +6986,7 @@ d_lite_to_s(VALUE self)
|
|
|
6670
6986
|
}
|
|
6671
6987
|
|
|
6672
6988
|
#ifndef NDEBUG
|
|
6989
|
+
/* :nodoc: */
|
|
6673
6990
|
static VALUE
|
|
6674
6991
|
mk_inspect_raw(union DateData *x, VALUE klass)
|
|
6675
6992
|
{
|
|
@@ -6719,6 +7036,7 @@ mk_inspect_raw(union DateData *x, VALUE klass)
|
|
|
6719
7036
|
}
|
|
6720
7037
|
}
|
|
6721
7038
|
|
|
7039
|
+
/* :nodoc: */
|
|
6722
7040
|
static VALUE
|
|
6723
7041
|
d_lite_inspect_raw(VALUE self)
|
|
6724
7042
|
{
|
|
@@ -6740,14 +7058,13 @@ mk_inspect(union DateData *x, VALUE klass, VALUE to_s)
|
|
|
6740
7058
|
|
|
6741
7059
|
/*
|
|
6742
7060
|
* call-seq:
|
|
6743
|
-
*
|
|
7061
|
+
* inspect -> string
|
|
7062
|
+
*
|
|
7063
|
+
* Returns a string representation of +self+:
|
|
6744
7064
|
*
|
|
6745
|
-
*
|
|
7065
|
+
* Date.new(2001, 2, 3).inspect
|
|
7066
|
+
* # => "#<Date: 2001-02-03 ((2451944j,0s,0n),+0s,2299161j)>"
|
|
6746
7067
|
*
|
|
6747
|
-
* Date.new(2001,2,3).inspect
|
|
6748
|
-
* #=> "#<Date: 2001-02-03>"
|
|
6749
|
-
* DateTime.new(2001,2,3,4,5,6,'-7').inspect
|
|
6750
|
-
* #=> "#<DateTime: 2001-02-03T04:05:06-07:00>"
|
|
6751
7068
|
*/
|
|
6752
7069
|
static VALUE
|
|
6753
7070
|
d_lite_inspect(VALUE self)
|
|
@@ -6929,180 +7246,16 @@ date_strftime_internal(int argc, VALUE *argv, VALUE self,
|
|
|
6929
7246
|
|
|
6930
7247
|
/*
|
|
6931
7248
|
* call-seq:
|
|
6932
|
-
*
|
|
6933
|
-
*
|
|
6934
|
-
*
|
|
6935
|
-
*
|
|
6936
|
-
*
|
|
6937
|
-
*
|
|
6938
|
-
*
|
|
6939
|
-
*
|
|
6940
|
-
*
|
|
6941
|
-
*
|
|
6942
|
-
* an optional modifier, and a conversion specifier
|
|
6943
|
-
* as follows.
|
|
6944
|
-
*
|
|
6945
|
-
* %<flags><width><modifier><conversion>
|
|
6946
|
-
*
|
|
6947
|
-
* Flags:
|
|
6948
|
-
* - don't pad a numerical output.
|
|
6949
|
-
* _ use spaces for padding.
|
|
6950
|
-
* 0 use zeros for padding.
|
|
6951
|
-
* ^ upcase the result string.
|
|
6952
|
-
* # change case.
|
|
6953
|
-
*
|
|
6954
|
-
* The minimum field width specifies the minimum width.
|
|
6955
|
-
*
|
|
6956
|
-
* The modifiers are "E", "O", ":", "::" and ":::".
|
|
6957
|
-
* "E" and "O" are ignored. No effect to result currently.
|
|
6958
|
-
*
|
|
6959
|
-
* Format directives:
|
|
6960
|
-
*
|
|
6961
|
-
* Date (Year, Month, Day):
|
|
6962
|
-
* %Y - Year with century (can be negative, 4 digits at least)
|
|
6963
|
-
* -0001, 0000, 1995, 2009, 14292, etc.
|
|
6964
|
-
* %C - year / 100 (round down. 20 in 2009)
|
|
6965
|
-
* %y - year % 100 (00..99)
|
|
6966
|
-
*
|
|
6967
|
-
* %m - Month of the year, zero-padded (01..12)
|
|
6968
|
-
* %_m blank-padded ( 1..12)
|
|
6969
|
-
* %-m no-padded (1..12)
|
|
6970
|
-
* %B - The full month name (``January'')
|
|
6971
|
-
* %^B uppercased (``JANUARY'')
|
|
6972
|
-
* %b - The abbreviated month name (``Jan'')
|
|
6973
|
-
* %^b uppercased (``JAN'')
|
|
6974
|
-
* %h - Equivalent to %b
|
|
6975
|
-
*
|
|
6976
|
-
* %d - Day of the month, zero-padded (01..31)
|
|
6977
|
-
* %-d no-padded (1..31)
|
|
6978
|
-
* %e - Day of the month, blank-padded ( 1..31)
|
|
6979
|
-
*
|
|
6980
|
-
* %j - Day of the year (001..366)
|
|
6981
|
-
*
|
|
6982
|
-
* Time (Hour, Minute, Second, Subsecond):
|
|
6983
|
-
* %H - Hour of the day, 24-hour clock, zero-padded (00..23)
|
|
6984
|
-
* %k - Hour of the day, 24-hour clock, blank-padded ( 0..23)
|
|
6985
|
-
* %I - Hour of the day, 12-hour clock, zero-padded (01..12)
|
|
6986
|
-
* %l - Hour of the day, 12-hour clock, blank-padded ( 1..12)
|
|
6987
|
-
* %P - Meridian indicator, lowercase (``am'' or ``pm'')
|
|
6988
|
-
* %p - Meridian indicator, uppercase (``AM'' or ``PM'')
|
|
6989
|
-
*
|
|
6990
|
-
* %M - Minute of the hour (00..59)
|
|
6991
|
-
*
|
|
6992
|
-
* %S - Second of the minute (00..60)
|
|
6993
|
-
*
|
|
6994
|
-
* %L - Millisecond of the second (000..999)
|
|
6995
|
-
* %N - Fractional seconds digits, default is 9 digits (nanosecond)
|
|
6996
|
-
* %3N millisecond (3 digits) %15N femtosecond (15 digits)
|
|
6997
|
-
* %6N microsecond (6 digits) %18N attosecond (18 digits)
|
|
6998
|
-
* %9N nanosecond (9 digits) %21N zeptosecond (21 digits)
|
|
6999
|
-
* %12N picosecond (12 digits) %24N yoctosecond (24 digits)
|
|
7000
|
-
*
|
|
7001
|
-
* Time zone:
|
|
7002
|
-
* %z - Time zone as hour and minute offset from UTC (e.g. +0900)
|
|
7003
|
-
* %:z - hour and minute offset from UTC with a colon (e.g. +09:00)
|
|
7004
|
-
* %::z - hour, minute and second offset from UTC (e.g. +09:00:00)
|
|
7005
|
-
* %:::z - hour, minute and second offset from UTC
|
|
7006
|
-
* (e.g. +09, +09:30, +09:30:30)
|
|
7007
|
-
* %Z - Equivalent to %:z (e.g. +09:00)
|
|
7008
|
-
*
|
|
7009
|
-
* Weekday:
|
|
7010
|
-
* %A - The full weekday name (``Sunday'')
|
|
7011
|
-
* %^A uppercased (``SUNDAY'')
|
|
7012
|
-
* %a - The abbreviated name (``Sun'')
|
|
7013
|
-
* %^a uppercased (``SUN'')
|
|
7014
|
-
* %u - Day of the week (Monday is 1, 1..7)
|
|
7015
|
-
* %w - Day of the week (Sunday is 0, 0..6)
|
|
7016
|
-
*
|
|
7017
|
-
* ISO 8601 week-based year and week number:
|
|
7018
|
-
* The week 1 of YYYY starts with a Monday and includes YYYY-01-04.
|
|
7019
|
-
* The days in the year before the first week are in the last week of
|
|
7020
|
-
* the previous year.
|
|
7021
|
-
* %G - The week-based year
|
|
7022
|
-
* %g - The last 2 digits of the week-based year (00..99)
|
|
7023
|
-
* %V - Week number of the week-based year (01..53)
|
|
7024
|
-
*
|
|
7025
|
-
* Week number:
|
|
7026
|
-
* The week 1 of YYYY starts with a Sunday or Monday (according to %U
|
|
7027
|
-
* or %W). The days in the year before the first week are in week 0.
|
|
7028
|
-
* %U - Week number of the year. The week starts with Sunday. (00..53)
|
|
7029
|
-
* %W - Week number of the year. The week starts with Monday. (00..53)
|
|
7030
|
-
*
|
|
7031
|
-
* Seconds since the Unix Epoch:
|
|
7032
|
-
* %s - Number of seconds since 1970-01-01 00:00:00 UTC.
|
|
7033
|
-
* %Q - Number of milliseconds since 1970-01-01 00:00:00 UTC.
|
|
7034
|
-
*
|
|
7035
|
-
* Literal string:
|
|
7036
|
-
* %n - Newline character (\n)
|
|
7037
|
-
* %t - Tab character (\t)
|
|
7038
|
-
* %% - Literal ``%'' character
|
|
7039
|
-
*
|
|
7040
|
-
* Combination:
|
|
7041
|
-
* %c - date and time (%a %b %e %T %Y)
|
|
7042
|
-
* %D - Date (%m/%d/%y)
|
|
7043
|
-
* %F - The ISO 8601 date format (%Y-%m-%d)
|
|
7044
|
-
* %v - VMS date (%e-%^b-%Y)
|
|
7045
|
-
* %x - Same as %D
|
|
7046
|
-
* %X - Same as %T
|
|
7047
|
-
* %r - 12-hour time (%I:%M:%S %p)
|
|
7048
|
-
* %R - 24-hour time (%H:%M)
|
|
7049
|
-
* %T - 24-hour time (%H:%M:%S)
|
|
7050
|
-
* %+ - date(1) (%a %b %e %H:%M:%S %Z %Y)
|
|
7051
|
-
*
|
|
7052
|
-
* This method is similar to the strftime() function defined in ISO C
|
|
7053
|
-
* and POSIX.
|
|
7054
|
-
* Several directives (%a, %A, %b, %B, %c, %p, %r, %x, %X, %E*, %O* and %Z)
|
|
7055
|
-
* are locale dependent in the function.
|
|
7056
|
-
* However, this method is locale independent.
|
|
7057
|
-
* So, the result may differ even if the same format string is used in other
|
|
7058
|
-
* systems such as C.
|
|
7059
|
-
* It is good practice to avoid %x and %X because there are corresponding
|
|
7060
|
-
* locale independent representations, %D and %T.
|
|
7061
|
-
*
|
|
7062
|
-
* Examples:
|
|
7063
|
-
*
|
|
7064
|
-
* d = DateTime.new(2007,11,19,8,37,48,"-06:00")
|
|
7065
|
-
* #=> #<DateTime: 2007-11-19T08:37:48-0600 ...>
|
|
7066
|
-
* d.strftime("Printed on %m/%d/%Y") #=> "Printed on 11/19/2007"
|
|
7067
|
-
* d.strftime("at %I:%M%p") #=> "at 08:37AM"
|
|
7068
|
-
*
|
|
7069
|
-
* Various ISO 8601 formats:
|
|
7070
|
-
* %Y%m%d => 20071119 Calendar date (basic)
|
|
7071
|
-
* %F => 2007-11-19 Calendar date (extended)
|
|
7072
|
-
* %Y-%m => 2007-11 Calendar date, reduced accuracy, specific month
|
|
7073
|
-
* %Y => 2007 Calendar date, reduced accuracy, specific year
|
|
7074
|
-
* %C => 20 Calendar date, reduced accuracy, specific century
|
|
7075
|
-
* %Y%j => 2007323 Ordinal date (basic)
|
|
7076
|
-
* %Y-%j => 2007-323 Ordinal date (extended)
|
|
7077
|
-
* %GW%V%u => 2007W471 Week date (basic)
|
|
7078
|
-
* %G-W%V-%u => 2007-W47-1 Week date (extended)
|
|
7079
|
-
* %GW%V => 2007W47 Week date, reduced accuracy, specific week (basic)
|
|
7080
|
-
* %G-W%V => 2007-W47 Week date, reduced accuracy, specific week (extended)
|
|
7081
|
-
* %H%M%S => 083748 Local time (basic)
|
|
7082
|
-
* %T => 08:37:48 Local time (extended)
|
|
7083
|
-
* %H%M => 0837 Local time, reduced accuracy, specific minute (basic)
|
|
7084
|
-
* %H:%M => 08:37 Local time, reduced accuracy, specific minute (extended)
|
|
7085
|
-
* %H => 08 Local time, reduced accuracy, specific hour
|
|
7086
|
-
* %H%M%S,%L => 083748,000 Local time with decimal fraction, comma as decimal sign (basic)
|
|
7087
|
-
* %T,%L => 08:37:48,000 Local time with decimal fraction, comma as decimal sign (extended)
|
|
7088
|
-
* %H%M%S.%L => 083748.000 Local time with decimal fraction, full stop as decimal sign (basic)
|
|
7089
|
-
* %T.%L => 08:37:48.000 Local time with decimal fraction, full stop as decimal sign (extended)
|
|
7090
|
-
* %H%M%S%z => 083748-0600 Local time and the difference from UTC (basic)
|
|
7091
|
-
* %T%:z => 08:37:48-06:00 Local time and the difference from UTC (extended)
|
|
7092
|
-
* %Y%m%dT%H%M%S%z => 20071119T083748-0600 Date and time of day for calendar date (basic)
|
|
7093
|
-
* %FT%T%:z => 2007-11-19T08:37:48-06:00 Date and time of day for calendar date (extended)
|
|
7094
|
-
* %Y%jT%H%M%S%z => 2007323T083748-0600 Date and time of day for ordinal date (basic)
|
|
7095
|
-
* %Y-%jT%T%:z => 2007-323T08:37:48-06:00 Date and time of day for ordinal date (extended)
|
|
7096
|
-
* %GW%V%uT%H%M%S%z => 2007W471T083748-0600 Date and time of day for week date (basic)
|
|
7097
|
-
* %G-W%V-%uT%T%:z => 2007-W47-1T08:37:48-06:00 Date and time of day for week date (extended)
|
|
7098
|
-
* %Y%m%dT%H%M => 20071119T0837 Calendar date and local time (basic)
|
|
7099
|
-
* %FT%R => 2007-11-19T08:37 Calendar date and local time (extended)
|
|
7100
|
-
* %Y%jT%H%MZ => 2007323T0837Z Ordinal date and UTC of day (basic)
|
|
7101
|
-
* %Y-%jT%RZ => 2007-323T08:37Z Ordinal date and UTC of day (extended)
|
|
7102
|
-
* %GW%V%uT%H%M%z => 2007W471T0837-0600 Week date and local time and difference from UTC (basic)
|
|
7103
|
-
* %G-W%V-%uT%R%:z => 2007-W47-1T08:37-06:00 Week date and local time and difference from UTC (extended)
|
|
7104
|
-
*
|
|
7105
|
-
* See also strftime(3) and ::strptime.
|
|
7249
|
+
* strftime(format = '%F') -> string
|
|
7250
|
+
*
|
|
7251
|
+
* Returns a string representation of the date in +self+,
|
|
7252
|
+
* formatted according the given +format+:
|
|
7253
|
+
*
|
|
7254
|
+
* Date.new(2001, 2, 3).strftime # => "2001-02-03"
|
|
7255
|
+
*
|
|
7256
|
+
* For other formats, see
|
|
7257
|
+
* {Formats for Dates and Times}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html].
|
|
7258
|
+
*
|
|
7106
7259
|
*/
|
|
7107
7260
|
static VALUE
|
|
7108
7261
|
d_lite_strftime(int argc, VALUE *argv, VALUE self)
|
|
@@ -7130,13 +7283,17 @@ strftimev(const char *fmt, VALUE self,
|
|
|
7130
7283
|
|
|
7131
7284
|
/*
|
|
7132
7285
|
* call-seq:
|
|
7133
|
-
*
|
|
7134
|
-
*
|
|
7286
|
+
* asctime -> string
|
|
7287
|
+
*
|
|
7288
|
+
* Equivalent to #strftime with argument <tt>'%a %b %e %T %Y'</tt>
|
|
7289
|
+
* (or its {shorthand form}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-Shorthand+Conversion+Specifiers]
|
|
7290
|
+
* <tt>'%c'</tt>):
|
|
7135
7291
|
*
|
|
7136
|
-
*
|
|
7137
|
-
* end). This method is equivalent to strftime('%c').
|
|
7292
|
+
* Date.new(2001, 2, 3).asctime # => "Sat Feb 3 00:00:00 2001"
|
|
7138
7293
|
*
|
|
7139
|
-
* See
|
|
7294
|
+
* See {asctime}[https://linux.die.net/man/3/asctime].
|
|
7295
|
+
*
|
|
7296
|
+
* Date#ctime is an alias for Date#asctime.
|
|
7140
7297
|
*/
|
|
7141
7298
|
static VALUE
|
|
7142
7299
|
d_lite_asctime(VALUE self)
|
|
@@ -7146,10 +7303,15 @@ d_lite_asctime(VALUE self)
|
|
|
7146
7303
|
|
|
7147
7304
|
/*
|
|
7148
7305
|
* call-seq:
|
|
7149
|
-
*
|
|
7150
|
-
*
|
|
7306
|
+
* iso8601 -> string
|
|
7307
|
+
*
|
|
7308
|
+
* Equivalent to #strftime with argument <tt>'%Y-%m-%d'</tt>
|
|
7309
|
+
* (or its {shorthand form}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-Shorthand+Conversion+Specifiers]
|
|
7310
|
+
* <tt>'%F'</tt>);
|
|
7311
|
+
*
|
|
7312
|
+
* Date.new(2001, 2, 3).iso8601 # => "2001-02-03"
|
|
7151
7313
|
*
|
|
7152
|
-
*
|
|
7314
|
+
* Date#xmlschema is an alias for Date#iso8601.
|
|
7153
7315
|
*/
|
|
7154
7316
|
static VALUE
|
|
7155
7317
|
d_lite_iso8601(VALUE self)
|
|
@@ -7159,9 +7321,13 @@ d_lite_iso8601(VALUE self)
|
|
|
7159
7321
|
|
|
7160
7322
|
/*
|
|
7161
7323
|
* call-seq:
|
|
7162
|
-
*
|
|
7324
|
+
* rfc3339 -> string
|
|
7325
|
+
*
|
|
7326
|
+
* Equivalent to #strftime with argument <tt>'%FT%T%:z'</tt>;
|
|
7327
|
+
* see {Formats for Dates and Times}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html]:
|
|
7328
|
+
*
|
|
7329
|
+
* Date.new(2001, 2, 3).rfc3339 # => "2001-02-03T00:00:00+00:00"
|
|
7163
7330
|
*
|
|
7164
|
-
* This method is equivalent to strftime('%FT%T%:z').
|
|
7165
7331
|
*/
|
|
7166
7332
|
static VALUE
|
|
7167
7333
|
d_lite_rfc3339(VALUE self)
|
|
@@ -7171,10 +7337,14 @@ d_lite_rfc3339(VALUE self)
|
|
|
7171
7337
|
|
|
7172
7338
|
/*
|
|
7173
7339
|
* call-seq:
|
|
7174
|
-
*
|
|
7175
|
-
*
|
|
7340
|
+
* rfc2822 -> string
|
|
7341
|
+
*
|
|
7342
|
+
* Equivalent to #strftime with argument <tt>'%a, %-d %b %Y %T %z'</tt>;
|
|
7343
|
+
* see {Formats for Dates and Times}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html]:
|
|
7344
|
+
*
|
|
7345
|
+
* Date.new(2001, 2, 3).rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
|
|
7176
7346
|
*
|
|
7177
|
-
*
|
|
7347
|
+
* Date#rfc822 is an alias for Date#rfc2822.
|
|
7178
7348
|
*/
|
|
7179
7349
|
static VALUE
|
|
7180
7350
|
d_lite_rfc2822(VALUE self)
|
|
@@ -7184,10 +7354,13 @@ d_lite_rfc2822(VALUE self)
|
|
|
7184
7354
|
|
|
7185
7355
|
/*
|
|
7186
7356
|
* call-seq:
|
|
7187
|
-
*
|
|
7357
|
+
* httpdate -> string
|
|
7358
|
+
*
|
|
7359
|
+
* Equivalent to #strftime with argument <tt>'%a, %d %b %Y %T GMT'</tt>;
|
|
7360
|
+
* see {Formats for Dates and Times}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html]:
|
|
7361
|
+
*
|
|
7362
|
+
* Date.new(2001, 2, 3).httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT"
|
|
7188
7363
|
*
|
|
7189
|
-
* This method is equivalent to strftime('%a, %d %b %Y %T GMT').
|
|
7190
|
-
* See also RFC 2616.
|
|
7191
7364
|
*/
|
|
7192
7365
|
static VALUE
|
|
7193
7366
|
d_lite_httpdate(VALUE self)
|
|
@@ -7238,11 +7411,13 @@ jisx0301_date_format(char *fmt, size_t size, VALUE jd, VALUE y)
|
|
|
7238
7411
|
|
|
7239
7412
|
/*
|
|
7240
7413
|
* call-seq:
|
|
7241
|
-
*
|
|
7414
|
+
* jisx0301 -> string
|
|
7242
7415
|
*
|
|
7243
|
-
* Returns a string
|
|
7416
|
+
* Returns a string representation of the date in +self+
|
|
7417
|
+
* in JIS X 0301 format.
|
|
7418
|
+
*
|
|
7419
|
+
* Date.new(2001, 2, 3).jisx0301 # => "H13.02.03"
|
|
7244
7420
|
*
|
|
7245
|
-
* Date.new(2001,2,3).jisx0301 #=> "H13.02.03"
|
|
7246
7421
|
*/
|
|
7247
7422
|
static VALUE
|
|
7248
7423
|
d_lite_jisx0301(VALUE self)
|
|
@@ -7258,6 +7433,7 @@ d_lite_jisx0301(VALUE self)
|
|
|
7258
7433
|
}
|
|
7259
7434
|
|
|
7260
7435
|
#ifndef NDEBUG
|
|
7436
|
+
/* :nodoc: */
|
|
7261
7437
|
static VALUE
|
|
7262
7438
|
d_lite_marshal_dump_old(VALUE self)
|
|
7263
7439
|
{
|
|
@@ -7545,17 +7721,7 @@ datetime_s_ordinal(int argc, VALUE *argv, VALUE klass)
|
|
|
7545
7721
|
}
|
|
7546
7722
|
|
|
7547
7723
|
/*
|
|
7548
|
-
*
|
|
7549
|
-
* DateTime.civil([year=-4712[, month=1[, mday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]]) -> datetime
|
|
7550
|
-
* DateTime.new([year=-4712[, month=1[, mday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]]) -> datetime
|
|
7551
|
-
*
|
|
7552
|
-
* Creates a DateTime object denoting the given calendar date.
|
|
7553
|
-
*
|
|
7554
|
-
* DateTime.new(2001,2,3) #=> #<DateTime: 2001-02-03T00:00:00+00:00 ...>
|
|
7555
|
-
* DateTime.new(2001,2,3,4,5,6,'+7')
|
|
7556
|
-
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
|
7557
|
-
* DateTime.new(2001,-11,-26,-20,-55,-54,'+7')
|
|
7558
|
-
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
|
7724
|
+
* Same as DateTime.new.
|
|
7559
7725
|
*/
|
|
7560
7726
|
static VALUE
|
|
7561
7727
|
datetime_s_civil(int argc, VALUE *argv, VALUE klass)
|
|
@@ -7745,6 +7911,7 @@ datetime_s_commercial(int argc, VALUE *argv, VALUE klass)
|
|
|
7745
7911
|
}
|
|
7746
7912
|
|
|
7747
7913
|
#ifndef NDEBUG
|
|
7914
|
+
/* :nodoc: */
|
|
7748
7915
|
static VALUE
|
|
7749
7916
|
datetime_s_weeknum(int argc, VALUE *argv, VALUE klass)
|
|
7750
7917
|
{
|
|
@@ -7814,6 +7981,7 @@ datetime_s_weeknum(int argc, VALUE *argv, VALUE klass)
|
|
|
7814
7981
|
return ret;
|
|
7815
7982
|
}
|
|
7816
7983
|
|
|
7984
|
+
/* :nodoc: */
|
|
7817
7985
|
static VALUE
|
|
7818
7986
|
datetime_s_nth_kday(int argc, VALUE *argv, VALUE klass)
|
|
7819
7987
|
{
|
|
@@ -8159,9 +8327,9 @@ datetime_s_strptime(int argc, VALUE *argv, VALUE klass)
|
|
|
8159
8327
|
* Parses the given representation of date and time, and creates a
|
|
8160
8328
|
* DateTime object.
|
|
8161
8329
|
*
|
|
8162
|
-
* This method *does not* function as a validator. If the input
|
|
8330
|
+
* This method *does* *not* function as a validator. If the input
|
|
8163
8331
|
* string does not match valid formats strictly, you may get a cryptic
|
|
8164
|
-
* result. Should consider to use
|
|
8332
|
+
* result. Should consider to use DateTime.strptime instead of this
|
|
8165
8333
|
* method as possible.
|
|
8166
8334
|
*
|
|
8167
8335
|
* If the optional second argument is true and the detected year is in
|
|
@@ -8175,8 +8343,8 @@ datetime_s_strptime(int argc, VALUE *argv, VALUE klass)
|
|
|
8175
8343
|
* #=> #<DateTime: 2001-02-03T16:05:06+00:00 ...>
|
|
8176
8344
|
*
|
|
8177
8345
|
* Raise an ArgumentError when the string length is longer than _limit_.
|
|
8178
|
-
* You can stop this check by passing
|
|
8179
|
-
* it may take a long time to parse.
|
|
8346
|
+
* You can stop this check by passing <code>limit: nil</code>, but note
|
|
8347
|
+
* that it may take a long time to parse.
|
|
8180
8348
|
*/
|
|
8181
8349
|
static VALUE
|
|
8182
8350
|
datetime_s_parse(int argc, VALUE *argv, VALUE klass)
|
|
@@ -8197,12 +8365,12 @@ datetime_s_parse(int argc, VALUE *argv, VALUE klass)
|
|
|
8197
8365
|
|
|
8198
8366
|
{
|
|
8199
8367
|
int argc2 = 2;
|
|
8200
|
-
VALUE argv2[3];
|
|
8368
|
+
VALUE argv2[3], hash;
|
|
8201
8369
|
argv2[0] = str;
|
|
8202
8370
|
argv2[1] = comp;
|
|
8203
8371
|
argv2[2] = opt;
|
|
8204
8372
|
if (!NIL_P(opt)) argc2++;
|
|
8205
|
-
|
|
8373
|
+
hash = date_s__parse(argc2, argv2, klass);
|
|
8206
8374
|
return dt_new_by_frags(klass, hash, sg);
|
|
8207
8375
|
}
|
|
8208
8376
|
}
|
|
@@ -8222,8 +8390,8 @@ datetime_s_parse(int argc, VALUE *argv, VALUE klass)
|
|
|
8222
8390
|
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
|
8223
8391
|
*
|
|
8224
8392
|
* Raise an ArgumentError when the string length is longer than _limit_.
|
|
8225
|
-
* You can stop this check by passing
|
|
8226
|
-
* it may take a long time to parse.
|
|
8393
|
+
* You can stop this check by passing <code>limit: nil</code>, but note
|
|
8394
|
+
* that it may take a long time to parse.
|
|
8227
8395
|
*/
|
|
8228
8396
|
static VALUE
|
|
8229
8397
|
datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
|
|
@@ -8242,11 +8410,11 @@ datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
|
|
|
8242
8410
|
|
|
8243
8411
|
{
|
|
8244
8412
|
int argc2 = 1;
|
|
8245
|
-
VALUE argv2[2];
|
|
8413
|
+
VALUE argv2[2], hash;
|
|
8246
8414
|
argv2[0] = str;
|
|
8247
8415
|
argv2[1] = opt;
|
|
8248
8416
|
if (!NIL_P(opt)) argc2--;
|
|
8249
|
-
|
|
8417
|
+
hash = date_s__iso8601(argc2, argv2, klass);
|
|
8250
8418
|
return dt_new_by_frags(klass, hash, sg);
|
|
8251
8419
|
}
|
|
8252
8420
|
}
|
|
@@ -8262,8 +8430,8 @@ datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
|
|
|
8262
8430
|
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
|
8263
8431
|
*
|
|
8264
8432
|
* Raise an ArgumentError when the string length is longer than _limit_.
|
|
8265
|
-
* You can stop this check by passing
|
|
8266
|
-
* it may take a long time to parse.
|
|
8433
|
+
* You can stop this check by passing <code>limit: nil</code>, but note
|
|
8434
|
+
* that it may take a long time to parse.
|
|
8267
8435
|
*/
|
|
8268
8436
|
static VALUE
|
|
8269
8437
|
datetime_s_rfc3339(int argc, VALUE *argv, VALUE klass)
|
|
@@ -8282,11 +8450,11 @@ datetime_s_rfc3339(int argc, VALUE *argv, VALUE klass)
|
|
|
8282
8450
|
|
|
8283
8451
|
{
|
|
8284
8452
|
int argc2 = 1;
|
|
8285
|
-
VALUE argv2[2];
|
|
8453
|
+
VALUE argv2[2], hash;
|
|
8286
8454
|
argv2[0] = str;
|
|
8287
8455
|
argv2[1] = opt;
|
|
8288
8456
|
if (!NIL_P(opt)) argc2++;
|
|
8289
|
-
|
|
8457
|
+
hash = date_s__rfc3339(argc2, argv2, klass);
|
|
8290
8458
|
return dt_new_by_frags(klass, hash, sg);
|
|
8291
8459
|
}
|
|
8292
8460
|
}
|
|
@@ -8302,8 +8470,8 @@ datetime_s_rfc3339(int argc, VALUE *argv, VALUE klass)
|
|
|
8302
8470
|
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
|
8303
8471
|
*
|
|
8304
8472
|
* Raise an ArgumentError when the string length is longer than _limit_.
|
|
8305
|
-
* You can stop this check by passing
|
|
8306
|
-
* it may take a long time to parse.
|
|
8473
|
+
* You can stop this check by passing <code>limit: nil</code>, but note
|
|
8474
|
+
* that it may take a long time to parse.
|
|
8307
8475
|
*/
|
|
8308
8476
|
static VALUE
|
|
8309
8477
|
datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass)
|
|
@@ -8322,11 +8490,11 @@ datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass)
|
|
|
8322
8490
|
|
|
8323
8491
|
{
|
|
8324
8492
|
int argc2 = 1;
|
|
8325
|
-
VALUE argv2[2];
|
|
8493
|
+
VALUE argv2[2], hash;
|
|
8326
8494
|
argv2[0] = str;
|
|
8327
8495
|
argv2[1] = opt;
|
|
8328
8496
|
if (!NIL_P(opt)) argc2++;
|
|
8329
|
-
|
|
8497
|
+
hash = date_s__xmlschema(argc2, argv2, klass);
|
|
8330
8498
|
return dt_new_by_frags(klass, hash, sg);
|
|
8331
8499
|
}
|
|
8332
8500
|
}
|
|
@@ -8343,8 +8511,8 @@ datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass)
|
|
|
8343
8511
|
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
|
8344
8512
|
*
|
|
8345
8513
|
* Raise an ArgumentError when the string length is longer than _limit_.
|
|
8346
|
-
* You can stop this check by passing
|
|
8347
|
-
* it may take a long time to parse.
|
|
8514
|
+
* You can stop this check by passing <code>limit: nil</code>, but note
|
|
8515
|
+
* that it may take a long time to parse.
|
|
8348
8516
|
*/
|
|
8349
8517
|
static VALUE
|
|
8350
8518
|
datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
|
|
@@ -8363,11 +8531,11 @@ datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
|
|
|
8363
8531
|
|
|
8364
8532
|
{
|
|
8365
8533
|
int argc2 = 1;
|
|
8366
|
-
VALUE argv2[2];
|
|
8534
|
+
VALUE argv2[2], hash;
|
|
8367
8535
|
argv2[0] = str;
|
|
8368
8536
|
argv2[1] = opt;
|
|
8369
8537
|
if (!NIL_P(opt)) argc2++;
|
|
8370
|
-
|
|
8538
|
+
hash = date_s__rfc2822(argc2, argv2, klass);
|
|
8371
8539
|
return dt_new_by_frags(klass, hash, sg);
|
|
8372
8540
|
}
|
|
8373
8541
|
}
|
|
@@ -8383,8 +8551,8 @@ datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
|
|
|
8383
8551
|
* #=> #<DateTime: 2001-02-03T04:05:06+00:00 ...>
|
|
8384
8552
|
*
|
|
8385
8553
|
* Raise an ArgumentError when the string length is longer than _limit_.
|
|
8386
|
-
* You can stop this check by passing
|
|
8387
|
-
* it may take a long time to parse.
|
|
8554
|
+
* You can stop this check by passing <code>limit: nil</code>, but note
|
|
8555
|
+
* that it may take a long time to parse.
|
|
8388
8556
|
*/
|
|
8389
8557
|
static VALUE
|
|
8390
8558
|
datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)
|
|
@@ -8403,11 +8571,11 @@ datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)
|
|
|
8403
8571
|
|
|
8404
8572
|
{
|
|
8405
8573
|
int argc2 = 1;
|
|
8406
|
-
VALUE argv2[2];
|
|
8574
|
+
VALUE argv2[2], hash;
|
|
8407
8575
|
argv2[0] = str;
|
|
8408
8576
|
argv2[1] = opt;
|
|
8409
8577
|
if (!NIL_P(opt)) argc2++;
|
|
8410
|
-
|
|
8578
|
+
hash = date_s__httpdate(argc2, argv2, klass);
|
|
8411
8579
|
return dt_new_by_frags(klass, hash, sg);
|
|
8412
8580
|
}
|
|
8413
8581
|
}
|
|
@@ -8428,8 +8596,8 @@ datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)
|
|
|
8428
8596
|
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
|
8429
8597
|
*
|
|
8430
8598
|
* Raise an ArgumentError when the string length is longer than _limit_.
|
|
8431
|
-
* You can stop this check by passing
|
|
8432
|
-
* it may take a long time to parse.
|
|
8599
|
+
* You can stop this check by passing <code>limit: nil</code>, but note
|
|
8600
|
+
* that it may take a long time to parse.
|
|
8433
8601
|
*/
|
|
8434
8602
|
static VALUE
|
|
8435
8603
|
datetime_s_jisx0301(int argc, VALUE *argv, VALUE klass)
|
|
@@ -8448,11 +8616,11 @@ datetime_s_jisx0301(int argc, VALUE *argv, VALUE klass)
|
|
|
8448
8616
|
|
|
8449
8617
|
{
|
|
8450
8618
|
int argc2 = 1;
|
|
8451
|
-
VALUE argv2[2];
|
|
8619
|
+
VALUE argv2[2], hash;
|
|
8452
8620
|
argv2[0] = str;
|
|
8453
8621
|
argv2[1] = opt;
|
|
8454
8622
|
if (!NIL_P(opt)) argc2++;
|
|
8455
|
-
|
|
8623
|
+
hash = date_s__jisx0301(argc2, argv2, klass);
|
|
8456
8624
|
return dt_new_by_frags(klass, hash, sg);
|
|
8457
8625
|
}
|
|
8458
8626
|
}
|
|
@@ -8475,181 +8643,16 @@ dt_lite_to_s(VALUE self)
|
|
|
8475
8643
|
|
|
8476
8644
|
/*
|
|
8477
8645
|
* call-seq:
|
|
8478
|
-
*
|
|
8479
|
-
*
|
|
8480
|
-
*
|
|
8481
|
-
*
|
|
8482
|
-
*
|
|
8483
|
-
*
|
|
8484
|
-
*
|
|
8485
|
-
*
|
|
8486
|
-
*
|
|
8487
|
-
*
|
|
8488
|
-
* an optional modifier, and a conversion specifier
|
|
8489
|
-
* as follows.
|
|
8490
|
-
*
|
|
8491
|
-
* %<flags><width><modifier><conversion>
|
|
8492
|
-
*
|
|
8493
|
-
* Flags:
|
|
8494
|
-
* - don't pad a numerical output.
|
|
8495
|
-
* _ use spaces for padding.
|
|
8496
|
-
* 0 use zeros for padding.
|
|
8497
|
-
* ^ upcase the result string.
|
|
8498
|
-
* # change case.
|
|
8499
|
-
* : use colons for %z.
|
|
8500
|
-
*
|
|
8501
|
-
* The minimum field width specifies the minimum width.
|
|
8502
|
-
*
|
|
8503
|
-
* The modifiers are "E" and "O".
|
|
8504
|
-
* They are ignored.
|
|
8505
|
-
*
|
|
8506
|
-
* Format directives:
|
|
8507
|
-
*
|
|
8508
|
-
* Date (Year, Month, Day):
|
|
8509
|
-
* %Y - Year with century (can be negative, 4 digits at least)
|
|
8510
|
-
* -0001, 0000, 1995, 2009, 14292, etc.
|
|
8511
|
-
* %C - year / 100 (round down. 20 in 2009)
|
|
8512
|
-
* %y - year % 100 (00..99)
|
|
8513
|
-
*
|
|
8514
|
-
* %m - Month of the year, zero-padded (01..12)
|
|
8515
|
-
* %_m blank-padded ( 1..12)
|
|
8516
|
-
* %-m no-padded (1..12)
|
|
8517
|
-
* %B - The full month name (``January'')
|
|
8518
|
-
* %^B uppercased (``JANUARY'')
|
|
8519
|
-
* %b - The abbreviated month name (``Jan'')
|
|
8520
|
-
* %^b uppercased (``JAN'')
|
|
8521
|
-
* %h - Equivalent to %b
|
|
8522
|
-
*
|
|
8523
|
-
* %d - Day of the month, zero-padded (01..31)
|
|
8524
|
-
* %-d no-padded (1..31)
|
|
8525
|
-
* %e - Day of the month, blank-padded ( 1..31)
|
|
8526
|
-
*
|
|
8527
|
-
* %j - Day of the year (001..366)
|
|
8528
|
-
*
|
|
8529
|
-
* Time (Hour, Minute, Second, Subsecond):
|
|
8530
|
-
* %H - Hour of the day, 24-hour clock, zero-padded (00..23)
|
|
8531
|
-
* %k - Hour of the day, 24-hour clock, blank-padded ( 0..23)
|
|
8532
|
-
* %I - Hour of the day, 12-hour clock, zero-padded (01..12)
|
|
8533
|
-
* %l - Hour of the day, 12-hour clock, blank-padded ( 1..12)
|
|
8534
|
-
* %P - Meridian indicator, lowercase (``am'' or ``pm'')
|
|
8535
|
-
* %p - Meridian indicator, uppercase (``AM'' or ``PM'')
|
|
8536
|
-
*
|
|
8537
|
-
* %M - Minute of the hour (00..59)
|
|
8538
|
-
*
|
|
8539
|
-
* %S - Second of the minute (00..60)
|
|
8540
|
-
*
|
|
8541
|
-
* %L - Millisecond of the second (000..999)
|
|
8542
|
-
* %N - Fractional seconds digits, default is 9 digits (nanosecond)
|
|
8543
|
-
* %3N millisecond (3 digits) %15N femtosecond (15 digits)
|
|
8544
|
-
* %6N microsecond (6 digits) %18N attosecond (18 digits)
|
|
8545
|
-
* %9N nanosecond (9 digits) %21N zeptosecond (21 digits)
|
|
8546
|
-
* %12N picosecond (12 digits) %24N yoctosecond (24 digits)
|
|
8547
|
-
*
|
|
8548
|
-
* Time zone:
|
|
8549
|
-
* %z - Time zone as hour and minute offset from UTC (e.g. +0900)
|
|
8550
|
-
* %:z - hour and minute offset from UTC with a colon (e.g. +09:00)
|
|
8551
|
-
* %::z - hour, minute and second offset from UTC (e.g. +09:00:00)
|
|
8552
|
-
* %:::z - hour, minute and second offset from UTC
|
|
8553
|
-
* (e.g. +09, +09:30, +09:30:30)
|
|
8554
|
-
* %Z - Equivalent to %:z (e.g. +09:00)
|
|
8555
|
-
*
|
|
8556
|
-
* Weekday:
|
|
8557
|
-
* %A - The full weekday name (``Sunday'')
|
|
8558
|
-
* %^A uppercased (``SUNDAY'')
|
|
8559
|
-
* %a - The abbreviated name (``Sun'')
|
|
8560
|
-
* %^a uppercased (``SUN'')
|
|
8561
|
-
* %u - Day of the week (Monday is 1, 1..7)
|
|
8562
|
-
* %w - Day of the week (Sunday is 0, 0..6)
|
|
8563
|
-
*
|
|
8564
|
-
* ISO 8601 week-based year and week number:
|
|
8565
|
-
* The week 1 of YYYY starts with a Monday and includes YYYY-01-04.
|
|
8566
|
-
* The days in the year before the first week are in the last week of
|
|
8567
|
-
* the previous year.
|
|
8568
|
-
* %G - The week-based year
|
|
8569
|
-
* %g - The last 2 digits of the week-based year (00..99)
|
|
8570
|
-
* %V - Week number of the week-based year (01..53)
|
|
8571
|
-
*
|
|
8572
|
-
* Week number:
|
|
8573
|
-
* The week 1 of YYYY starts with a Sunday or Monday (according to %U
|
|
8574
|
-
* or %W). The days in the year before the first week are in week 0.
|
|
8575
|
-
* %U - Week number of the year. The week starts with Sunday. (00..53)
|
|
8576
|
-
* %W - Week number of the year. The week starts with Monday. (00..53)
|
|
8577
|
-
*
|
|
8578
|
-
* Seconds since the Unix Epoch:
|
|
8579
|
-
* %s - Number of seconds since 1970-01-01 00:00:00 UTC.
|
|
8580
|
-
* %Q - Number of milliseconds since 1970-01-01 00:00:00 UTC.
|
|
8581
|
-
*
|
|
8582
|
-
* Literal string:
|
|
8583
|
-
* %n - Newline character (\n)
|
|
8584
|
-
* %t - Tab character (\t)
|
|
8585
|
-
* %% - Literal ``%'' character
|
|
8586
|
-
*
|
|
8587
|
-
* Combination:
|
|
8588
|
-
* %c - date and time (%a %b %e %T %Y)
|
|
8589
|
-
* %D - Date (%m/%d/%y)
|
|
8590
|
-
* %F - The ISO 8601 date format (%Y-%m-%d)
|
|
8591
|
-
* %v - VMS date (%e-%^b-%Y)
|
|
8592
|
-
* %x - Same as %D
|
|
8593
|
-
* %X - Same as %T
|
|
8594
|
-
* %r - 12-hour time (%I:%M:%S %p)
|
|
8595
|
-
* %R - 24-hour time (%H:%M)
|
|
8596
|
-
* %T - 24-hour time (%H:%M:%S)
|
|
8597
|
-
* %+ - date(1) (%a %b %e %H:%M:%S %Z %Y)
|
|
8598
|
-
*
|
|
8599
|
-
* This method is similar to the strftime() function defined in ISO C
|
|
8600
|
-
* and POSIX.
|
|
8601
|
-
* Several directives (%a, %A, %b, %B, %c, %p, %r, %x, %X, %E*, %O* and %Z)
|
|
8602
|
-
* are locale dependent in the function.
|
|
8603
|
-
* However, this method is locale independent.
|
|
8604
|
-
* So, the result may differ even if the same format string is used in other
|
|
8605
|
-
* systems such as C.
|
|
8606
|
-
* It is good practice to avoid %x and %X because there are corresponding
|
|
8607
|
-
* locale independent representations, %D and %T.
|
|
8608
|
-
*
|
|
8609
|
-
* Examples:
|
|
8610
|
-
*
|
|
8611
|
-
* d = DateTime.new(2007,11,19,8,37,48,"-06:00")
|
|
8612
|
-
* #=> #<DateTime: 2007-11-19T08:37:48-0600 ...>
|
|
8613
|
-
* d.strftime("Printed on %m/%d/%Y") #=> "Printed on 11/19/2007"
|
|
8614
|
-
* d.strftime("at %I:%M%p") #=> "at 08:37AM"
|
|
8615
|
-
*
|
|
8616
|
-
* Various ISO 8601 formats:
|
|
8617
|
-
* %Y%m%d => 20071119 Calendar date (basic)
|
|
8618
|
-
* %F => 2007-11-19 Calendar date (extended)
|
|
8619
|
-
* %Y-%m => 2007-11 Calendar date, reduced accuracy, specific month
|
|
8620
|
-
* %Y => 2007 Calendar date, reduced accuracy, specific year
|
|
8621
|
-
* %C => 20 Calendar date, reduced accuracy, specific century
|
|
8622
|
-
* %Y%j => 2007323 Ordinal date (basic)
|
|
8623
|
-
* %Y-%j => 2007-323 Ordinal date (extended)
|
|
8624
|
-
* %GW%V%u => 2007W471 Week date (basic)
|
|
8625
|
-
* %G-W%V-%u => 2007-W47-1 Week date (extended)
|
|
8626
|
-
* %GW%V => 2007W47 Week date, reduced accuracy, specific week (basic)
|
|
8627
|
-
* %G-W%V => 2007-W47 Week date, reduced accuracy, specific week (extended)
|
|
8628
|
-
* %H%M%S => 083748 Local time (basic)
|
|
8629
|
-
* %T => 08:37:48 Local time (extended)
|
|
8630
|
-
* %H%M => 0837 Local time, reduced accuracy, specific minute (basic)
|
|
8631
|
-
* %H:%M => 08:37 Local time, reduced accuracy, specific minute (extended)
|
|
8632
|
-
* %H => 08 Local time, reduced accuracy, specific hour
|
|
8633
|
-
* %H%M%S,%L => 083748,000 Local time with decimal fraction, comma as decimal sign (basic)
|
|
8634
|
-
* %T,%L => 08:37:48,000 Local time with decimal fraction, comma as decimal sign (extended)
|
|
8635
|
-
* %H%M%S.%L => 083748.000 Local time with decimal fraction, full stop as decimal sign (basic)
|
|
8636
|
-
* %T.%L => 08:37:48.000 Local time with decimal fraction, full stop as decimal sign (extended)
|
|
8637
|
-
* %H%M%S%z => 083748-0600 Local time and the difference from UTC (basic)
|
|
8638
|
-
* %T%:z => 08:37:48-06:00 Local time and the difference from UTC (extended)
|
|
8639
|
-
* %Y%m%dT%H%M%S%z => 20071119T083748-0600 Date and time of day for calendar date (basic)
|
|
8640
|
-
* %FT%T%:z => 2007-11-19T08:37:48-06:00 Date and time of day for calendar date (extended)
|
|
8641
|
-
* %Y%jT%H%M%S%z => 2007323T083748-0600 Date and time of day for ordinal date (basic)
|
|
8642
|
-
* %Y-%jT%T%:z => 2007-323T08:37:48-06:00 Date and time of day for ordinal date (extended)
|
|
8643
|
-
* %GW%V%uT%H%M%S%z => 2007W471T083748-0600 Date and time of day for week date (basic)
|
|
8644
|
-
* %G-W%V-%uT%T%:z => 2007-W47-1T08:37:48-06:00 Date and time of day for week date (extended)
|
|
8645
|
-
* %Y%m%dT%H%M => 20071119T0837 Calendar date and local time (basic)
|
|
8646
|
-
* %FT%R => 2007-11-19T08:37 Calendar date and local time (extended)
|
|
8647
|
-
* %Y%jT%H%MZ => 2007323T0837Z Ordinal date and UTC of day (basic)
|
|
8648
|
-
* %Y-%jT%RZ => 2007-323T08:37Z Ordinal date and UTC of day (extended)
|
|
8649
|
-
* %GW%V%uT%H%M%z => 2007W471T0837-0600 Week date and local time and difference from UTC (basic)
|
|
8650
|
-
* %G-W%V-%uT%R%:z => 2007-W47-1T08:37-06:00 Week date and local time and difference from UTC (extended)
|
|
8651
|
-
*
|
|
8652
|
-
* See also strftime(3) and ::strptime.
|
|
8646
|
+
* strftime(format = '%FT%T%:z') -> string
|
|
8647
|
+
*
|
|
8648
|
+
* Returns a string representation of +self+,
|
|
8649
|
+
* formatted according the given +format:
|
|
8650
|
+
*
|
|
8651
|
+
* DateTime.now.strftime # => "2022-07-01T11:03:19-05:00"
|
|
8652
|
+
*
|
|
8653
|
+
* For other formats, see
|
|
8654
|
+
* {Formats for Dates and Times}[doc/strftime_formatting.rdoc].
|
|
8655
|
+
*
|
|
8653
8656
|
*/
|
|
8654
8657
|
static VALUE
|
|
8655
8658
|
dt_lite_strftime(int argc, VALUE *argv, VALUE self)
|
|
@@ -8815,7 +8818,7 @@ time_to_datetime(VALUE self)
|
|
|
8815
8818
|
ret = d_complex_new_internal(cDateTime,
|
|
8816
8819
|
nth, 0,
|
|
8817
8820
|
0, sf,
|
|
8818
|
-
of,
|
|
8821
|
+
of, GREGORIAN,
|
|
8819
8822
|
ry, m, d,
|
|
8820
8823
|
h, min, s,
|
|
8821
8824
|
HAVE_CIVIL | HAVE_TIME);
|
|
@@ -8828,10 +8831,15 @@ time_to_datetime(VALUE self)
|
|
|
8828
8831
|
|
|
8829
8832
|
/*
|
|
8830
8833
|
* call-seq:
|
|
8831
|
-
*
|
|
8834
|
+
* to_time -> time
|
|
8835
|
+
*
|
|
8836
|
+
* Returns a new Time object with the same value as +self+;
|
|
8837
|
+
* if +self+ is a Julian date, derives its Gregorian date
|
|
8838
|
+
* for conversion to the \Time object:
|
|
8839
|
+
*
|
|
8840
|
+
* Date.new(2001, 2, 3).to_time # => 2001-02-03 00:00:00 -0600
|
|
8841
|
+
* Date.new(2001, 2, 3, Date::JULIAN).to_time # => 2001-02-16 00:00:00 -0600
|
|
8832
8842
|
*
|
|
8833
|
-
* Returns a Time object which denotes self. If self is a julian date,
|
|
8834
|
-
* convert it to a gregorian date before converting it to Time.
|
|
8835
8843
|
*/
|
|
8836
8844
|
static VALUE
|
|
8837
8845
|
date_to_time(VALUE self)
|
|
@@ -8852,9 +8860,9 @@ date_to_time(VALUE self)
|
|
|
8852
8860
|
|
|
8853
8861
|
/*
|
|
8854
8862
|
* call-seq:
|
|
8855
|
-
*
|
|
8863
|
+
* to_date -> self
|
|
8856
8864
|
*
|
|
8857
|
-
* Returns self
|
|
8865
|
+
* Returns +self+.
|
|
8858
8866
|
*/
|
|
8859
8867
|
static VALUE
|
|
8860
8868
|
date_to_date(VALUE self)
|
|
@@ -8866,7 +8874,10 @@ date_to_date(VALUE self)
|
|
|
8866
8874
|
* call-seq:
|
|
8867
8875
|
* d.to_datetime -> datetime
|
|
8868
8876
|
*
|
|
8869
|
-
* Returns a DateTime
|
|
8877
|
+
* Returns a DateTime whose value is the same as +self+:
|
|
8878
|
+
*
|
|
8879
|
+
* Date.new(2001, 2, 3).to_datetime # => #<DateTime: 2001-02-03T00:00:00+00:00>
|
|
8880
|
+
*
|
|
8870
8881
|
*/
|
|
8871
8882
|
static VALUE
|
|
8872
8883
|
date_to_datetime(VALUE self)
|
|
@@ -8911,12 +8922,17 @@ date_to_datetime(VALUE self)
|
|
|
8911
8922
|
static VALUE
|
|
8912
8923
|
datetime_to_time(VALUE self)
|
|
8913
8924
|
{
|
|
8914
|
-
|
|
8925
|
+
get_d1(self);
|
|
8926
|
+
|
|
8927
|
+
if (m_julian_p(dat)) {
|
|
8928
|
+
self = d_lite_gregorian(self);
|
|
8929
|
+
get_d1a(self);
|
|
8930
|
+
dat = adat;
|
|
8931
|
+
}
|
|
8932
|
+
|
|
8915
8933
|
{
|
|
8916
8934
|
VALUE t;
|
|
8917
8935
|
|
|
8918
|
-
get_d1(dup);
|
|
8919
|
-
|
|
8920
8936
|
t = rb_funcall(rb_cTime,
|
|
8921
8937
|
rb_intern("new"),
|
|
8922
8938
|
7,
|
|
@@ -8984,6 +9000,7 @@ datetime_to_datetime(VALUE self)
|
|
|
8984
9000
|
#define MIN_JD -327
|
|
8985
9001
|
#define MAX_JD 366963925
|
|
8986
9002
|
|
|
9003
|
+
/* :nodoc: */
|
|
8987
9004
|
static int
|
|
8988
9005
|
test_civil(int from, int to, double sg)
|
|
8989
9006
|
{
|
|
@@ -9004,6 +9021,7 @@ test_civil(int from, int to, double sg)
|
|
|
9004
9021
|
return 1;
|
|
9005
9022
|
}
|
|
9006
9023
|
|
|
9024
|
+
/* :nodoc: */
|
|
9007
9025
|
static VALUE
|
|
9008
9026
|
date_s_test_civil(VALUE klass)
|
|
9009
9027
|
{
|
|
@@ -9024,6 +9042,7 @@ date_s_test_civil(VALUE klass)
|
|
|
9024
9042
|
return Qtrue;
|
|
9025
9043
|
}
|
|
9026
9044
|
|
|
9045
|
+
/* :nodoc: */
|
|
9027
9046
|
static int
|
|
9028
9047
|
test_ordinal(int from, int to, double sg)
|
|
9029
9048
|
{
|
|
@@ -9044,6 +9063,7 @@ test_ordinal(int from, int to, double sg)
|
|
|
9044
9063
|
return 1;
|
|
9045
9064
|
}
|
|
9046
9065
|
|
|
9066
|
+
/* :nodoc: */
|
|
9047
9067
|
static VALUE
|
|
9048
9068
|
date_s_test_ordinal(VALUE klass)
|
|
9049
9069
|
{
|
|
@@ -9064,6 +9084,7 @@ date_s_test_ordinal(VALUE klass)
|
|
|
9064
9084
|
return Qtrue;
|
|
9065
9085
|
}
|
|
9066
9086
|
|
|
9087
|
+
/* :nodoc: */
|
|
9067
9088
|
static int
|
|
9068
9089
|
test_commercial(int from, int to, double sg)
|
|
9069
9090
|
{
|
|
@@ -9084,6 +9105,7 @@ test_commercial(int from, int to, double sg)
|
|
|
9084
9105
|
return 1;
|
|
9085
9106
|
}
|
|
9086
9107
|
|
|
9108
|
+
/* :nodoc: */
|
|
9087
9109
|
static VALUE
|
|
9088
9110
|
date_s_test_commercial(VALUE klass)
|
|
9089
9111
|
{
|
|
@@ -9104,6 +9126,7 @@ date_s_test_commercial(VALUE klass)
|
|
|
9104
9126
|
return Qtrue;
|
|
9105
9127
|
}
|
|
9106
9128
|
|
|
9129
|
+
/* :nodoc: */
|
|
9107
9130
|
static int
|
|
9108
9131
|
test_weeknum(int from, int to, int f, double sg)
|
|
9109
9132
|
{
|
|
@@ -9124,6 +9147,7 @@ test_weeknum(int from, int to, int f, double sg)
|
|
|
9124
9147
|
return 1;
|
|
9125
9148
|
}
|
|
9126
9149
|
|
|
9150
|
+
/* :nodoc: */
|
|
9127
9151
|
static VALUE
|
|
9128
9152
|
date_s_test_weeknum(VALUE klass)
|
|
9129
9153
|
{
|
|
@@ -9148,6 +9172,7 @@ date_s_test_weeknum(VALUE klass)
|
|
|
9148
9172
|
return Qtrue;
|
|
9149
9173
|
}
|
|
9150
9174
|
|
|
9175
|
+
/* :nodoc: */
|
|
9151
9176
|
static int
|
|
9152
9177
|
test_nth_kday(int from, int to, double sg)
|
|
9153
9178
|
{
|
|
@@ -9168,6 +9193,7 @@ test_nth_kday(int from, int to, double sg)
|
|
|
9168
9193
|
return 1;
|
|
9169
9194
|
}
|
|
9170
9195
|
|
|
9196
|
+
/* :nodoc: */
|
|
9171
9197
|
static VALUE
|
|
9172
9198
|
date_s_test_nth_kday(VALUE klass)
|
|
9173
9199
|
{
|
|
@@ -9188,6 +9214,7 @@ date_s_test_nth_kday(VALUE klass)
|
|
|
9188
9214
|
return Qtrue;
|
|
9189
9215
|
}
|
|
9190
9216
|
|
|
9217
|
+
/* :nodoc: */
|
|
9191
9218
|
static int
|
|
9192
9219
|
test_unit_v2v(VALUE i,
|
|
9193
9220
|
VALUE (* conv1)(VALUE),
|
|
@@ -9199,6 +9226,7 @@ test_unit_v2v(VALUE i,
|
|
|
9199
9226
|
return f_eqeq_p(o, i);
|
|
9200
9227
|
}
|
|
9201
9228
|
|
|
9229
|
+
/* :nodoc: */
|
|
9202
9230
|
static int
|
|
9203
9231
|
test_unit_v2v_iter2(VALUE (* conv1)(VALUE),
|
|
9204
9232
|
VALUE (* conv2)(VALUE))
|
|
@@ -9230,6 +9258,7 @@ test_unit_v2v_iter2(VALUE (* conv1)(VALUE),
|
|
|
9230
9258
|
return 1;
|
|
9231
9259
|
}
|
|
9232
9260
|
|
|
9261
|
+
/* :nodoc: */
|
|
9233
9262
|
static int
|
|
9234
9263
|
test_unit_v2v_iter(VALUE (* conv1)(VALUE),
|
|
9235
9264
|
VALUE (* conv2)(VALUE))
|
|
@@ -9241,6 +9270,7 @@ test_unit_v2v_iter(VALUE (* conv1)(VALUE),
|
|
|
9241
9270
|
return 1;
|
|
9242
9271
|
}
|
|
9243
9272
|
|
|
9273
|
+
/* :nodoc: */
|
|
9244
9274
|
static VALUE
|
|
9245
9275
|
date_s_test_unit_conv(VALUE klass)
|
|
9246
9276
|
{
|
|
@@ -9255,6 +9285,7 @@ date_s_test_unit_conv(VALUE klass)
|
|
|
9255
9285
|
return Qtrue;
|
|
9256
9286
|
}
|
|
9257
9287
|
|
|
9288
|
+
/* :nodoc: */
|
|
9258
9289
|
static VALUE
|
|
9259
9290
|
date_s_test_all(VALUE klass)
|
|
9260
9291
|
{
|
|
@@ -9321,6 +9352,7 @@ mk_ary_of_str(long len, const char *a[])
|
|
|
9321
9352
|
return o;
|
|
9322
9353
|
}
|
|
9323
9354
|
|
|
9355
|
+
/* :nodoc: */
|
|
9324
9356
|
static VALUE
|
|
9325
9357
|
d_lite_zero(VALUE x)
|
|
9326
9358
|
{
|
|
@@ -9358,152 +9390,81 @@ Init_date_core(void)
|
|
|
9358
9390
|
negative_inf = -INFINITY;
|
|
9359
9391
|
|
|
9360
9392
|
/*
|
|
9361
|
-
*
|
|
9362
|
-
*
|
|
9363
|
-
* 'date' provides two classes: Date and DateTime.
|
|
9364
|
-
*
|
|
9365
|
-
* == Terms and Definitions
|
|
9366
|
-
*
|
|
9367
|
-
* Some terms and definitions are based on ISO 8601 and JIS X 0301.
|
|
9368
|
-
*
|
|
9369
|
-
* === Calendar Date
|
|
9370
|
-
*
|
|
9371
|
-
* The calendar date is a particular day of a calendar year,
|
|
9372
|
-
* identified by its ordinal number within a calendar month within
|
|
9373
|
-
* that year.
|
|
9374
|
-
*
|
|
9375
|
-
* In those classes, this is so-called "civil".
|
|
9376
|
-
*
|
|
9377
|
-
* === Ordinal Date
|
|
9393
|
+
* \Class \Date provides methods for storing and manipulating
|
|
9394
|
+
* calendar dates.
|
|
9378
9395
|
*
|
|
9379
|
-
*
|
|
9380
|
-
*
|
|
9396
|
+
* Consider using
|
|
9397
|
+
* {class Time}[https://docs.ruby-lang.org/en/master/Time.html]
|
|
9398
|
+
* instead of class \Date if:
|
|
9381
9399
|
*
|
|
9382
|
-
*
|
|
9400
|
+
* - You need both dates and times; \Date handles only dates.
|
|
9401
|
+
* - You need only Gregorian dates (and not Julian dates);
|
|
9402
|
+
* see {Julian and Gregorian Calendars}[rdoc-ref:calendars.rdoc].
|
|
9383
9403
|
*
|
|
9384
|
-
*
|
|
9404
|
+
* A \Date object, once created, is immutable, and cannot be modified.
|
|
9385
9405
|
*
|
|
9386
|
-
*
|
|
9406
|
+
* == Creating a \Date
|
|
9387
9407
|
*
|
|
9388
|
-
*
|
|
9389
|
-
* starting on a Monday and identified by its ordinal number within
|
|
9390
|
-
* the year; the first calendar week of the year is the one that
|
|
9391
|
-
* includes the first Thursday of that year. In the Gregorian
|
|
9392
|
-
* calendar, this is equivalent to the week which includes January 4.
|
|
9408
|
+
* You can create a date for the current date, using Date.today:
|
|
9393
9409
|
*
|
|
9394
|
-
*
|
|
9410
|
+
* Date.today # => #<Date: 1999-12-31>
|
|
9395
9411
|
*
|
|
9396
|
-
*
|
|
9412
|
+
* You can create a specific date from various combinations of arguments:
|
|
9397
9413
|
*
|
|
9398
|
-
*
|
|
9399
|
-
* Time) on January 1, 4713 BCE (in the Julian calendar).
|
|
9414
|
+
* - Date.new takes integer year, month, and day-of-month:
|
|
9400
9415
|
*
|
|
9401
|
-
*
|
|
9402
|
-
* the original Julian day number. And the chronological Julian day
|
|
9403
|
-
* number is a variation of the Julian day number. Its days begin at
|
|
9404
|
-
* midnight on local time.
|
|
9416
|
+
* Date.new(1999, 12, 31) # => #<Date: 1999-12-31>
|
|
9405
9417
|
*
|
|
9406
|
-
*
|
|
9407
|
-
* it just refers to "chronological Julian day number", not the
|
|
9408
|
-
* original.
|
|
9418
|
+
* - Date.ordinal takes integer year and day-of-year:
|
|
9409
9419
|
*
|
|
9410
|
-
*
|
|
9420
|
+
* Date.ordinal(1999, 365) # => #<Date: 1999-12-31>
|
|
9411
9421
|
*
|
|
9412
|
-
*
|
|
9422
|
+
* - Date.jd takes integer Julian day:
|
|
9413
9423
|
*
|
|
9414
|
-
*
|
|
9415
|
-
* (Coordinated Universal Time) on November 17, 1858 CE (in the
|
|
9416
|
-
* Gregorian calendar).
|
|
9424
|
+
* Date.jd(2451544) # => #<Date: 1999-12-31>
|
|
9417
9425
|
*
|
|
9418
|
-
*
|
|
9419
|
-
* the same as the original modified Julian day number. And the
|
|
9420
|
-
* chronological modified Julian day number is a variation of the
|
|
9421
|
-
* modified Julian day number. Its days begin at midnight on local
|
|
9422
|
-
* time.
|
|
9426
|
+
* - Date.commercial takes integer commercial data (year, week, day-of-week):
|
|
9423
9427
|
*
|
|
9424
|
-
*
|
|
9425
|
-
* appears, it just refers to "chronological modified Julian day
|
|
9426
|
-
* number", not the original.
|
|
9428
|
+
* Date.commercial(1999, 52, 5) # => #<Date: 1999-12-31>
|
|
9427
9429
|
*
|
|
9428
|
-
*
|
|
9430
|
+
* - Date.parse takes a string, which it parses heuristically:
|
|
9429
9431
|
*
|
|
9430
|
-
*
|
|
9432
|
+
* Date.parse('1999-12-31') # => #<Date: 1999-12-31>
|
|
9433
|
+
* Date.parse('31-12-1999') # => #<Date: 1999-12-31>
|
|
9434
|
+
* Date.parse('1999-365') # => #<Date: 1999-12-31>
|
|
9435
|
+
* Date.parse('1999-W52-5') # => #<Date: 1999-12-31>
|
|
9431
9436
|
*
|
|
9432
|
-
*
|
|
9433
|
-
*
|
|
9437
|
+
* - Date.strptime takes a date string and a format string,
|
|
9438
|
+
* then parses the date string according to the format string:
|
|
9434
9439
|
*
|
|
9435
|
-
*
|
|
9436
|
-
*
|
|
9437
|
-
*
|
|
9440
|
+
* Date.strptime('1999-12-31', '%Y-%m-%d') # => #<Date: 1999-12-31>
|
|
9441
|
+
* Date.strptime('31-12-1999', '%d-%m-%Y') # => #<Date: 1999-12-31>
|
|
9442
|
+
* Date.strptime('1999-365', '%Y-%j') # => #<Date: 1999-12-31>
|
|
9443
|
+
* Date.strptime('1999-W52-5', '%G-W%V-%u') # => #<Date: 1999-12-31>
|
|
9444
|
+
* Date.strptime('1999 52 5', '%Y %U %w') # => #<Date: 1999-12-31>
|
|
9445
|
+
* Date.strptime('1999 52 5', '%Y %W %u') # => #<Date: 1999-12-31>
|
|
9446
|
+
* Date.strptime('fri31dec99', '%a%d%b%y') # => #<Date: 1999-12-31>
|
|
9438
9447
|
*
|
|
9439
|
-
*
|
|
9440
|
-
*
|
|
9441
|
-
* Date.new(2001,2,3)
|
|
9442
|
-
* #=> #<Date: 2001-02-03 ...>
|
|
9443
|
-
* Date.jd(2451944)
|
|
9444
|
-
* #=> #<Date: 2001-02-03 ...>
|
|
9445
|
-
* Date.ordinal(2001,34)
|
|
9446
|
-
* #=> #<Date: 2001-02-03 ...>
|
|
9447
|
-
* Date.commercial(2001,5,6)
|
|
9448
|
-
* #=> #<Date: 2001-02-03 ...>
|
|
9449
|
-
* Date.parse('2001-02-03')
|
|
9450
|
-
* #=> #<Date: 2001-02-03 ...>
|
|
9451
|
-
* Date.strptime('03-02-2001', '%d-%m-%Y')
|
|
9452
|
-
* #=> #<Date: 2001-02-03 ...>
|
|
9453
|
-
* Time.new(2001,2,3).to_date
|
|
9454
|
-
* #=> #<Date: 2001-02-03 ...>
|
|
9455
|
-
*
|
|
9456
|
-
* All date objects are immutable; hence cannot modify themselves.
|
|
9448
|
+
* See also the specialized methods in
|
|
9449
|
+
* {"Specialized Format Strings" in Formats for Dates and Times}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-Specialized+Format+Strings]
|
|
9457
9450
|
*
|
|
9458
|
-
*
|
|
9459
|
-
* of the day count, the offset and the day of calendar reform.
|
|
9451
|
+
* == Argument +limit+
|
|
9460
9452
|
*
|
|
9461
|
-
*
|
|
9462
|
-
*
|
|
9463
|
-
*
|
|
9464
|
-
* reform denotes the start day of the new style. The old style
|
|
9465
|
-
* of the West is the Julian calendar which was adopted by
|
|
9466
|
-
* Caesar. The new style is the Gregorian calendar, which is the
|
|
9467
|
-
* current civil calendar of many countries.
|
|
9453
|
+
* Certain singleton methods in \Date that parse string arguments
|
|
9454
|
+
* also take optional keyword argument +limit+,
|
|
9455
|
+
* which can limit the length of the string argument.
|
|
9468
9456
|
*
|
|
9469
|
-
*
|
|
9470
|
-
* The offset in this class is usually zero, and cannot be
|
|
9471
|
-
* specified directly.
|
|
9472
|
-
*
|
|
9473
|
-
* A Date object can be created with an optional argument,
|
|
9474
|
-
* the day of calendar reform as a Julian day number, which
|
|
9475
|
-
* should be 2298874 to 2426355 or negative/positive infinity.
|
|
9476
|
-
* The default value is +Date::ITALY+ (2299161=1582-10-15).
|
|
9477
|
-
* See also sample/cal.rb.
|
|
9457
|
+
* When +limit+ is:
|
|
9478
9458
|
*
|
|
9479
|
-
*
|
|
9480
|
-
*
|
|
9481
|
-
*
|
|
9482
|
-
*
|
|
9483
|
-
* 17 18 19 20 21 22 23
|
|
9484
|
-
* 24 25 26 27 28 29 30
|
|
9485
|
-
* 31
|
|
9486
|
-
*
|
|
9487
|
-
* $ ruby sample/cal.rb -c gb 9 1752
|
|
9488
|
-
* September 1752
|
|
9489
|
-
* S M Tu W Th F S
|
|
9490
|
-
* 1 2 14 15 16
|
|
9491
|
-
* 17 18 19 20 21 22 23
|
|
9492
|
-
* 24 25 26 27 28 29 30
|
|
9493
|
-
*
|
|
9494
|
-
* A Date object has various methods. See each reference.
|
|
9495
|
-
*
|
|
9496
|
-
* d = Date.parse('3rd Feb 2001')
|
|
9497
|
-
* #=> #<Date: 2001-02-03 ...>
|
|
9498
|
-
* d.year #=> 2001
|
|
9499
|
-
* d.mon #=> 2
|
|
9500
|
-
* d.mday #=> 3
|
|
9501
|
-
* d.wday #=> 6
|
|
9502
|
-
* d += 1 #=> #<Date: 2001-02-04 ...>
|
|
9503
|
-
* d.strftime('%a %d %b %Y') #=> "Sun 04 Feb 2001"
|
|
9459
|
+
* - Non-negative:
|
|
9460
|
+
* raises ArgumentError if the string length is greater than _limit_.
|
|
9461
|
+
* - Other numeric or +nil+: ignores +limit+.
|
|
9462
|
+
* - Other non-numeric: raises TypeError.
|
|
9504
9463
|
*
|
|
9505
9464
|
*/
|
|
9506
9465
|
cDate = rb_define_class("Date", rb_cObject);
|
|
9466
|
+
|
|
9467
|
+
/* Exception for invalid date/time */
|
|
9507
9468
|
eDateError = rb_define_class_under(cDate, "Error", rb_eArgError);
|
|
9508
9469
|
|
|
9509
9470
|
rb_include_module(cDate, rb_mComparable);
|