Skip to content

Commit 81633ab

Browse files
committed
rework checks and re-establish old test value.
1 parent 35325ca commit 81633ab

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

ext/calendar/dow.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,11 @@ int DayOfWeek(
3535
{
3636
int dow;
3737

38-
if ((sdn + 1) > INT_MAX) {
39-
return (0);
40-
}
41-
42-
dow = (sdn + 1) % 7;
38+
dow = (int)(sdn % 7 + 1);
4339
if (dow >= 0) {
44-
return (dow);
40+
return (dow % 7);
4541
} else {
46-
return (dow + 7);
42+
return (dow + 7) % 7;
4743
}
4844
}
4945

ext/calendar/tests/bug53574_2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ array(9) {
2525
["year"]=>
2626
int(0)
2727
["dow"]=>
28-
int(0)
28+
int(3)
2929
["abbrevdayname"]=>
3030
string(3) "Wed"
3131
["dayname"]=>

ext/calendar/tests/gh16258.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ GH-16258 (jddayofweek overflow on argument)
44
calendar
55
--FILE--
66
<?php
7-
jddayofweek(9223372036854775807, 1);
8-
jddayofweek(-9223372036854775806, 1);
7+
jddayofweek(PHP_INT_MAX, 1);
8+
jddayofweek(PHP_INT_MIN, 1);
99
echo "DONE";
1010
?>
1111
--EXPECT--

0 commit comments

Comments
 (0)