function testLocalizedFormat() { $date = new lmbLocaleDateTime('2005-01-20 10:15:30'); $locale = new lmbLocale('en', new lmbIni(dirname(__FILE__) . '/../en.ini')); $res = $date->localeStrftime($locale->getDateFormat(), $locale); $expected = 'Thursday 20 January 2005'; $this->assertEqual($res, $expected); }
function lmb_i18n_date_filter($params, $value) { $toolkit = lmbToolkit::instance(); if (isset($params[0]) && $params[0]) { $locale = $toolkit->getLocaleObject($params[0]); } else { $locale = $toolkit->getLocaleObject(); } if (isset($params[3]) && $params[3]) { $format = $params[3]; } else { if (isset($params[2]) && $params[2]) { $format_type = $params[2]; } else { $format_type = 'short_date'; } $property = $format_type . '_format'; $format = $locale->{$property}; } if (isset($params[1]) && $params[1]) { $date_type = $params[1]; } else { $date_type = 'stamp'; } switch ($date_type) { case 'string': $date = new lmbLocaleDateTime($value); break; case 'stamp': $date = new lmbLocaleDateTime((int) $value); break; default: $date = new lmbLocaleDateTime($value); break; } return $date->localeStrftime($format, $locale); }
function testIsLocalStringNotValid() { $locale = new lmbLocale('en', new lmbIni(dirname(__FILE__) . '/../en.ini')); $this->assertFalse(lmbLocaleDateTime::isLocalStringValid($locale, '02-29-2003', '%a %d %b %Y')); }
static function isLocalStringValid($locale, $string, $format = null) { try { lmbLocaleDateTime::localStringToDate($locale, $string, $format); return true; } catch (lmbException $e) { return false; } }