summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/POSIX/t/posix.t17
-rw-r--r--util.c14
2 files changed, 18 insertions, 13 deletions
diff --git a/ext/POSIX/t/posix.t b/ext/POSIX/t/posix.t
index 442b540dac..be804c24a2 100644
--- a/ext/POSIX/t/posix.t
+++ b/ext/POSIX/t/posix.t
@@ -8,7 +8,7 @@ BEGIN {
}
}
-use Test::More tests => 106;
+use Test::More tests => 109;
use POSIX qw(fcntl_h signal_h limits_h _exit getcwd open read strftime write
errno localeconv dup dup2 lseek access);
@@ -224,6 +224,21 @@ try_strftime("Mon Feb 28 00:00:00 2000 059", 0,0,0, 28,1,100);
try_strftime("Tue Feb 29 00:00:00 2000 060", 0,0,0, 0,2,100);
try_strftime("Wed Mar 01 00:00:00 2000 061", 0,0,0, 1,2,100);
try_strftime("Fri Mar 31 00:00:00 2000 091", 0,0,0, 31,2,100);
+
+{ # rt 72232
+
+ # Std C/POSIX allows day/month to be negative and requires that
+ # wday/yday be adjusted as needed
+ # previously mini_mktime() would allow yday to dominate if mday and
+ # month were both non-positive
+ # check that yday doesn't dominate
+ try_strftime("Thu Dec 30 00:00:00 1999 364", 0,0,0, -1,0,100);
+ try_strftime("Thu Dec 30 00:00:00 1999 364", 0,0,0, -1,0,100,-1,10);
+ # it would also allow a positive wday to override the calculated value
+ # check that wday is recalculated too
+ try_strftime("Thu Dec 30 00:00:00 1999 364", 0,0,0, -1,0,100,0,10);
+}
+
&POSIX::setlocale(&POSIX::LC_TIME, $lc) if $Config{d_setlocale};
{
diff --git a/util.c b/util.c
index 5e69cb9373..94f92b2761 100644
--- a/util.c
+++ b/util.c
@@ -3910,15 +3910,7 @@ Perl_mini_mktime(pTHX_ struct tm *ptm)
year = 1900 + ptm->tm_year;
month = ptm->tm_mon;
mday = ptm->tm_mday;
- /* allow given yday with no month & mday to dominate the result */
- if (ptm->tm_yday >= 0 && mday <= 0 && month <= 0) {
- month = 0;
- mday = 0;
- jday = 1 + ptm->tm_yday;
- }
- else {
- jday = 0;
- }
+ jday = 0;
if (month >= 2)
month+=2;
else
@@ -4013,9 +4005,7 @@ Perl_mini_mktime(pTHX_ struct tm *ptm)
yearday = year*DAYS_PER_YEAR + year/4 - year/100 + year/400;
yearday += 14*MONTH_TO_DAYS + 1;
ptm->tm_yday = jday - yearday;
- /* fix tm_wday if not overridden by caller */
- if ((unsigned)ptm->tm_wday > 6)
- ptm->tm_wday = (jday + WEEKDAY_BIAS) % 7;
+ ptm->tm_wday = (jday + WEEKDAY_BIAS) % 7;
}
char *