|
@@ 323-346 (lines=24) @@
|
| 320 |
|
$this->assertFalse($f->validate(new RequiredFields()), 'Date above max datetime'); |
| 321 |
|
} |
| 322 |
|
|
| 323 |
|
public function testTimezoneSetValueLocalised() |
| 324 |
|
{ |
| 325 |
|
date_default_timezone_set('Europe/Berlin'); |
| 326 |
|
// Berlin and Auckland have 12h time difference in northern hemisphere winter |
| 327 |
|
$datetimeField = new DatetimeField('Datetime', 'Datetime'); |
| 328 |
|
|
| 329 |
|
$datetimeField |
| 330 |
|
->setHTML5(false) |
| 331 |
|
->setDatetimeFormat('dd/MM/y HH:mm:ss'); |
| 332 |
|
|
| 333 |
|
$datetimeField->setTimezone('Pacific/Auckland'); |
| 334 |
|
$datetimeField->setValue('2003-12-24 23:59:59'); |
| 335 |
|
$this->assertEquals( |
| 336 |
|
'25/12/2003 11:59:59', |
| 337 |
|
$datetimeField->Value(), |
| 338 |
|
'User value is formatted, and in user timezone' |
| 339 |
|
); |
| 340 |
|
|
| 341 |
|
$this->assertEquals( |
| 342 |
|
'2003-12-24 23:59:59', |
| 343 |
|
$datetimeField->dataValue(), |
| 344 |
|
'Data value is in ISO format, and in server timezone' |
| 345 |
|
); |
| 346 |
|
} |
| 347 |
|
|
| 348 |
|
public function testTimezoneSetValueWithHtml5() |
| 349 |
|
{ |
|
@@ 369-384 (lines=16) @@
|
| 366 |
|
); |
| 367 |
|
} |
| 368 |
|
|
| 369 |
|
public function testTimezoneSetSubmittedValueLocalised() |
| 370 |
|
{ |
| 371 |
|
date_default_timezone_set('Europe/Berlin'); |
| 372 |
|
// Berlin and Auckland have 12h time difference in northern hemisphere summer, but Berlin and Moscow only 2h. |
| 373 |
|
$datetimeField = new DatetimeField('Datetime', 'Datetime'); |
| 374 |
|
|
| 375 |
|
$datetimeField |
| 376 |
|
->setHTML5(false) |
| 377 |
|
->setLocale('en_NZ'); |
| 378 |
|
|
| 379 |
|
$datetimeField->setTimezone('Europe/Moscow'); |
| 380 |
|
// pass in default format, at user time (Moscow) |
| 381 |
|
$datetimeField->setSubmittedValue('24/06/2003 11:59:59 pm'); |
| 382 |
|
$this->assertTrue($datetimeField->validate(new RequiredFields())); |
| 383 |
|
$this->assertEquals('2003-06-24 21:59:59', $datetimeField->dataValue(), 'Data value matches server timezone'); |
| 384 |
|
} |
| 385 |
|
|
| 386 |
|
public function testGetName() |
| 387 |
|
{ |