(Michael Sierks)
- Date:
+ . Fixed bug #63740 (strtotime seems to use both sunday and monday as start of
+ week). (Derick)
. Fixed bug #71889 (DateInterval::format Segmentation fault). (Thomas Punt)
- EXIF:
timelib_long timelib_parse_tz_cor(char **ptr)
{
- char *begin = *ptr, *end;
- timelib_long tmp;
-
- while (isdigit(**ptr) || **ptr == ':') {
- ++*ptr;
- }
- end = *ptr;
- switch (end - begin) {
- case 1:
- case 2:
- return HOUR(strtol(begin, NULL, 10));
- break;
- case 3:
- case 4:
- if (begin[1] == ':') {
- tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 2, NULL, 10);
- return tmp;
- } else if (begin[2] == ':') {
- tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
- return tmp;
- } else {
- tmp = strtol(begin, NULL, 10);
- return HOUR(tmp / 100) + tmp % 100;
- }
- case 5:
- tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
- return tmp;
- }
- return 0;
+ char *begin = *ptr, *end;
+ timelib_long tmp;
+
+ while (isdigit(**ptr) || **ptr == ':') {
+ ++*ptr;
+ }
+ end = *ptr;
+ switch (end - begin) {
+ case 1: /* H */
+ case 2: /* HH */
+ return HOUR(strtol(begin, NULL, 10));
+ break;
+ case 3: /* H:M */
+ case 4: /* H:MM, HH:M, HHMM */
+ if (begin[1] == ':') {
+ tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 2, NULL, 10);
+ return tmp;
+ } else if (begin[2] == ':') {
+ tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
+ return tmp;
+ } else {
+ tmp = strtol(begin, NULL, 10);
+ return HOUR(tmp / 100) + tmp % 100;
+ }
+ case 5: /* HH:MM */
+ tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
+ return tmp;
+ }
+ return 0;
}
# define timelib_free free
#endif
-#define TIMELIB_VERSION 201502
-#define TIMELIB_ASCII_VERSION "2015.02"
+#define TIMELIB_VERSION 201602
+#define TIMELIB_ASCII_VERSION "2016.02"
#define TIMELIB_NONE 0x00
#define TIMELIB_OVERRIDE_TIME 0x01
current_dow = timelib_day_of_week(time->y, time->m, time->d);
if (time->relative.weekday_behavior == 2)
{
- if (time->relative.weekday == 0) {
+ /* To make "this week" work, where the current DOW is a "sunday" */
+ if (current_dow == 0 && time->relative.weekday != 0) {
+ time->relative.weekday = -6;
+ }
+
+ /* To make "sunday this week" work, where the current DOW is not a
+ * "sunday" */
+ if (time->relative.weekday == 0 && current_dow != 0) {
time->relative.weekday = 7;
}
+
time->d -= current_dow;
time->d += time->relative.weekday;
return;
--- /dev/null
+--TEST--
+Bug #63740 (strtotime seems to use both sunday and monday as start of week)
+--FILE--
+<?php
+$dates = [
+ '2015-07-04',
+ '2015-07-05',
+ '2015-07-06',
+ '2015-07-07',
+ '2015-07-08',
+ '2015-07-09',
+ '2015-07-10',
+ '2015-07-11',
+ '2015-07-12',
+ '2015-07-13',
+ '2015-07-14',
+];
+
+foreach ( $dates as $date )
+{
+ $dt = new DateTimeImmutable( "$date 00:00 UTC" );
+
+ echo $dt->format( "D Y-m-d H:i" ), " → ";
+
+ $dtn = $dt->modify( "this week" );
+
+ echo $dtn->format( "D Y-m-d H:i" ), "\n";
+}
+?>
+--EXPECT--
+Sat 2015-07-04 00:00 → Mon 2015-06-29 00:00
+Sun 2015-07-05 00:00 → Mon 2015-06-29 00:00
+Mon 2015-07-06 00:00 → Mon 2015-07-06 00:00
+Tue 2015-07-07 00:00 → Mon 2015-07-06 00:00
+Wed 2015-07-08 00:00 → Mon 2015-07-06 00:00
+Thu 2015-07-09 00:00 → Mon 2015-07-06 00:00
+Fri 2015-07-10 00:00 → Mon 2015-07-06 00:00
+Sat 2015-07-11 00:00 → Mon 2015-07-06 00:00
+Sun 2015-07-12 00:00 → Mon 2015-07-06 00:00
+Mon 2015-07-13 00:00 → Mon 2015-07-13 00:00
+Tue 2015-07-14 00:00 → Mon 2015-07-13 00:00