2012, 2013, 2014, 2015
};
-static const char dow_year_start[SOLAR_CYCLE_LENGTH] = {
- 5, 0, 1, 2, /* 0 2016 - 2019 */
- 3, 5, 6, 0, /* 4 */
- 1, 3, 4, 5, /* 8 */
- 6, 1, 2, 3, /* 12 */
- 4, 6, 0, 1, /* 16 */
- 2, 4, 5, 6, /* 20 2036, 2037, 2010, 2011 */
- 0, 2, 3, 4 /* 24 2012, 2013, 2014, 2015 */
-};
-
/* Let's assume people are going to be looking for dates in the future.
Let's provide some cheats so you can skip ahead.
This has a 4x speed boost when near 2008.
static int S_is_exception_century(Year year)
{
- int is_exception = ((year % 100 == 0) && !(year % 400 == 0));
+ const int is_exception = ((year % 100 == 0) && !(year % 400 == 0));
TIME64_TRACE1("# is_exception_century: %s\n", is_exception ? "yes" : "no");
return(is_exception);
}
-static Time64_T S_timegm64(struct TM *date) {
+static Time64_T S_timegm64(const struct TM *date) {
int days = 0;
Time64_T seconds = 0;
- Year year;
if( date->tm_year > 70 ) {
- year = 70;
+ Year year = 70;
while( year < date->tm_year ) {
days += length_of_year[IS_LEAP(year)];
year++;
}
}
else if ( date->tm_year < 70 ) {
- year = 69;
+ Year year = 69;
do {
days -= length_of_year[IS_LEAP(year)];
year--;
#ifdef DEBUGGING
-static int S_check_tm(struct TM *tm)
+static int S_check_tm(const struct TM *tm)
{
/* Don't forget leap seconds */
assert(tm->tm_sec >= 0);
#ifdef __VMS
dTHX; /* the following is defined as Perl_my_localtime(aTHX_ ...) */
#endif
- const struct tm *static_result = localtime(clock);
+ const struct tm * const static_result = localtime(clock);
assert(result != NULL);
#ifdef __VMS
dTHX; /* the following is defined as Perl_my_localtime(aTHX_ ...) */
#endif
- const struct tm *static_result = gmtime(clock);
+ const struct tm * const static_result = gmtime(clock);
assert(result != NULL);
Time64_T m;
Time64_T time = *in_time;
Year year = 70;
- int cycles = 0;
assert(p != NULL);
if (m >= 0) {
/* Gregorian cycles, this is huge optimization for distant times */
- cycles = (int)Perl_floor(m / (Time64_T) days_in_gregorian_cycle);
+ const int cycles = (int)Perl_floor(m / (Time64_T) days_in_gregorian_cycle);
if( cycles ) {
m -= (cycles * (Time64_T) days_in_gregorian_cycle);
year += (cycles * years_in_gregorian_cycle);
v_tm_mon++;
}
} else {
+ int cycles;
+
year--;
/* Gregorian cycles */