@@ -188,6 +188,9 @@ public function format($timestamp)
188
188
$ argumentError = 'datefmt_format: takes either an array or an integer timestamp value ' ;
189
189
} elseif (version_compare (\PHP_VERSION , '5.3.4 ' , '>= ' ) && !is_int ($ timestamp ) && !$ timestamp instanceof \DateTime) {
190
190
$ argumentError = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object ' ;
191
+ if (version_compare (\PHP_VERSION , '5.5.0alpha1 ' , '>= ' ) && !is_int ($ timestamp )) {
192
+ $ argumentError = sprintf ('datefmt_format: string \'%s \' is not numeric, which would be required for it to be a valid date ' , $ timestamp );
193
+ }
191
194
}
192
195
193
196
if (null !== $ argumentError ) {
@@ -214,6 +217,24 @@ public function format($timestamp)
214
217
return $ formatted ;
215
218
}
216
219
220
+ /**
221
+ * Formats an object
222
+ *
223
+ * @param object $object
224
+ * @param mixed $format
225
+ * @param string $locale
226
+ *
227
+ * @return string The formatted value
228
+ *
229
+ * @see http://www.php.net/manual/en/intldateformatter.formatobject.php
230
+ *
231
+ * @throws MethodNotImplementedException
232
+ */
233
+ public function formatObject ($ object , $ format = null , $ locale = null )
234
+ {
2
D7AE
35
+ throw new MethodNotImplementedException (__METHOD__ );
236
+ }
237
+
217
238
/**
218
239
* Returns the formatter's calendar
219
240
*
@@ -226,6 +247,20 @@ public function getCalendar()
226
247
return self ::GREGORIAN ;
227
248
}
228
249
250
+ /**
251
+ * Returns the formatter's calendar object
252
+ *
253
+ * @return object The calendar's object being used by the formatter
254
+ *
255
+ * @see http://www.php.net/manual/en/intldateformatter.getcalendarobject.php
256
+ *
257
+ * @throws MethodNotImplementedException
258
+ */
259
+ public function getCalendarObject ()
260
+ {
261
+ throw new MethodNotImplementedException (__METHOD__ );
262
+ }
263
+
229
264
/**
230
265
* Returns the formatter's datetype
231
266
*
@@ -313,9 +348,28 @@ public function getTimeZoneId()
313
348
return $ this ->timeZoneId ;
314
349
}
315
350
351
+ // In PHP 5.5 default timezone depends on `date_default_timezone_get()` method
352
+ if (version_compare (\PHP_VERSION , '5.5.0alpha1 ' , '>= ' )) {
353
+ return date_default_timezone_get ();
354
+ }
355
+
316
356
return null ;
317
357
}
318
358
359
+ /**
360
+ * Returns the formatter's timezone
361
+ *
362
+ * @return mixed The timezone used by the formatter
363
+ *
364
+ * @see http://www.php.net/manual/en/intldateformatter.gettimezone.php
365
+ *
366
+ * @throws MethodNotImplementedException
367
+ */
368
+ public function getTimeZone ()
369
+ {
370
+ throw new MethodNotImplementedException (__METHOD__ );
371
+ }
372
+
319
373
/**
320
374
* Returns whether the formatter is lenient
321
375
*
@@ -458,11 +512,16 @@ public function setPattern($pattern)
458
512
public function setTimeZoneId ($ timeZoneId )
459
513
{
460
514
if (null === $ timeZoneId ) {
461
- // TODO: changes were made to ext/intl in PHP 5.4.4 release that need to be investigated since it will
462
- // use ini's date.timezone when the time zone is not provided. As a not well tested workaround, uses UTC.
463
- // See the first two items of the commit message for more information:
464
- // https://github.com/php/php-src/commit/eb346ef0f419b90739aadfb6cc7b7436c5b521d9
465
- $ timeZoneId = getenv ('TZ ' ) ?: 'UTC ' ;
515
+ // In PHP 5.5 if $timeZoneId is null it fallbacks to `date_default_timezone_get()` method
516
+ if (version_compare (\PHP_VERSION , '5.5.0alpha1 ' , '>= ' )) {
517
+ $ timeZoneId = date_default_timezone_get ();
518
+ } else {
519
+ // TODO: changes were made to ext/intl in PHP 5.4.4 release that need to be investigated since it will
520
+ // use ini's date.timezone when the time zone is not provided. As a not well tested workaround, uses UTC.
521
+ // See the first two items of the commit message for more information:
522
+ // https://github.com/php/php-src/commit/eb346ef0f419b90739aadfb6cc7b7436c5b521d9
523
+ $ timeZoneId = getenv ('TZ ' ) ?: 'UTC ' ;
524
+ }
466
525
467
526
$ this ->unitializedTimeZoneId = true ;
468
527
}
@@ -490,13 +549,27 @@ public function setTimeZoneId($timeZoneId)
490
549
return true ;
491
550
}
492
551
552
+ /**
553
+ * This method was added in PHP 5.5 as replacement for `setTimeZoneId()`
554
+ *
555
+ * @param mixed $timeZone
556
+ *
557
+ * @return Boolean true on success or false on failure
558
+ *
559
+ * @see http://www.php.net/manual/en/intldateformatter.settimezone.php
560
+ */
561
+ public function setTimeZone ($ timeZone )
562
+ {
563
+ return $ this ->setTimeZoneId ($ timeZone );
564
+ }
565
+
493
566
/**
494
567
* Create and returns a DateTime object with the specified timestamp and with the
495
568
* current time zone
496
569
*
497
570
* @param int $timestamp
498
571
*
499
- * @return DateTime
572
+ * @return \ DateTime
500
573
*/
501
574
protected function createDateTime ($ timestamp )
502
575
{
0 commit comments