php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #55015
Patch calc_rel_weekday_after_month_year_test revision 2011-07-06 06:08 UTC by lonnyk at gmail dot com
Patch calc_rel_weekday_after_month_year revision 2011-07-06 06:08 UTC by lonnyk at gmail dot com

Patch calc_rel_weekday_after_month_year for Date/time related Bug #55015

Patch version 2011-07-06 06:08 UTC

Return to Bug #55015 | Download this patch
Patch Revisions:

Developer: lonnyk@gmail.com

Index: ext/date/lib/tm2unixtime.c
===================================================================
--- ext/date/lib/tm2unixtime.c	(revision 312976)
+++ ext/date/lib/tm2unixtime.c	(working copy)
@@ -192,19 +192,22 @@
 
 static void do_adjust_relative(timelib_time* time)
 {
-	if (time->relative.have_weekday_relative) {
-		do_adjust_for_weekday(time);
-	}
-	do_normalize(time);
-
 	if (time->have_relative) {
 		time->s += time->relative.s;
 		time->i += time->relative.i;
 		time->h += time->relative.h;
 
-		time->d += time->relative.d;
 		time->m += time->relative.m;
 		time->y += time->relative.y;
+
+                if (time->relative.have_weekday_relative) {
+                    /* Relative weekdays are calculated after we change month/year b/c weekdays change every month/yr. */
+                    do_normalize(time);
+                    do_adjust_for_weekday(time);
+                    do_normalize(time);
+                }
+
+                time->d += time->relative.d;
 	}
 	switch (time->relative.first_last_day_of) {
 		case 1: /* first */
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 30 01:01:28 2024 UTC