Go to the documentation of this file.
8 protected function setUp() {
19 $this->assertInternalType(
'string',
$timestamp->getTimestamp() );
20 $this->assertNotEmpty(
$timestamp->getTimestamp() );
21 $this->assertNotEquals(
false, strtotime(
$timestamp->getTimestamp(
TS_MW ) ) );
29 $this->assertEquals(
'1406833268',
$timestamp->__toString() );
34 array(
'1406833268',
'1406833269',
'00 00 00 01' ),
35 array(
'1406833268',
'1406833329',
'00 00 01 01' ),
36 array(
'1406833268',
'1406836929',
'00 01 01 01' ),
37 array(
'1406833268',
'1406923329',
'01 01 01 01' ),
45 public function testDiff( $timestamp1, $timestamp2, $expected ) {
48 $diff = $timestamp1->diff( $timestamp2 );
49 $this->assertEquals( $expected, $diff->format(
'%D %H %I %S' ) );
69 $this->assertEquals( $expected, (
string)
$timestamp->getTimestamp( $format ) );
99 array(
TS_MW,
'20120731190108',
'20120731190108' ),
100 array(
TS_DB,
'2012-07-31 19:01:08',
'20120731190108' ),
103 array(
TS_EXIF,
'2012:07:31 19:01:08',
'20120731190108' ),
104 array(
TS_RFC2822,
'Tue, 31 Jul 2012 19:01:08 GMT',
'20120731190108' ),
105 array(
TS_ORACLE,
'31-07-2012 19:01:08.000000',
'20120731190108' ),
125 $user = $this->getMock(
'User' );
126 $user->expects( $this->any() )
127 ->method(
'getOption' )
128 ->with(
'timecorrection' )
129 ->will( $this->returnValue( $timeCorrection ) );
131 $user->expects( $this->any() )
132 ->method(
'getDatePreference' )
133 ->will( $this->returnValue( $dateFormat ) );
140 $tsTime->getHumanTimestamp( $currentTime,
$user ),
152 'Yesterday at 17:00',
153 '"Yesterday" across years',
192 '15:15, January 30, 1991',
200 'Yesterday at 23:00',
201 '"Yesterday" across years with time correction',
209 'Recent weekday with time correction',
217 'Today at another time with time correction',
225 'Another month with dmy'
233 'Another month with ISO-8601'
240 '1991-01-30T15:15:00',
241 'Different year with ISO-8601',
258 $user = $this->getMock(
'User' );
259 $user->expects( $this->any() )
260 ->method(
'getOption' )
261 ->with(
'timecorrection' )
262 ->will( $this->returnValue( $timeCorrection ) );
269 $tsTime->getRelativeTimestamp( $currentTime,
$user ),
282 '"Yesterday" across years',
297 '6 minutes and 30 seconds ago',
298 'Combination of multiple units',
313 '2 decades, 1 year, 168 days, 2 hours, 8 minutes and 48 seconds ago',
322 '"Yesterday" across years with time correction',
330 'Recent weekday with time correction',
337 '9 hours and 17 minutes ago',
338 'Today at another time with time correction',
static provideRelativeTimestampTests()
Library for creating and parsing MW-style timestamps.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
testHumanTimestamp( $tsTime, $currentTime, $timeCorrection, $dateFormat, $expectedOutput, $desc)
@dataProvider provideHumanTimestampTests @covers MWTimestamp::getHumanTimestamp
const TS_EXIF
An Exif timestamp (YYYY:MM:DD HH:MM:SS)
Tests timestamp parsing and output.
const TS_DB
MySQL DATETIME (YYYY-MM-DD HH:MM:SS)
const TS_ORACLE
Oracle format time.
const TS_ISO_8601
ISO 8601 format with no timezone: 1986-02-09T20:00:00Z.
testDiff( $timestamp1, $timestamp2, $expected)
@dataProvider provideValidTimestampDifferences @covers MWTimestamp::diff
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
const TS_ISO_8601_BASIC
ISO 8601 basic format with no timezone: 19860209T200000Z.
static getMain()
Static methods.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
testInvalidParse()
Test an invalid timestamp.
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
testConstructWithNoTimestamp()
@covers MWTimestamp::__construct
static provideHumanTimestampTests()
testToString()
@covers MWTimestamp::__toString
const TS_POSTGRES
Postgres format time.
static factory( $code)
Get a cached or new language object for a given language code.
provideValidTimestampDifferences()
testInvalidOutput()
Test requesting an invalid output format.
testValidParse( $format, $original, $expected)
Test parsing of valid timestamps and outputing to MW format.
static provideValidTimestamps()
Returns a list of valid timestamps in the format: array( type, timestamp_of_type, timestamp_in_MW )
const TS_RFC2822
RFC 2822 format, for E-mail and HTTP headers.
testRelativeTimestamp( $tsTime, $currentTime, $timeCorrection, $dateFormat, $expectedOutput, $desc)
@dataProvider provideRelativeTimestampTests @covers MWTimestamp::getRelativeTimestamp
testValidOutput( $format, $expected, $original)
Test outputting valid timestamps to different formats.