]> granicus.if.org Git - php/commitdiff
Fix for bug #1750.
authorAndrey Hristov <andrey@php.net>
Tue, 20 Jul 1999 16:59:30 +0000 (16:59 +0000)
committerAndrey Hristov <andrey@php.net>
Tue, 20 Jul 1999 16:59:30 +0000 (16:59 +0000)
ext/standard/datetime.c

index 9be3bc80ae69aca5b5de3ae4d3e5d29d24ce9adf..4b19f459e9029ef032111118a2666da6cc842bc5 100644 (file)
@@ -197,6 +197,8 @@ _php3_date(INTERNAL_FUNCTION_PARAMETERS, int gm)
                        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 */
@@ -278,6 +280,15 @@ _php3_date(INTERNAL_FUNCTION_PARAMETERS, int gm)
                                sprintf(tmp_buff, "%02d", h);  /* SAFE */
                                strcat(return_value->value.str.val, tmp_buff);
                                break;
+                       case 'G':      /* hour, numeric, 24 hour format, no leading zeros */
+                               sprintf(tmp_buff, "%d", ta->tm_hour);  /* SAFE */
+                               strcat(return_value->value.str.val, tmp_buff);
+                               break;
+                       case 'g':      /* hour, numeric, 12 hour format, no leading zeros */
+                               h = ta->tm_hour % 12; if (h==0) h = 12;
+                               sprintf(tmp_buff, "%d", h);  /* SAFE */
+                               strcat(return_value->value.str.val, tmp_buff);
+                               break;
                        case 'i':               /* minutes, numeric */
                                sprintf(tmp_buff, "%02d", ta->tm_min);  /* SAFE */
                                strcat(return_value->value.str.val, tmp_buff);