Skip to content

Instantly share code, notes, and snippets.

/gist:135202
Created Jun 24, 2009

Embed
What would you like to do?
--- 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-24 15:26:05.000000000 +0900
@@ -376,6 +376,7 @@
case 'O': /* GMT offset in [+-]HHMM format */
size += 5;
break;
+ case 'y': /* year, numeric, 4 digits */
case 'Y': /* year, numeric, 4 digits */
size += 4;
break;
@@ -385,7 +386,6 @@
case 'B': /* Swatch Beat, 3 digits */
size += 3;
break;
- case 'y': /* year, numeric, 2 digits */
case 'm': /* month, numeric */
case 'n': /* month, numeric, no leading zeroes */
case 'd': /* day of the month, numeric */
@@ -442,6 +442,7 @@
case 'l': /* day (of the week), textual, full */
strcat(Z_STRVAL_P(return_value), day_full_names[ta->tm_wday]);
break;
+ case 'y': /* year, numeric, 4 digits */
case 'Y': /* year, numeric, 4 digits */
sprintf(tmp_buff, "%d", ta->tm_year + YEAR_BASE); /* SAFE */
strcat(Z_STRVAL_P(return_value), tmp_buff);
@@ -456,10 +457,6 @@
sprintf(tmp_buff, "%d", ta->tm_yday); /* SAFE */
strcat(Z_STRVAL_P(return_value), tmp_buff);
break;
- case 'y': /* year, numeric, 2 digits */
- sprintf(tmp_buff, "%02d", ((ta->tm_year)%100)); /* SAFE */
- strcat(Z_STRVAL_P(return_value), tmp_buff);
- break;
case 'm': /* month, numeric */
sprintf(tmp_buff, "%02d", ta->tm_mon + 1); /* SAFE */
strcat(Z_STRVAL_P(return_value), tmp_buff);
@@ -476,15 +473,11 @@
sprintf(tmp_buff, "%d", ta->tm_mday); /* SAFE */
strcat(Z_STRVAL_P(return_value), tmp_buff);
break;
+ case 'h': /* hour, numeric, 24 hour format */
case 'H': /* hour, numeric, 24 hour format */
sprintf(tmp_buff, "%02d", ta->tm_hour); /* SAFE */
strcat(Z_STRVAL_P(return_value), tmp_buff);
break;
- case 'h': /* hour, numeric, 12 hour format */
- h = ta->tm_hour % 12; if (h==0) h = 12;
- sprintf(tmp_buff, "%02d", h); /* SAFE */
- strcat(Z_STRVAL_P(return_value), tmp_buff);
- break;
case 'G': /* hour, numeric, 24 hour format, no leading zeros */
sprintf(tmp_buff, "%d", ta->tm_hour); /* SAFE */
strcat(Z_STRVAL_P(return_value), tmp_buff);
--- 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-24 15:20:41.000000000 +0900
@@ -797,7 +797,7 @@
/* 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':
case 'Y': length = slprintf(buffer, 32, "%s%04ld", t->y < 0 ? "-" : "", llabs(t->y)); break;
/* time */
@@ -814,7 +814,7 @@
}
case 'g': length = slprintf(buffer, 32, "%d", (t->h % 12) ? (int) t->h % 12 : 12); 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':
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;
--- 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-24 15:22:09.000000000 +0900
@@ -1049,7 +1049,7 @@
/* 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':
case 'Y': length = slprintf(buffer, 32, "%s%04ld", t->y < 0 ? "-" : "", llabs((timelib_sll) t->y)); break;
/* time */
@@ -1066,7 +1066,7 @@
}
case 'g': length = slprintf(buffer, 32, "%d", (t->h % 12) ? (int) t->h % 12 : 12); 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':
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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.