Created
June 25, 2009 09:33
-
-
Save anonymous/135766 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- php-4.4.9,orig/ext/standard/datetime.c 2007-12-31 16:22:52.000000000 +0900 | |
+++ php-4.4.9/ext/standard/datetime.c 2009-06-25 17:34:56.000000000 +0900 | |
@@ -288,6 +288,8 @@ | |
struct tm *ta, tmbuf; | |
int i, size = 0, length, h, beat, fd, wd, yd, wk; | |
char tmp_buff[32]; | |
+ int warning_flg = 0, ampm_flg = 0; | |
+ | |
#if !HAVE_TM_GMTOFF | |
long tzone; | |
char *tname[2]= {"GMT Standard Time", "BST"}; | |
@@ -386,18 +388,27 @@ | |
size += 3; | |
break; | |
case 'y': /* year, numeric, 2 digits */ | |
+ size += 2; | |
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could you double-check the 'y' format!! You defined the \"%s\". Year returns 2 digits.", Z_STRVAL_PP(format)); | |
+ break; | |
+ case 'h': /* hour, numeric, 12 hour format */ | |
+ case 'g': /* hour, numeric, 12 hour format, no leading zeroes */ | |
+ size += 2; | |
+ warning_flg = 1; | |
+ break; | |
+ case 'A': /* AM/PM */ | |
+ case 'a': /* am/pm */ | |
+ size += 2; | |
+ ampm_flg = 1; | |
+ break; | |
case 'm': /* month, numeric */ | |
case 'n': /* month, numeric, no leading zeroes */ | |
case 'd': /* day of the month, numeric */ | |
case 'j': /* day of the month, numeric, no leading zeros */ | |
case 'H': /* hour, numeric, 24 hour format */ | |
- case 'h': /* hour, numeric, 12 hour format */ | |
case 'G': /* hour, numeric, 24 hour format, no leading zeroes */ | |
- case 'g': /* hour, numeric, 12 hour format, no leading zeroes */ | |
case 'i': /* minutes, numeric */ | |
case 's': /* seconds, numeric */ | |
- case 'A': /* AM/PM */ | |
- case 'a': /* am/pm */ | |
case 'S': /* standard english suffix for the day of the month (e.g. 3rd, 2nd, etc) */ | |
case 't': /* days in current month */ | |
case 'W': /* ISO-8601 week number of year, weeks starting on Monday */ | |
@@ -418,6 +429,10 @@ | |
} | |
} | |
+ if (warning_flg && !ampm_flg) { | |
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could you double-check the 'g' or 'h' format!! You defined the \"%s\". Hour returns 12 hour format.", Z_STRVAL_PP(format)); | |
+ } | |
+ | |
Z_STRVAL_P(return_value) = (char *) emalloc(size + 1); | |
Z_STRVAL_P(return_value)[0] = '\0'; | |
--- php-5.2.10,orig/ext/date/php_date.c 2009-06-06 07:34:30.000000000 +0900 | |
+++ php-5.2.10/ext/date/php_date.c 2009-06-25 17:57:53.000000000 +0900 | |
@@ -743,6 +743,7 @@ | |
timelib_time_offset *offset = NULL; | |
timelib_sll isoweek, isoyear; | |
int rfc_colon; | |
+ int warning_flg = 0, ampm_flg = 0; | |
if (!format_len) { | |
return estrdup(""); | |
@@ -797,12 +798,15 @@ | |
/* year */ | |
case 'L': length = slprintf(buffer, 32, "%d", timelib_is_leap((int) t->y)); break; | |
- case 'y': length = slprintf(buffer, 32, "%02d", (int) t->y % 100); break; | |
+ case 'y': | |
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could you double-check the 'y' format!! You defined the \"%s\". Year returns 2 digits.", format); | |
+ length = slprintf(buffer, 32, "%02d", (int) t->y % 100); | |
+ break; | |
case 'Y': length = slprintf(buffer, 32, "%s%04ld", t->y < 0 ? "-" : "", llabs(t->y)); break; | |
/* time */ | |
- case 'a': length = slprintf(buffer, 32, "%s", t->h >= 12 ? "pm" : "am"); break; | |
- case 'A': length = slprintf(buffer, 32, "%s", t->h >= 12 ? "PM" : "AM"); break; | |
+ case 'a': length = slprintf(buffer, 32, "%s", t->h >= 12 ? "pm" : "am"); ampm_flg = 1; break; | |
+ case 'A': length = slprintf(buffer, 32, "%s", t->h >= 12 ? "PM" : "AM"); ampm_flg = 1; break; | |
case 'B': { | |
int retval = (((((long)t->sse)-(((long)t->sse) - ((((long)t->sse) % 86400) + 3600))) * 10) / 864); | |
while (retval < 0) { | |
@@ -812,9 +816,9 @@ | |
length = slprintf(buffer, 32, "%03d", retval); | |
break; | |
} | |
- case 'g': length = slprintf(buffer, 32, "%d", (t->h % 12) ? (int) t->h % 12 : 12); break; | |
+ case 'g': length = slprintf(buffer, 32, "%d", (t->h % 12) ? (int) t->h % 12 : 12); warning_flg = 1; break; | |
case 'G': length = slprintf(buffer, 32, "%d", (int) t->h); break; | |
- case 'h': length = slprintf(buffer, 32, "%02d", (t->h % 12) ? (int) t->h % 12 : 12); break; | |
+ case 'h': length = slprintf(buffer, 32, "%02d", (t->h % 12) ? (int) t->h % 12 : 12); warning_flg = 1; break; | |
case 'H': length = slprintf(buffer, 32, "%02d", (int) t->h); break; | |
case 'i': length = slprintf(buffer, 32, "%02d", (int) t->i); break; | |
case 's': length = slprintf(buffer, 32, "%02d", (int) t->s); break; | |
@@ -880,6 +884,10 @@ | |
smart_str_appendl(&string, buffer, length); | |
} | |
+ if (warning_flg && !ampm_flg) { | |
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could you double-check the 'g' or 'h' format!! You defined the \"%s\". Hour returns 12 hour format.", format); | |
+ } | |
+ | |
smart_str_0(&string); | |
if (localtime) { | |
@@ -997,7 +1005,10 @@ | |
/* year */ | |
case 'L': retval = (int) timelib_is_leap((int) t->y); break; | |
- case 'y': retval = (int) (t->y % 100); break; | |
+ case 'y': | |
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could you double-check the 'y' format!! You defined the \"%c\". Year returns 2 digits.", format); | |
+ retval = (int) (t->y % 100); | |
+ break; | |
case 'Y': retval = (int) t->y; break; | |
/* Swatch Beat a.k.a. Internet Time */ | |
@@ -1010,7 +1021,10 @@ | |
break; | |
/* time */ | |
- case 'g': case 'h': retval = (int) ((t->h % 12) ? (int) t->h % 12 : 12); break; | |
+ case 'g': case 'h': | |
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could you double-check the 'g' or 'h' format!! You defined the \"%c\". Hour returns 12 hour format.", format); | |
+ retval = (int) ((t->h % 12) ? (int) t->h % 12 : 12); | |
+ break; | |
case 'H': case 'G': retval = (int) t->h; break; | |
case 'i': retval = (int) t->i; break; | |
case 's': retval = (int) t->s; break; | |
--- php-5.3.0RC4,orig/ext/date/php_date.c 2009-06-18 02:56:17.000000000 +0900 | |
+++ php-5.3.0RC4/ext/date/php_date.c 2009-06-25 18:11:47.000000000 +0900 | |
@@ -995,6 +995,7 @@ | |
timelib_time_offset *offset = NULL; | |
timelib_sll isoweek, isoyear; | |
int rfc_colon; | |
+ int warning_flg = 0, ampm_flg = 0; | |
if (!format_len) { | |
return estrdup(""); | |
@@ -1049,12 +1050,15 @@ | |
/* year */ | |
case 'L': length = slprintf(buffer, 32, "%d", timelib_is_leap((int) t->y)); break; | |
- case 'y': length = slprintf(buffer, 32, "%02d", (int) t->y % 100); break; | |
+ case 'y': | |
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could you double-check the 'y' format!! You defined the \"%s\". Year returns 2 digits.", format); | |
+ length = slprintf(buffer, 32, "%02d", (int) t->y % 100); | |
+ break; | |
case 'Y': length = slprintf(buffer, 32, "%s%04ld", t->y < 0 ? "-" : "", llabs((timelib_sll) t->y)); break; | |
/* time */ | |
- case 'a': length = slprintf(buffer, 32, "%s", t->h >= 12 ? "pm" : "am"); break; | |
- case 'A': length = slprintf(buffer, 32, "%s", t->h >= 12 ? "PM" : "AM"); break; | |
+ case 'a': length = slprintf(buffer, 32, "%s", t->h >= 12 ? "pm" : "am"); ampm_flg = 1; break; | |
+ case 'A': length = slprintf(buffer, 32, "%s", t->h >= 12 ? "PM" : "AM"); ampm_flg = 1; break; | |
case 'B': { | |
int retval = (((((long)t->sse)-(((long)t->sse) - ((((long)t->sse) % 86400) + 3600))) * 10) / 864); | |
while (retval < 0) { | |
@@ -1064,9 +1068,9 @@ | |
length = slprintf(buffer, 32, "%03d", retval); | |
break; | |
} | |
- case 'g': length = slprintf(buffer, 32, "%d", (t->h % 12) ? (int) t->h % 12 : 12); break; | |
+ case 'g': length = slprintf(buffer, 32, "%d", (t->h % 12) ? (int) t->h % 12 : 12); warning_flg = 1; break; | |
case 'G': length = slprintf(buffer, 32, "%d", (int) t->h); break; | |
- case 'h': length = slprintf(buffer, 32, "%02d", (t->h % 12) ? (int) t->h % 12 : 12); break; | |
+ case 'h': length = slprintf(buffer, 32, "%02d", (t->h % 12) ? (int) t->h % 12 : 12); warning_flg = 1; break; | |
case 'H': length = slprintf(buffer, 32, "%02d", (int) t->h); break; | |
case 'i': length = slprintf(buffer, 32, "%02d", (int) t->i); break; | |
case 's': length = slprintf(buffer, 32, "%02d", (int) t->s); break; | |
@@ -1132,6 +1136,10 @@ | |
smart_str_appendl(&string, buffer, length); | |
} | |
+ if (warning_flg && !ampm_flg) { | |
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could you double-check the 'g' or 'h' format!! You defined the \"%s\". Hour returns 12 hour format.", format); | |
+ } | |
+ | |
smart_str_0(&string); | |
if (localtime) { | |
@@ -1249,7 +1257,10 @@ | |
/* year */ | |
case 'L': retval = (int) timelib_is_leap((int) t->y); break; | |
- case 'y': retval = (int) (t->y % 100); break; | |
+ case 'y': | |
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could you double-check the 'y' format!! You defined the \"%c\". Year returns 2 digits.", format); | |
+ retval = (int) (t->y % 100); | |
+ break; | |
case 'Y': retval = (int) t->y; break; | |
/* Swatch Beat a.k.a. Internet Time */ | |
@@ -1262,7 +1273,10 @@ | |
break; | |
/* time */ | |
- case 'g': case 'h': retval = (int) ((t->h % 12) ? (int) t->h % 12 : 12); break; | |
+ case 'g': case 'h': | |
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could you double-check the 'g' or 'h' format!! You defined the \"%c\". Hour returns 12 hour format.", format); | |
+ retval = (int) ((t->h % 12) ? (int) t->h % 12 : 12); | |
+ break; | |
case 'H': case 'G': retval = (int) t->h; break; | |
case 'i': retval = (int) t->i; break; | |
case 's': retval = (int) t->s; break; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment