php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch date-interval-format-fraction.patch for Date/time related Bug #74355

Patch version 2017-04-01 06:27 UTC

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

Developer: for-bugs@hnw.jp

diff -u -r php-7.1.3-orig/ext/date/php_date.c php-7.1.3/ext/date/php_date.c
--- php-7.1.3-orig/ext/date/php_date.c	2017-03-14 22:17:47.000000000 +0900
+++ php-7.1.3/ext/date/php_date.c	2017-04-01 10:25:18.000000000 +0900
@@ -4362,8 +4362,8 @@
 				case 'S': length = slprintf(buffer, 32, "%02" ZEND_LONG_FMT_SPEC, (zend_long) t->s); break;
 				case 's': length = slprintf(buffer, 32, ZEND_LONG_FMT, (zend_long) t->s); break;
 
-				case 'F': length = slprintf(buffer, 32, "%06" ZEND_LONG_FMT_SPEC, (zend_long) (t->f * 1000000)); break;
-				case 'f': length = slprintf(buffer, 32, ZEND_LONG_FMT, (zend_long) (t->f * 1000000)); break;
+				case 'F': length = slprintf(buffer, 32, "%06" ZEND_LONG_FMT_SPEC, (zend_long) (t->f * 1000000 + 0.5)); break;
+				case 'f': length = slprintf(buffer, 32, ZEND_LONG_FMT, (zend_long) (t->f * 1000000 + 0.5)); break;
 
 				case 'a': {
 					if ((int) t->days != -99999) {
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 18:02:40 2024 UTC