12 $this->assertInternalType(
'string',
$timestamp->getTimestamp() );
13 $this->assertNotEmpty(
$timestamp->getTimestamp() );
14 $this->assertNotEquals(
false, strtotime(
$timestamp->getTimestamp(
TS_MW ) ) );
22 $this->assertEquals(
'1406833268',
$timestamp->__toString() );
27 [
'1406833268',
'1406833269',
'00 00 00 01' ],
28 [
'1406833268',
'1406833329',
'00 00 01 01' ],
29 [
'1406833268',
'1406836929',
'00 01 01 01' ],
30 [
'1406833268',
'1406923329',
'01 01 01 01' ],
38 public function testDiff( $timestamp1, $timestamp2, $expected ) {
41 $diff = $timestamp1->diff( $timestamp2 );
42 $this->assertEquals( $expected, $diff->format(
'%D %H %I %S' ) );
62 $this->assertEquals( $expected, (
string)
$timestamp->getTimestamp( $format ) );
78 public function testConvert( $format, $expected, $original ) {
118 [
TS_UNIX,
'1343761268',
'20120731190108' ],
119 [
TS_MW,
'20120731190108',
'20120731190108' ],
120 [
TS_DB,
'2012-07-31 19:01:08',
'20120731190108' ],
121 [
TS_ISO_8601,
'2012-07-31T19:01:08Z',
'20120731190108' ],
123 [
TS_EXIF,
'2012:07:31 19:01:08',
'20120731190108' ],
124 [
TS_RFC2822,
'Tue, 31 Jul 2012 19:01:08 GMT',
'20120731190108' ],
125 [
TS_ORACLE,
'31-07-2012 19:01:08.000000',
'20120731190108' ],
126 [
TS_POSTGRES,
'2012-07-31 19:01:08 GMT',
'20120731190108' ],
128 [
TS_ISO_8601,
'9999-12-31T23:59:59Z',
'99991231235959' ],
129 [
TS_UNIX,
'-62135596801',
'00001231235959' ]
140 [
TS_MW,
'-62167219201' ],
141 [
TS_MW,
'253402300800' ],
Library for creating, parsing, and converting timestamps.
testConvert($format, $expected, $original)
provideValidTimestamps ConvertibleTimestamp::convert
const TS_RFC2822
RFC 2822 format, for E-mail and HTTP headers.
testConvertInvalid()
Format an invalid timestamp.
static provideValidTimestamps()
Returns a list of valid timestamps in the format: [ type, timestamp_of_type, timestamp_in_MW ]...
Tests timestamp parsing and output.
const TS_ISO_8601
ISO 8601 format with no timezone: 1986-02-09T20:00:00Z.
testValidParse($format, $original, $expected)
Test parsing of valid timestamps and outputing to MW format.
testConstructWithNoTimestamp()
ConvertibleTimestamp::__construct.
testInvalidParse()
Test an invalid timestamp.
static provideValidTimestampDifferences()
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
testDiff($timestamp1, $timestamp2, $expected)
provideValidTimestampDifferences ConvertibleTimestamp::diff
testInvalidOutput()
Test requesting an invalid output format.
const TS_EXIF
An Exif timestamp (YYYY:MM:DD HH:MM:SS)
testOutOfRangeTimestamps($format, $input)
Test an out of range timestamp provideOutOfRangeTimestamps TimestampException ConvertibleTimestamp.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
const TS_ISO_8601_BASIC
ISO 8601 basic format with no timezone: 19860209T200000Z.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
static provideOutOfRangeTimestamps()
Returns a list of out of range timestamps in the format: [ type, timestamp_of_type ]...
const TS_POSTGRES
Postgres format time.
static convert($style=TS_UNIX, $ts)
Convert a timestamp string to a given format.
testToString()
ConvertibleTimestamp::__toString.
testValidOutput($format, $expected, $original)
Test outputting valid timestamps to different formats.
const TS_ORACLE
Oracle format time.
const TS_DB
MySQL DATETIME (YYYY-MM-DD HH:MM:SS)