@@ -1058,11 +1058,15 @@ object DateTimeUtils {
10581058 rebased
10591059 }
10601060
1061- private val julToGregDay = Array (
1061+ // The differences in days between Julian and Proleptic Gregorian dates.
1062+ // The diff at the index `i` is applicable for all days in the date interval:
1063+ // [julianGregDiffSwitchDay(i), julianGregDiffSwitchDay(i+1))
1064+ private val julianGregDiffs = Array (2 , 1 , 0 , - 1 , - 2 , - 3 , - 4 , - 5 , - 6 , - 7 , - 8 , - 9 , - 10 , 0 )
1065+ // The sorted days when difference in days between Julian and Proleptic
1066+ // Gregorian calendars was changed.
1067+ private val julianGregDiffSwitchDay = Array (
10621068 - 719164 , - 682945 , - 646420 , - 609895 , - 536845 , - 500320 , - 463795 ,
10631069 - 390745 , - 354220 , - 317695 , - 244645 , - 208120 , - 171595 , - 141427 )
1064- private val julToGregDiff = Array (2 , 1 , 0 , - 1 , - 2 , - 3 , - 4 , - 5 , - 6 , - 7 , - 8 , - 9 , - 10 , 0 )
1065-
10661070 /**
10671071 * Converts the given number of days since the epoch day 1970-01-01 to
10681072 * a local date in Julian calendar, interprets the result as a local
@@ -1073,14 +1077,18 @@ object DateTimeUtils {
10731077 * @return The rebased number of days in Gregorian calendar.
10741078 */
10751079 def rebaseJulianToGregorianDays (days : Int ): Int = {
1076- rebaseDays(julToGregDay, julToGregDiff , days)
1080+ rebaseDays(julianGregDiffSwitchDay, julianGregDiffs , days)
10771081 }
10781082
1079- private val gregToJulDay = Array (
1083+ // The differences in days between Proleptic Gregorian and Julian dates.
1084+ // The diff at the index `i` is applicable for all days in the date interval:
1085+ // [gregJulianDiffSwitchDay(i), gregJulianDiffSwitchDay(i+1))
1086+ private val grepJulianDiffs = Array (- 2 , - 1 , 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 0 )
1087+ // The sorted days when difference in days between Proleptic
1088+ // Gregorian and Julian was changed.
1089+ private val gregJulianDiffSwitchDay = Array (
10801090 - 719162 , - 682944 , - 646420 , - 609896 , - 536847 , - 500323 , - 463799 ,
10811091 - 390750 , - 354226 , - 317702 , - 244653 , - 208129 , - 171605 , - 141427 )
1082- private val gregToJulDiff = Array (- 2 , - 1 , 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 0 )
1083-
10841092 /**
10851093 * Rebasing days since the epoch to store the same number of days
10861094 * as by Spark 2.4 and earlier versions. Spark 3.0 switched to
@@ -1098,6 +1106,6 @@ object DateTimeUtils {
10981106 * @return The rebased number of days since the epoch in Julian calendar.
10991107 */
11001108 def rebaseGregorianToJulianDays (days : Int ): Int = {
1101- rebaseDays(gregToJulDay, gregToJulDiff , days)
1109+ rebaseDays(gregJulianDiffSwitchDay, grepJulianDiffs , days)
11021110 }
11031111}
0 commit comments