Skip to content

Commit

Permalink
Fallback for 'extreme' dates
Browse files Browse the repository at this point in the history
  • Loading branch information
sjaakp committed Oct 30, 2015
1 parent d30a50b commit ec5df29
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Formatter.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* MIT licence
* Version 1.0
* Sjaak Priester, Amsterdam 04-06-2015.
* Version 1.0.1
* Sjaak Priester, Amsterdam 04-06-2015 ... 30-10-2015.
*
* Formatter class, extends Yii's standard formatter yii\i18n\Formatter.
* Use this by setting it as component in the configuration file (often config/web.php, or config/main.php) like:
Expand Down Expand Up @@ -129,9 +129,11 @@ public function asFuzzyDate($value, $format = null) {
}
if (! $formatter) $formatter = new IntlDateFormatter($this->locale, IntlDateFormatter::NONE, IntlDateFormatter::NONE);

$formatter->setPattern($pattern);


return $formatter->format($dt);
// New in 1.0.1 : fall back to PHP if 32 bits and 'extreme' date
if (PHP_INT_SIZE > 4 || ($value['y'] > 1901 && $value['y'] < 2038)) {
$formatter->setPattern($pattern);
return $formatter->format($dt);
}
else return $dt->format(FormatConverter::convertDateIcuToPhp($pattern));
}
}

0 comments on commit ec5df29

Please sign in to comment.