]> granicus.if.org Git - php/commitdiff
- MFH: Fixed DateTime::setTimestamp() and added a test for it.
authorDerick Rethans <derick@php.net>
Sun, 27 Jul 2008 19:10:23 +0000 (19:10 +0000)
committerDerick Rethans <derick@php.net>
Sun, 27 Jul 2008 19:10:23 +0000 (19:10 +0000)
NEWS
ext/date/php_date.c
ext/date/tests/date-set-timestamp.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index c59421e68e156cd4e441fcddeb07b4d344c75560..744c04c454b77eaf8fb764f7c19280445a7a5ddc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -178,7 +178,7 @@ PHP                                                                        NEWS
   . timezone_location_get() / DateTimezone::getLocation() for retrieving
     location information from timezones.
   . date_timestamp_set() / DateTime::setTimestamp() to set a Unix timestamp
-    without invoking the date parser. (Scott)
+    without invoking the date parser. (Scott, Derick)
   . date_timestamp_get() / DateTime::getTimestamp() to retrieve the Unix
     timestamp belonging to a date object.
   . two optional parameters to timezone_transitions_get() /
index e37039df36e433ad04ed95978ae6740cd2599a71..04466a1e5342340c8e14b71269d000bbc53fcbdc 100644 (file)
@@ -3063,7 +3063,7 @@ PHP_FUNCTION(date_timestamp_set)
        }
        dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC);
        DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
-       timelib_unixtime2gmt(dateobj->time, (timelib_sll)timestamp);
+       timelib_unixtime2local(dateobj->time, (timelib_sll)timestamp);
        timelib_update_ts(dateobj->time, NULL);
 }
 /* }}} */
diff --git a/ext/date/tests/date-set-timestamp.phpt b/ext/date/tests/date-set-timestamp.phpt
new file mode 100644 (file)
index 0000000..5819e09
--- /dev/null
@@ -0,0 +1,17 @@
+--TEST--
+DateTime::setTimestamp()
+--INI--
+date.timezone=Europe/Oslo
+--FILE--
+<?php
+$d = new DateTime( '@1217184864' );
+echo $d->format( "Y-m-d H:i e\n" );
+
+$d = new DateTime();
+$d->setTimestamp( 1217184864 );
+echo $d->format( "Y-m-d H:i e\n" );
+?>
+--EXPECT--
+2008-07-27
+2008-07-27 18:54 +00:00
+2008-07-27 20:54 Europe/Oslo