$output .= ' GMT';
}
+ if ( $style == TS_MW && strlen( $output ) !== 14 ) {
+ throw new TimestampException( __METHOD__ . ': The timestamp cannot be represented in ' .
+ 'the specified format' );
+ }
+
return $output;
}
new MWTimestamp( "This is not a timestamp." );
}
+ /**
+ * Test an out of range timestamp
+ * @dataProvider provideOutOfRangeTimestamps
+ * @expectedException TimestampException
+ * @covers MWTimestamp
+ */
+ public function testOutOfRangeTimestamps( $format, $input ) {
+ $timestamp = new MWTimestamp( $input );
+ $timestamp->getTimestamp( $format );
+ }
+
/**
* Test requesting an invalid output format.
* @expectedException TimestampException
);
}
+ /**
+ * Returns a list of out of range timestamps in the format:
+ * array( type, timestamp_of_type )
+ */
+ public static function provideOutOfRangeTimestamps() {
+ return array(
+ // Various formats
+ array( TS_MW, '-62167219201' ), // -0001-12-31T23:59:59Z
+ array( TS_MW, '253402300800' ), // 10000-01-01T00:00:00Z
+ );
+ }
+
/**
* @dataProvider provideHumanTimestampTests
* @covers MWTimestamp::getHumanTimestamp