当前位置: 首页>>代码示例>>PHP>>正文


PHP sfI18N::getTimeForCulture方法代码示例

本文整理汇总了PHP中sfI18N::getTimeForCulture方法的典型用法代码示例。如果您正苦于以下问题:PHP sfI18N::getTimeForCulture方法的具体用法?PHP sfI18N::getTimeForCulture怎么用?PHP sfI18N::getTimeForCulture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sfI18N的用法示例。


在下文中一共展示了sfI18N::getTimeForCulture方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

// ->getCountry()
$t->diag('->getCountry()');
$i18n = new sfI18N($configuration, $cache, array('culture' => 'fr'));
$t->is($i18n->getCountry('FR'), 'France', '->getCountry() returns the name of a country for the current culture');
$t->is($i18n->getCountry('FR', 'es'), 'Francia', '->getCountry() takes an optional culture as its second argument');
// ->getNativeName()
$t->diag('->getNativeName()');
$i18n = new sfI18N($configuration, $cache, array('culture' => 'fr'));
$t->is($i18n->getNativeName('fr'), 'français', '->getNativeName() returns the name of a culture');
// ->getTimestampForCulture()
$t->diag('->getTimestampForCulture()');
$i18n = new sfI18N($configuration, $cache, array('culture' => 'fr'));
$t->is($i18n->getTimestampForCulture('15/10/2005'), mktime(0, 0, 0, '10', '15', '2005'), '->getTimestampForCulture() returns the timestamp for a data formatted in the current culture');
$t->is($i18n->getTimestampForCulture('15/10/2005 15:33'), mktime(15, 33, 0, '10', '15', '2005'), '->getTimestampForCulture() returns the timestamp for a data formatted in the current culture');
$t->is($i18n->getTimestampForCulture('10/15/2005', 'en_US'), mktime(0, 0, 0, '10', '15', '2005'), '->getTimestampForCulture() can take a culture as its second argument');
$t->is($i18n->getTimestampForCulture('10/15/2005 15:33', 'en_US'), mktime(15, 33, 0, '10', '15', '2005'), '->getTimestampForCulture() can take a culture as its second argument');
$t->is($i18n->getTimestampForCulture('not a date'), null, '->getTimestampForCulture() returns the day, month and year for a data formatted in the current culture');
// ->getDateForCulture()
$t->diag('->getDateForCulture()');
$i18n = new sfI18N($configuration, $cache, array('culture' => 'fr'));
$t->is($i18n->getDateForCulture('15/10/2005'), array('15', '10', '2005'), '->getDateForCulture() returns the day, month and year for a data formatted in the current culture');
$t->is($i18n->getDateForCulture('10/15/2005', 'en_US'), array('15', '10', '2005'), '->getDateForCulture() can take a culture as its second argument');
$t->is($i18n->getDateForCulture(null), null, '->getDateForCulture() returns null in case of conversion problem');
$t->is($i18n->getDateForCulture('not a date'), null, '->getDateForCulture() returns null in case of conversion problem');
// ->getTimeForCulture()
$t->diag('->getTimeForCulture()');
$i18n = new sfI18N($configuration, $cache, array('culture' => 'fr'));
$t->is($i18n->getTimeForCulture('15:33'), array('15', '33'), '->getTimeForCulture() returns the hour and minuter for a time formatted in the current culture');
$t->is($i18n->getTimeForCulture('15:33', 'en_US'), array('15', '33'), '->getTimeForCulture() can take a culture as its second argument');
$t->is($i18n->getTimeForCulture(null), null, '->getTimeForCulture() returns null in case of conversion problem');
$t->is($i18n->getTimeForCulture('not a time'), null, '->getTimeForCulture() returns null in case of conversion problem');
开发者ID:mediasadc,项目名称:alba,代码行数:31,代码来源:sfI18NTest.php

示例2: array

$t->is($i18n->getNativeName('fr'), 'français', '->getNativeName() returns the name of a culture');
// ->getTimestampForCulture()
$t->diag('->getTimestampForCulture()');
$i18n = new sfI18N($configuration, $cache, array('culture' => 'fr'));
$t->is($i18n->getTimestampForCulture('15/10/2005'), mktime(0, 0, 0, '10', '15', '2005'), '->getTimestampForCulture() returns the timestamp for a data formatted in the current culture');
$t->is($i18n->getTimestampForCulture('15/10/2005 15:33'), mktime(15, 33, 0, '10', '15', '2005'), '->getTimestampForCulture() returns the timestamp for a data formatted in the current culture');
$t->is($i18n->getTimestampForCulture('10/15/2005', 'en_US'), mktime(0, 0, 0, '10', '15', '2005'), '->getTimestampForCulture() can take a culture as its second argument');
$t->is($i18n->getTimestampForCulture('10/15/2005 3:33 pm', 'en_US'), mktime(15, 33, 0, '10', '15', '2005'), '->getTimestampForCulture() can take a culture as its second argument');
$t->is($i18n->getTimestampForCulture('not a date'), null, '->getTimestampForCulture() returns the day, month and year for a data formatted in the current culture');
// ->getDateForCulture()
$t->diag('->getDateForCulture()');
$i18n = new sfI18N($configuration, $cache, array('culture' => 'fr'));
$t->is($i18n->getDateForCulture('15/10/2005'), array('15', '10', '2005'), '->getDateForCulture() returns the day, month and year for a data formatted in the current culture');
$t->is($i18n->getDateForCulture('10/15/2005', 'en_US'), array('15', '10', '2005'), '->getDateForCulture() can take a culture as its second argument');
$t->is($i18n->getDateForCulture(null), null, '->getDateForCulture() returns null in case of conversion problem');
$t->is($i18n->getDateForCulture('not a date'), null, '->getDateForCulture() returns null in case of conversion problem');
// german locale contains a dot as separator for date. See #7582
$i18n = new sfI18N($configuration, $cache, array('culture' => 'de'));
$t->is($i18n->getDateForCulture('15.10.2005'), array('15', '10', '2005'), '->getDateForCulture() returns the day, month and year for a data formatted in culture with dots as separators');
$t->is($i18n->getDateForCulture('15x10x2005'), null, '->getDateForCulture() returns null in case of conversion problem with dots as separators');
// ->getTimeForCulture()
$t->diag('->getTimeForCulture()');
$i18n = new sfI18N($configuration, $cache, array('culture' => 'fr'));
$t->is($i18n->getTimeForCulture('15:33'), array('15', '33'), '->getTimeForCulture() returns the hour and minuter for a time formatted in the current culture');
$t->is($i18n->getTimeForCulture('3:33 pm', 'en_US'), array('15', '33'), '->getTimeForCulture() can take a culture as its second argument');
$t->is($i18n->getTimeForCulture(null), null, '->getTimeForCulture() returns null in case of conversion problem');
$t->is($i18n->getTimeForCulture('not a time'), null, '->getTimeForCulture() returns null in case of conversion problem');
// swedish locale contains a dot as separator for time. See #7582
$i18n = new sfI18N($configuration, $cache, array('culture' => 'sv'));
$t->is($i18n->getTimeForCulture('15.33'), array('15', '33'), '->getTimeForCulture() returns the hour and minuter for a time formatted in culture with dots as separators');
$t->is($i18n->getTimeForCulture('15x33'), null, '->getTimeForCulture() returns null in case of conversion problem with dots as separators');
开发者ID:sabaki-dev,项目名称:symfony1,代码行数:31,代码来源:sfI18NTest.php


注:本文中的sfI18N::getTimeForCulture方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。