summaryrefslogtreecommitdiff
path: root/ext/date/tests
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 00:39:08 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 00:39:08 -0400
commit993e1866df547532a05ab6db76c9ff5aefc9a3df (patch)
tree169d3bde0974235d3cde164786ef6f381a4749a7 /ext/date/tests
parent1f589a2bd44ba835ad1b009a5d83abd453724829 (diff)
downloadphp-upstream/5.2.6.tar.gz
Imported Upstream version 5.2.6upstream/5.2.6
Diffstat (limited to 'ext/date/tests')
-rw-r--r--ext/date/tests/bug40743.phpt40
-rw-r--r--ext/date/tests/bug41523-64bit.phpt47
-rw-r--r--ext/date/tests/bug41523.phpt4
-rw-r--r--ext/date/tests/bug41599.phpt27
-rw-r--r--ext/date/tests/bug42910.phpt30
-rw-r--r--ext/date/tests/bug43003.phpt27
-rw-r--r--ext/date/tests/bug43527.phpt10
-rw-r--r--ext/date/tests/bug43808.phpt14
-rw-r--r--ext/date/tests/bug44742.phpt36
-rw-r--r--ext/date/tests/mktime-3-64bit.phpt56
-rw-r--r--ext/date/tests/mktime-3.phpt4
-rw-r--r--ext/date/tests/oo_002.phpt2
-rw-r--r--ext/date/tests/strtotime-mysql-64bit.phpt28
-rwxr-xr-xext/date/tests/strtotime-mysql.phpt4
-rw-r--r--ext/date/tests/strtotime3-64bit.phpt71
-rw-r--r--ext/date/tests/strtotime3.phpt4
-rw-r--r--ext/date/tests/timestamp-in-dst.phpt11
17 files changed, 410 insertions, 5 deletions
diff --git a/ext/date/tests/bug40743.phpt b/ext/date/tests/bug40743.phpt
new file mode 100644
index 000000000..f3ce17124
--- /dev/null
+++ b/ext/date/tests/bug40743.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Bug #40743 (DateTime ignores the TimeZone object passed to the constructor)
+--FILE--
+<?php
+$dt = new DateTime('@1200506699', new DateTimeZone('Europe/Berlin'));
+echo $dt->format(DATE_RFC822), "\n";
+echo $dt->format('T e Z'), "\n";
+echo "-----\n";
+
+date_default_timezone_set('America/New_York');
+
+$dt = new DateTime('16 Jan 08 13:04:59');
+echo $dt->format(DATE_RFC822 . " e T O U"), "\n";
+
+$dt = new DateTime('@1200506699');
+echo $dt->format(DATE_RFC822 . " e T O U"), "\n";
+
+$dt = new DateTime('@1200506699');
+$dt->setTimezone( new DateTimeZone( 'America/New_York' ) );
+echo $dt->format(DATE_RFC822 . " e T O U"), "\n";
+
+$dt = new DateTime('@1200506699', new DateTimeZone('Europe/Berlin'));
+echo $dt->format(DATE_RFC822 . " e T O U"), "\n";
+
+$dt = new DateTime('16 Jan 08 13:04:59 America/Chicago');
+echo $dt->format(DATE_RFC822 . " e T O U"), "\n";
+
+$dt = new DateTime('16 Jan 08 13:04:59 America/Chicago', new DateTimeZone('Europe/Berlin'));
+echo $dt->format(DATE_RFC822 . " e T O U"), "\n";
+?>
+--EXPECT--
+Wed, 16 Jan 08 18:04:59 +0000
+GMT+0000 +00:00 0
+-----
+Wed, 16 Jan 08 13:04:59 -0500 America/New_York EST -0500 1200506699
+Wed, 16 Jan 08 18:04:59 +0000 +00:00 GMT+0000 +0000 1200506699
+Wed, 16 Jan 08 13:04:59 -0500 America/New_York EST -0500 1200506699
+Wed, 16 Jan 08 18:04:59 +0000 +00:00 GMT+0000 +0000 1200506699
+Wed, 16 Jan 08 13:04:59 -0600 America/Chicago CST -0600 1200510299
+Wed, 16 Jan 08 13:04:59 -0600 America/Chicago CST -0600 1200510299
diff --git a/ext/date/tests/bug41523-64bit.phpt b/ext/date/tests/bug41523-64bit.phpt
new file mode 100644
index 000000000..9b4e90061
--- /dev/null
+++ b/ext/date/tests/bug41523-64bit.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Bug #41523 (strtotime('0000-00-00 00:00:00') is parsed as 1999-11-30) (64 bit)
+--SKIPIF--
+<?php echo PHP_INT_SIZE != 8 ? "skip 64-bit only" : "OK"; ?>
+--FILE--
+<?php
+date_default_timezone_set("UTC");
+
+var_dump( date_parse('0000-00-00 00:00:00') );
+var_dump( strtotime('0000-00-00 00:00:00') );
+var_dump( $dt = new DateTime('0000-00-00 00:00:00') );
+echo $dt->format( DateTime::ISO8601 ), "\n";
+
+?>
+--EXPECT--
+array(12) {
+ ["year"]=>
+ int(0)
+ ["month"]=>
+ int(0)
+ ["day"]=>
+ int(0)
+ ["hour"]=>
+ int(0)
+ ["minute"]=>
+ int(0)
+ ["second"]=>
+ int(0)
+ ["fraction"]=>
+ float(0)
+ ["warning_count"]=>
+ int(0)
+ ["warnings"]=>
+ array(0) {
+ }
+ ["error_count"]=>
+ int(0)
+ ["errors"]=>
+ array(0) {
+ }
+ ["is_localtime"]=>
+ bool(false)
+}
+int(-62169984000)
+object(DateTime)#1 (0) {
+}
+-0001-11-30T00:00:00+0000
diff --git a/ext/date/tests/bug41523.phpt b/ext/date/tests/bug41523.phpt
index c8aa00fd7..5b0d5bd19 100644
--- a/ext/date/tests/bug41523.phpt
+++ b/ext/date/tests/bug41523.phpt
@@ -1,5 +1,7 @@
--TEST--
-Bug #41523 (strtotime('0000-00-00 00:00:00') is parsed as 1999-11-30)
+Bug #41523 (strtotime('0000-00-00 00:00:00') is parsed as 1999-11-30) (32 bit)
+--SKIPIF--
+<?php echo PHP_INT_SIZE == 8 ? "skip 32-bit only" : "OK"; ?>
--FILE--
<?php
date_default_timezone_set("UTC");
diff --git a/ext/date/tests/bug41599.phpt b/ext/date/tests/bug41599.phpt
new file mode 100644
index 000000000..e4febe2cd
--- /dev/null
+++ b/ext/date/tests/bug41599.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Bug #41599 (setTime() fails after modify() is used)
+--FILE--
+<?php
+date_default_timezone_set('Europe/London');
+
+$start = new DateTime('2008-01-17 last Monday');
+echo $start->format('Y-m-d H:i:s'),PHP_EOL;
+//good
+
+$start->modify('Tuesday');
+echo $start->format('Y-m-d H:i:s'),PHP_EOL;
+//good
+
+$start->setTime(4, 0, 0);
+echo $start->format('Y-m-d H:i:s'),PHP_EOL;
+//jumped to next Sunday
+
+$start->setTime(8, 0, 0);
+echo $start->format('Y-m-d H:i:s'),PHP_EOL;
+//jumped to next Sunday again
+?>
+--EXPECT--
+2008-01-14 00:00:00
+2008-01-15 00:00:00
+2008-01-15 04:00:00
+2008-01-15 08:00:00
diff --git a/ext/date/tests/bug42910.phpt b/ext/date/tests/bug42910.phpt
new file mode 100644
index 000000000..1bd079081
--- /dev/null
+++ b/ext/date/tests/bug42910.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Bug #42910 (Constructing DateTime with TimeZone Indicator invalidates DateTimeZone)
+--FILE--
+<?php
+ date_default_timezone_set('America/Los_Angeles');
+ $foo = new DateTime('2007-03-11');
+ $bar = new DateTime('2007-03-11T00:00:00-0800');
+
+ print $foo->format(DateTime::ISO8601) . ' - ' . $foo->getTimezone()->getName() . ' - ' . $foo->format('U') . "\r\n";
+ print $bar->format(DateTime::ISO8601) . ' - ' . $bar->getTimezone()->getName() . ' - ' . $bar->format('U') . "\r\n";
+
+ $foo->setDate(2007, 03, 12);
+ $bar->setDate(2007, 03, 12);
+
+ print $foo->format(DateTime::ISO8601) . ' - ' . $foo->getTimezone()->getName() . ' - ' . $foo->format('U') . "\r\n";
+ print $bar->format(DateTime::ISO8601) . ' - ' . $bar->getTimezone()->getName() . ' - ' . $bar->format('U') . "\r\n";
+
+// --------------
+
+ date_default_timezone_set('Australia/Sydney');
+
+ $date= date_create('2007-11-04 12:00:00+0200');
+ var_dump(date_format($date, 'O e'));
+?>
+--EXPECT--
+2007-03-11T00:00:00-0800 - America/Los_Angeles - 1173600000
+2007-03-11T00:00:00-0800 - -08:00 - 1173600000
+2007-03-12T00:00:00-0700 - America/Los_Angeles - 1173682800
+2007-03-12T00:00:00-0800 - -08:00 - 1173686400
+string(12) "+0200 +02:00"
diff --git a/ext/date/tests/bug43003.phpt b/ext/date/tests/bug43003.phpt
new file mode 100644
index 000000000..8070358b9
--- /dev/null
+++ b/ext/date/tests/bug43003.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Bug #43003 (Invalid timezone reported for DateTime objects constructed using a timestamp)
+--FILE--
+<?php
+date_default_timezone_set('Europe/Oslo');
+
+$oDateTest = new DateTime("@0", new DateTimeZone(date_default_timezone_get()));
+echo $oDateTest->getTimezone()->getName().": " . $oDateTest->format("Y-m-d H:i:s")."\n";
+
+$oDateTest->setTimezone(new DateTimeZone("UTC"));
+echo $oDateTest->getTimezone()->getName().": " . $oDateTest->format("Y-m-d H:i:s")."\n";
+
+$oDateTest->setTimezone(new DateTimeZone(date_default_timezone_get()));
+echo $oDateTest->getTimezone()->getName().": " . $oDateTest->format("Y-m-d H:i:s")."\n";
+
+$oDateTest = new DateTime("@0");
+echo $oDateTest->getTimezone()->getName().": " . $oDateTest->format("Y-m-d H:i:s")."\n";
+
+$oDateTest->setTimezone( new DateTimeZone(date_default_timezone_get()));
+echo $oDateTest->getTimezone()->getName().": " . $oDateTest->format("Y-m-d H:i:s")."\n";
+?>
+--EXPECT--
++00:00: 1970-01-01 00:00:00
+UTC: 1970-01-01 00:00:00
+Europe/Oslo: 1970-01-01 01:00:00
++00:00: 1970-01-01 00:00:00
+Europe/Oslo: 1970-01-01 01:00:00
diff --git a/ext/date/tests/bug43527.phpt b/ext/date/tests/bug43527.phpt
new file mode 100644
index 000000000..cc69def7b
--- /dev/null
+++ b/ext/date/tests/bug43527.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Bug #43527 (DateTime created from a timestamp reports environment timezone)
+--FILE--
+<?php
+date_default_timezone_set("Etc/GMT+1");
+$datetime = new DateTime('Fri, 07 Dec 2007 19:05:14 +1000');
+echo $datetime->getTimezone()->getName(), "\n";
+?>
+--EXPECT--
++10:00
diff --git a/ext/date/tests/bug43808.phpt b/ext/date/tests/bug43808.phpt
new file mode 100644
index 000000000..fe8102199
--- /dev/null
+++ b/ext/date/tests/bug43808.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #43808 (date_create never fails (even when it should))
+--FILE--
+<?php
+$date = date_create('asdfasdf');
+
+if ($date instanceof DateTime) {
+ echo "this is wrong, should be bool";
+}
+
+var_dump( $date );
+?>
+--EXPECT--
+bool(false)
diff --git a/ext/date/tests/bug44742.phpt b/ext/date/tests/bug44742.phpt
new file mode 100644
index 000000000..48952b4e6
--- /dev/null
+++ b/ext/date/tests/bug44742.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Bug #44742 (timezone_offset_get() causes segmentation faults)
+--FILE--
+<?php
+date_default_timezone_set('Europe/London');
+$dates = array(
+ "2008-04-11 00:00:00+0000",
+ "2008-04-11 00:00:00+0200",
+ "2008-04-11 00:00:00+0330",
+ "2008-04-11 00:00:00-0500",
+ "2008-04-11 00:00:00-1130",
+ "2008-04-11 00:00:00 CEST",
+ "2008-04-11 00:00:00 CET",
+ "2008-04-11 00:00:00 UTC",
+ "2008-04-11 00:00:00 America/New_York",
+ "2008-04-11 00:00:00 Europe/Oslo",
+ "2008-04-11 00:00:00 Asia/Singapore",
+);
+foreach ($dates as $date)
+{
+ $date = date_create($date);
+ var_dump(timezone_offset_get(date_timezone_get($date), $date));
+}
+?>
+--EXPECT--
+int(0)
+int(7200)
+int(12600)
+int(-18000)
+int(-41400)
+int(7200)
+int(3600)
+int(0)
+int(-14400)
+int(7200)
+int(28800)
diff --git a/ext/date/tests/mktime-3-64bit.phpt b/ext/date/tests/mktime-3-64bit.phpt
new file mode 100644
index 000000000..bb3fb2df7
--- /dev/null
+++ b/ext/date/tests/mktime-3-64bit.phpt
@@ -0,0 +1,56 @@
+--TEST--
+mktime() [3] (64-bit)
+--SKIPIF--
+<?php echo PHP_INT_SIZE != 8 ? "skip 64-bit only" : "OK" ?>
+--INI--
+error_reporting=2047
+--FILE--
+<?php
+$tzs = array("America/Toronto", "Europe/Oslo");
+$years = array(0, 69, 70, 71, 99, 100, 105, 1900, 1901, 1902, 1999, 2000, 2001);
+
+foreach ($tzs as $tz) {
+ echo $tz, "\n";
+ date_default_timezone_set($tz);
+ foreach ($years as $year) {
+ printf("Y: %4d - ", $year);
+ $ret = mktime(1, 1, 1, 1, 1, $year);
+ if ($ret == FALSE) {
+ echo "out of range\n";
+ } else {
+ echo date("F ".DATE_ISO8601, $ret), "\n";
+ }
+ }
+ echo "\n";
+}
+?>
+--EXPECT--
+America/Toronto
+Y: 0 - January 2000-01-01T01:01:01-0500
+Y: 69 - January 2069-01-01T01:01:01-0500
+Y: 70 - January 1970-01-01T01:01:01-0500
+Y: 71 - January 1971-01-01T01:01:01-0500
+Y: 99 - January 1999-01-01T01:01:01-0500
+Y: 100 - January 2000-01-01T01:01:01-0500
+Y: 105 - January 2005-01-01T01:01:01-0500
+Y: 1900 - January 1900-01-01T01:01:01-0500
+Y: 1901 - January 1901-01-01T01:01:01-0500
+Y: 1902 - January 1902-01-01T01:01:01-0500
+Y: 1999 - January 1999-01-01T01:01:01-0500
+Y: 2000 - January 2000-01-01T01:01:01-0500
+Y: 2001 - January 2001-01-01T01:01:01-0500
+
+Europe/Oslo
+Y: 0 - January 2000-01-01T01:01:01+0100
+Y: 69 - January 2069-01-01T01:01:01+0100
+Y: 70 - January 1970-01-01T01:01:01+0100
+Y: 71 - January 1971-01-01T01:01:01+0100
+Y: 99 - January 1999-01-01T01:01:01+0100
+Y: 100 - January 2000-01-01T01:01:01+0100
+Y: 105 - January 2005-01-01T01:01:01+0100
+Y: 1900 - January 1900-01-01T01:01:01+0100
+Y: 1901 - January 1901-01-01T01:01:01+0100
+Y: 1902 - January 1902-01-01T01:01:01+0100
+Y: 1999 - January 1999-01-01T01:01:01+0100
+Y: 2000 - January 2000-01-01T01:01:01+0100
+Y: 2001 - January 2001-01-01T01:01:01+0100
diff --git a/ext/date/tests/mktime-3.phpt b/ext/date/tests/mktime-3.phpt
index 0d19074fc..3201def6c 100644
--- a/ext/date/tests/mktime-3.phpt
+++ b/ext/date/tests/mktime-3.phpt
@@ -1,5 +1,7 @@
--TEST--
-mktime() [3]
+mktime() [3] (32-bit)
+--SKIPIF--
+<?php echo PHP_INT_SIZE == 8 ? "skip 32-bit only" : "OK" ?>
--INI--
error_reporting=2047
--FILE--
diff --git a/ext/date/tests/oo_002.phpt b/ext/date/tests/oo_002.phpt
index e619d9dfe..0cd9187b1 100644
--- a/ext/date/tests/oo_002.phpt
+++ b/ext/date/tests/oo_002.phpt
@@ -6,7 +6,7 @@ date.timezone=Europe/Berlin
<?php
class _d extends DateTime {}
class _t extends DateTimeZone {}
-$d = new _d("1pm Aug 1 GMT");
+$d = new _d("1pm Aug 1 GMT 2007");
var_dump($d->format(DateTime::RFC822));
$c = clone $d;
var_dump($c->format(DateTime::RFC822));
diff --git a/ext/date/tests/strtotime-mysql-64bit.phpt b/ext/date/tests/strtotime-mysql-64bit.phpt
new file mode 100644
index 000000000..38e7f15df
--- /dev/null
+++ b/ext/date/tests/strtotime-mysql-64bit.phpt
@@ -0,0 +1,28 @@
+--TEST--
+strtotime() and mysql timestamps (64 bit)
+--SKIPIF--
+<?php echo PHP_INT_SIZE != 8 ? "skip 64-bit only" : "OK"; ?>
+--FILE--
+<?php
+date_default_timezone_set('UTC');
+
+/* Format: YYYYMMDDHHMMSS */
+$d[] = '19970523091528';
+$d[] = '20001231185859';
+$d[] = '20800410101010'; // overflow..
+
+foreach($d as $date) {
+ $time = strtotime($date);
+
+ if (is_integer($time)) {
+ var_dump(date('r', $time));
+ } else {
+ var_dump($time);
+ }
+}
+?>
+--EXPECT--
+string(31) "Fri, 23 May 1997 09:15:28 +0000"
+string(31) "Sun, 31 Dec 2000 18:58:59 +0000"
+string(31) "Wed, 10 Apr 2080 10:10:10 +0000"
+
diff --git a/ext/date/tests/strtotime-mysql.phpt b/ext/date/tests/strtotime-mysql.phpt
index 88a8f10fe..e5935bb16 100755
--- a/ext/date/tests/strtotime-mysql.phpt
+++ b/ext/date/tests/strtotime-mysql.phpt
@@ -1,5 +1,7 @@
--TEST--
-strtotime() and mysql timestamps
+strtotime() and mysql timestamps (32 bit)
+--SKIPIF--
+<?php echo PHP_INT_SIZE == 8 ? "skip 32-bit only" : "OK"; ?>
--FILE--
<?php
date_default_timezone_set('UTC');
diff --git a/ext/date/tests/strtotime3-64bit.phpt b/ext/date/tests/strtotime3-64bit.phpt
new file mode 100644
index 000000000..7dc081635
--- /dev/null
+++ b/ext/date/tests/strtotime3-64bit.phpt
@@ -0,0 +1,71 @@
+--TEST--
+strtotime() function (64 bit)
+--SKIPIF--
+<?php echo PHP_INT_SIZE != 8 ? "skip 64-bit only" : "OK"; ?>
+--FILE--
+<?php
+date_default_timezone_set('Europe/Lisbon');
+$time = 1150494719; // 16/June/2006
+
+$strs = array(
+ '',
+ " \t\r\n000",
+ 'yesterday',
+ '22:49:12',
+ '22:49:12 bogusTZ',
+ '22.49.12.42GMT',
+ '22.49.12.42bogusTZ',
+ 't0222',
+ 't0222 t0222',
+ '022233',
+ '022233 bogusTZ',
+ '2-3-2004',
+ '2.3.2004',
+ '20060212T23:12:23UTC',
+ '20060212T23:12:23 bogusTZ',
+ '2006167', //pgydotd
+ 'Jan-15-2006', //pgtextshort
+ '2006-Jan-15', //pgtextreverse
+ '10/Oct/2000:13:55:36 +0100', //clf
+ '10/Oct/2000:13:55:36 +00100', //clf
+ '2006',
+ '1986', // year
+ 'JAN',
+ 'January',
+);
+
+foreach ($strs as $str) {
+ $t = strtotime($str, $time);
+ if (is_integer($t)) {
+ var_dump(date(DATE_RFC2822, $t));
+ } else {
+ var_dump($t);
+ }
+}
+
+?>
+--EXPECT--
+bool(false)
+bool(false)
+string(31) "Thu, 15 Jun 2006 00:00:00 +0100"
+string(31) "Fri, 16 Jun 2006 22:49:12 +0100"
+bool(false)
+string(31) "Fri, 16 Jun 2006 23:49:12 +0100"
+bool(false)
+string(31) "Fri, 16 Jun 2006 02:22:00 +0100"
+string(31) "Mon, 16 Jun 0222 02:22:00 -0036"
+string(31) "Fri, 16 Jun 2006 02:22:33 +0100"
+bool(false)
+string(31) "Tue, 02 Mar 2004 00:00:00 +0000"
+string(31) "Tue, 02 Mar 2004 00:00:00 +0000"
+string(31) "Sun, 12 Feb 2006 23:12:23 +0000"
+bool(false)
+string(31) "Fri, 16 Jun 2006 00:00:00 +0100"
+string(31) "Sun, 15 Jan 2006 00:00:00 +0000"
+string(31) "Sun, 15 Jan 2006 00:00:00 +0000"
+string(31) "Tue, 10 Oct 2000 13:55:36 +0100"
+bool(false)
+string(31) "Fri, 16 Jun 2006 20:06:00 +0100"
+string(31) "Mon, 16 Jun 1986 22:51:59 +0100"
+string(31) "Mon, 16 Jan 2006 00:00:00 +0000"
+string(31) "Mon, 16 Jan 2006 00:00:00 +0000"
diff --git a/ext/date/tests/strtotime3.phpt b/ext/date/tests/strtotime3.phpt
index c5d13d8a6..6aa5640f6 100644
--- a/ext/date/tests/strtotime3.phpt
+++ b/ext/date/tests/strtotime3.phpt
@@ -1,5 +1,7 @@
--TEST--
-strtotime() function
+strtotime() function (32 bit)
+--SKIPIF--
+<?php echo PHP_INT_SIZE == 8 ? "skip 32-bit only" : "OK"; ?>
--FILE--
<?php
date_default_timezone_set('Europe/Lisbon');
diff --git a/ext/date/tests/timestamp-in-dst.phpt b/ext/date/tests/timestamp-in-dst.phpt
new file mode 100644
index 000000000..5b66351e1
--- /dev/null
+++ b/ext/date/tests/timestamp-in-dst.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Format timestamp in DST test
+--INI--
+date.timezone=CEST
+--FILE--
+<?php
+error_reporting(E_ALL); // hide e_strict warning about timezones
+var_dump( date_create( '@1202996091' )->format( 'c' ) );
+?>
+--EXPECT--
+string(25) "2008-02-14T13:34:51+00:00"