+ /**
+ * This test checks wfTimestamp() with values outside.
+ * It needs PHP 64 bits or PHP > 5.1.
+ * See r74778 and bug 25451
+ */
+ function testOldTimestamps() {
+ $this->assertEquals( 'Fri, 13 Dec 1901 20:45:54 GMT',
+ wfTimestamp( TS_RFC2822, '19011213204554' ),
+ 'Earliest time according to php documentation' );
+
+ $this->assertEquals( 'Tue, 19 Jan 2038 03:14:07 GMT',
+ wfTimestamp( TS_RFC2822, '20380119031407' ),
+ 'Latest 32 bit time' );
+
+ $this->assertEquals( '-2147483648',
+ wfTimestamp( TS_UNIX, '19011213204552' ),
+ 'Earliest 32 bit unix time' );
+
+ $this->assertEquals( '2147483647',
+ wfTimestamp( TS_UNIX, '20380119031407' ),
+ 'Latest 32 bit unix time' );
+
+ $this->assertEquals( 'Fri, 13 Dec 1901 20:45:52 GMT',
+ wfTimestamp( TS_RFC2822, '19011213204552' ),
+ 'Earliest 32 bit time' );
+
+ $this->assertEquals( 'Fri, 13 Dec 1901 20:45:51 GMT',
+ wfTimestamp( TS_RFC2822, '19011213204551' ),
+ 'Earliest 32 bit time - 1' );
+
+ $this->assertEquals( 'Tue, 19 Jan 2038 03:14:08 GMT',
+ wfTimestamp( TS_RFC2822, '20380119031408' ),
+ 'Latest 32 bit time + 1' );
+
+ $this->assertEquals( '19011212000000',
+ wfTimestamp(TS_MW, '19011212000000'),
+ 'Convert to itself r74778#c10645' );
+
+ $this->assertEquals( '-2147483649',
+ wfTimestamp( TS_UNIX, '19011213204551' ),
+ 'Earliest 32 bit unix time - 1' );
+
+ $this->assertEquals( '2147483648',
+ wfTimestamp( TS_UNIX, '20380119031408' ),
+ 'Latest 32 bit unix time + 1' );
+
+ $this->assertEquals( '19011213204551',
+ wfTimestamp( TS_MW, '-2147483649' ),
+ '1901 negative unix time to MediaWiki' );
+
+ $this->assertEquals( '18010115123456',
+ wfTimestamp( TS_MW, '-5331871504' ),
+ '1801 negative unix time to MediaWiki' );
+
+ $this->assertEquals( 'Tue, 09 Aug 0117 12:34:56 GMT',
+ wfTimestamp( TS_RFC2822, '0117-08-09 12:34:56'),
+ 'Death of Roman Emperor [[Trajan]]');
+
+ /* FIXME: 00 to 101 years are taken as being in [1970-2069] */
+
+ $this->assertEquals( 'Sun, 01 Jan 0101 00:00:00 GMT',
+ wfTimestamp( TS_RFC2822, '-58979923200'),
+ '1/1/101');
+
+ $this->assertEquals( 'Mon, 01 Jan 0001 00:00:00 GMT',
+ wfTimestamp( TS_RFC2822, '-62135596800'),
+ 'Year 1');
+
+ /* It is not clear if we should generate a year 0 or not
+ * We are completely off RFC2822 requirement of year being
+ * 1900 or later.
+ */
+ $this->assertEquals( 'Wed, 18 Oct 0000 00:00:00 GMT',
+ wfTimestamp( TS_RFC2822, '-62142076800'),
+ 'ISO 8601:2004 [[year 0]], also called [[1 BC]]');
+ }
+