本文整理汇总了PHP中sfI18N::getDateForCulture方法的典型用法代码示例。如果您正苦于以下问题:PHP sfI18N::getDateForCulture方法的具体用法?PHP sfI18N::getDateForCulture怎么用?PHP sfI18N::getDateForCulture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfI18N
的用法示例。
在下文中一共展示了sfI18N::getDateForCulture方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeUpdate
public function executeUpdate()
{
if (!$this->getRequestParameter('id')) {
$campus = new Campus();
} else {
$campus = CampusPeer::retrieveByPk($this->getRequestParameter('id'));
$this->forward404Unless($campus);
}
$campus->setId($this->getRequestParameter('id'));
$campus->setUuid($this->getRequestParameter('uuid'));
$campus->setName($this->getRequestParameter('name'));
$campus->setAddress($this->getRequestParameter('address'));
$campus->setCity($this->getRequestParameter('city'));
$campus->setState($this->getRequestParameter('state'));
$campus->setZip($this->getRequestParameter('zip'));
$campus->setUrl($this->getRequestParameter('url'));
$campus->setPhone($this->getRequestParameter('phone'));
$campus->setEmail($this->getRequestParameter('email'));
$campus->setSlug($this->getRequestParameter('slug'));
$campus->setVersion($this->getRequestParameter('version'));
if ($this->getRequestParameter('deleted_at')) {
list($d, $m, $y) = sfI18N::getDateForCulture($this->getRequestParameter('deleted_at'), $this->getUser()->getCulture());
$campus->setDeletedAt("{$y}-{$m}-{$d}");
}
$campus->save();
return $this->redirect('campus/show?id=' . $campus->getId());
}
示例2: executeUpdate
public function executeUpdate()
{
$task = TaskPeer::retrieveByUuid($this->getRequestParameter('task'));
$this->forward404Unless($task);
$this->forward404Unless($task->isAuthorized($this->getUser()->getId()), 'User not authorized to edit tasks for this project');
$project = $task->getProject();
$task->setName($this->getRequestParameter('name'));
$task->setDescription($this->getRequestParameter('description'));
if ($this->getRequestParameter('begin')) {
list($d, $m, $y) = sfI18N::getDateForCulture($this->getRequestParameter('begin'), $this->getUser()->getCulture());
$task->setBegin("{$y}-{$m}-{$d}");
}
if ($this->getRequestParameter('finish')) {
list($d, $m, $y) = sfI18N::getDateForCulture($this->getRequestParameter('finish'), $this->getUser()->getCulture());
$task->setFinish("{$y}-{$m}-{$d}");
}
$task->setStatus($this->getRequestParameter('status', sfConfig::get('app_task_status_open')));
$task->setPriority($this->getRequestParameter('priority'));
$task->clearUsers();
$user = sfGuardUserProfilePeer::retrieveByUuid($this->getRequestParameter('task_user'));
$task->addUser($user->getUserId());
$task->save();
$this->task = $task;
$this->project = $project;
$this->setTemplate('show');
return $this->redirect('project/showTask?tab=tasks&task=' . $task->getUuid());
}
示例3: executeUpdateTodo
/**
* Executes updateTodo action
*
*/
public function executeUpdateTodo()
{
$this->forward404Unless($this->getUser()->isAuthenticated() && ($this->profile = $this->getUser()->getProfile()));
$this->forward404Unless($todo = ToDoPeer::retrieveByUserIdSlug($this->profile->getUserId(), $this->getRequestParameter('todo'), true), 'Todo not found by user_id:slug, [' . $this->profile->getUserId() . ']:[' . $this->getRequestParameter('todo') . ']');
$this->forward404Unless($todo->getOwnerId() == $this->getUser()->getId(), 'Owner doesn\'t match current user');
$todo->setName($this->getRequestParameter('name'));
$todo->setDescription($this->getRequestParameter('description'));
$todo->setStatus($this->getRequestParameter('status'));
if ($this->getRequestParameter('begin')) {
list($d, $m, $y) = sfI18N::getDateForCulture($this->getRequestParameter('begin'), $this->getUser()->getCulture());
$todo->setBegin("{$y}-{$m}-{$d}");
}
if ($this->getRequestParameter('finish')) {
list($d, $m, $y) = sfI18N::getDateForCulture($this->getRequestParameter('finish'), $this->getUser()->getCulture());
$todo->setFinish("{$y}-{$m}-{$d}");
}
$todo->save();
$this->todo = $todo;
$this->setTemplate('showTodo');
}
示例4: executeUpdate
public function executeUpdate()
{
if (!$this->getRequestParameter('id')) {
$personal = new Personal();
} else {
$personal = PersonalPeer::retrieveByPk($this->getRequestParameter('id'));
$this->forward404Unless($personal);
}
if ($this->getRequest()->getFileName('image')) {
$fileName = md5($this->getRequest()->getFileName('image') . time() . rand(0, 99999));
$ext = $this->getRequest()->getFileExtension('image');
$this->getRequest()->moveFile('image', sfConfig::get('sf_upload_dir') . "//profilepic//" . $fileName . $ext);
$fullname = $fileName . $ext;
$fullpath = '/uploads/profilepic/' . $fullname;
$personal->setImage($fullpath);
}
$personal->setId($this->getRequestParameter('id'));
$personal->setUserId($this->getRequestParameter('user_id') ? $this->getRequestParameter('user_id') : null);
$personal->setImageflag($this->getRequestParameter('imageflag'));
$personal->setSalutation($this->getRequestParameter('salutation'));
$personal->setFirstname($this->getRequestParameter('firstname'));
$personal->setFirstnameflag($this->getRequestParameter('firstnameflag'));
$personal->setMiddlename($this->getRequestParameter('middlename'));
$personal->setMiddlenameflag($this->getRequestParameter('middlenameflag'));
$personal->setLastname($this->getRequestParameter('lastname'));
$personal->setLastnameflag($this->getRequestParameter('lastnameflag'));
$personal->setMaidenname($this->getRequestParameter('maidenname'));
$personal->setMaidennameflag($this->getRequestParameter('maidennameflag'));
$personal->setItbhuname($this->getRequestParameter('itbhuname'));
$personal->setItbhunameflag($this->getRequestParameter('itbhunameflag'));
$personal->setGender($this->getRequestParameter('gender'));
$personal->setGenderflag($this->getRequestParameter('genderflag'));
if ($this->getRequestParameter('dob')) {
list($d, $m, $y) = sfI18N::getDateForCulture($this->getRequestParameter('dob'), $this->getUser()->getCulture());
$personal->setDob("{$y}-{$m}-{$d}");
}
$personal->setDobflag($this->getRequestParameter('dobflag'));
$personal->setMaritalstatus($this->getRequestParameter('maritalstatus'));
$personal->setMaritalstatusflag($this->getRequestParameter('maritalstatusflag'));
$personal->setMobile($this->getRequestParameter('mobile'));
$personal->setMobileflag($this->getRequestParameter('mobileflag'));
$personal->setEmail($this->getRequestParameter('email'));
$personal->setEmailflag($this->getRequestParameter('emailflag'));
$personal->setWebsite($this->getRequestParameter('website'));
$personal->setWebsiteflag($this->getRequestParameter('websiteflag'));
$personal->setLinkedin($this->getRequestParameter('linkedin'));
$personal->setLinkedinflag($this->getRequestParameter('linkedinflag'));
$personal->setHobbies($this->getRequestParameter('hobbies'));
$personal->setHobbiesflag($this->getRequestParameter('hobbiesflag'));
$personal->setInterest($this->getRequestParameter('interest'));
$personal->save();
$user = $personal->getUser();
$user->setCurrentlyat($this->getRequestParameter('currentlyat'));
$user->setCurrentlyatflag($this->getRequestParameter('currentlyatflag'));
$user->save();
return $this->redirect('personal/show?id=' . $personal->getId());
}
示例5: executeUpdateMilestone
/**
* Executes updateMilestone action
*
*/
public function executeUpdateMilestone()
{
$this->forward404Unless($this->project = ProjectPeer::retrieveBySlug($this->getRequestParameter('project')), 'Project does not exist, using slug [' . $this->getRequestParameter('project') . ']');
$this->tab = sfConfig::get('app_tab_project_team');
$this->forward404Unless($this->position = ProjectPositionPeer::retrieveByUuid($this->getRequestParameter('position')), 'Position not found, unable to add milestone');
$milestone = PositionMilestonePeer::retrieveByUuid($this->getRequestParameter('milestone'));
if ($milestone == null) {
$milestone = new PositionMilestone();
}
$milestone->setTitle($this->getRequestParameter('milestone_title'));
if ($this->getRequestParameter('milestone_deadline')) {
list($d, $m, $y) = sfI18N::getDateForCulture($this->getRequestParameter('milestone_deadline'), $this->getUser()->getCulture());
$milestone->setDeadline("{$y}-{$m}-{$d}");
}
$milestone->setDescription($this->getRequestParameter('milestone_description'));
$milestone->setDeliverables($this->getRequestParameter('milestone_deliverables'));
$milestone->save();
if (sfContext::getInstance()->getRequest()->isXmlHttpRequest()) {
# Should we do something special here, if the request is ajax? Perhaps we can separate ajax and non-ajax paths here
}
}
示例6: 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');
示例7: 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');
示例8: getValidDate
/**
* Converts the given date into a Unix timestamp.
*
* Returns null if the date is invalid
*
* @param $value Date to convert
* @param $culture Language culture to use
*/
protected function getValidDate($value, $culture)
{
// Use the language culture date format
$result = sfI18N::getDateForCulture($value, $culture);
list($d, $m, $y) = $result;
// Make sure the date is a valid gregorian calendar date also
if ($result === null || !checkdate($m, $d, $y)) {
return null;
}
return strtotime("{$y}-{$m}-{$d} 00:00");
}
示例9: executeUpdate
public function executeUpdate()
{
if (!$this->getRequestParameter('id')) {
$suggested_feature = new SuggestedFeature();
} else {
$suggested_feature = SuggestedFeaturePeer::retrieveByPk($this->getRequestParameter('id'));
$this->forward404Unless($suggested_feature);
}
$suggested_feature->setId($this->getRequestParameter('id'));
$suggested_feature->setUuid($this->getRequestParameter('uuid'));
$suggested_feature->setUserId($this->getRequestParameter('user_id') ? $this->getRequestParameter('user_id') : null);
$suggested_feature->setTitle($this->getRequestParameter('title'));
$suggested_feature->setSlug($this->getRequestParameter('slug'));
$suggested_feature->setDescription($this->getRequestParameter('description'));
$suggested_feature->setStatus($this->getRequestParameter('status'));
$suggested_feature->setType($this->getRequestParameter('type'));
$suggested_feature->setFeeling($this->getRequestParameter('feeling'));
if ($this->getRequestParameter('deleted_at')) {
list($d, $m, $y) = sfI18N::getDateForCulture($this->getRequestParameter('deleted_at'), $this->getUser()->getCulture());
$suggested_feature->setDeletedAt("{$y}-{$m}-{$d}");
}
$suggested_feature->save();
return $this->redirect('features/show?id=' . $suggested_feature->getId());
}
示例10: getValidDateTime
/**
* Converts the given datetime into a Unix timestamp.
*
* Returns null if the datetime is invalid
*
* @param $value DateTime to convert
* @param $culture Language culture to use
*/
protected function getValidDateTime($value, $culture)
{
list($date, $time) = split(" ", $value);
// Use the language culture datetime format
$result = sfI18N::getDateForCulture($date, $culture);
list($d, $m, $y) = $result;
// Make sure the datetime is a valid gregorian calendar datetime also
if ($result === null || !checkdate($m, $d, $y)) {
return null;
}
$is_valid = preg_match('/^(\\d{1,2})(:(\\d{1,2})(:(\\d{1,2}))?)?$/', $time, $match);
if (!$is_valid) {
return;
}
$hr = $match[1];
$min = 0;
$sec = 0;
if (count($match) > 5) {
$sec = $match[5];
}
if (count($match) > 3) {
$min = $match[3];
}
$datetime = "{$y}-{$m}-{$d} " . join(':', array(str_pad($hr, 2, '0', STR_PAD_LEFT), str_pad($min, 2, '0', STR_PAD_LEFT), str_pad($sec, 2, '0', STR_PAD_LEFT)));
$retval = strtotime($datetime);
return $retval;
}
示例11: dirname
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
require_once sfConfig::get('sf_symfony_lib_dir') . '/i18n/sfI18N.class.php';
$t = new lime_test(9, new lime_output_color());
$t->diag('i18n');
$i18n = sfI18n::getInstance();
$time = mktime(10, 30, 0, 8, 1, 2008);
$t->is(sfI18N::getTimestampForCulture('01/08/2008 10:30', 'fr'), $time, '->getTimestampForCulture() returns the timestamp for a data formatted in the current culture');
$t->is(sfI18N::getTimestampForCulture('08/01/2008 10:30', 'en_US'), $time, '->getTimestampForCulture() returns the timestamp for a data formatted in the current culture');
$t->is(sfI18N::getTimestampForCulture('08/01/2008', 'en_US'), mktime(0, 0, 0, 8, 1, 2008), '->getTimestampForCulture() returns the timestamp for a data formatted in the current culture');
$t->is(sfI18N::getTimestampForCulture('', 'en_US'), mktime(0, 0, 0, 0, 0, 0), '->getTimestampForCulture() returns the timestamp for a data formatted in the current culture');
$t->is(sfI18N::getTimestampForCulture('not a date', 'en_US'), mktime(0, 0, 0, 0, 0, 0), '->getTimestampForCulture() returns the timestamp for a data formatted in the current culture');
$t->is(sfI18N::getTimestampForCulture('10:30', 'en_US'), mktime(10, 30, 0, 0, 0, 0), '->getTimestampForCulture() returns the timestamp for a data formatted in the current culture');
$t->is(sfI18N::getDateForCulture('01/08/2008 10:30', 'fr'), array(1, 8, 2008), '->getDateForCulture() returns the day, month and year for a data formatted in the current culture');
$t->is(sfI18N::getDateForCulture('08/01/2008 10:30', 'en_US'), array(1, 8, 2008), '->getDateForCulture() returns the day, month and year for a data formatted in the current culture');
$t->is(sfI18N::getDateForCulture('not a date', 'en_US'), null, '->getTimeForCulture() returns null in case of conversion problem');
示例12: executeUpdate
public function executeUpdate()
{
if (!$this->getRequestParameter('id')) {
$family = new Family();
} else {
$family = FamilyPeer::retrieveByPk($this->getRequestParameter('id'));
$this->forward404Unless($family);
}
/*if($this->getRequest()->getFileName('image'))
{
$fileName = md5($this->getRequest()->getFileName('image').time().rand(0, 99999));
$ext = $this->getRequest()->getFileExtension('image');
$this->getRequest()->moveFile('image', sfConfig::get('sf_upload_dir')."//profilepic//".$fileName.$ext);
$fullname = $fileName.$ext;
$fullpath = '/uploads/profilepic/'.$fullname;
$personal->setImage($fullpath);
}*/
$family->setId($this->getRequestParameter('id'));
$family->setUserId($this->getRequestParameter('user_id') ? $this->getRequestParameter('user_id') : null);
if ($this->getRequestParameter('dom')) {
list($d, $m, $y) = sfI18N::getDateForCulture($this->getRequestParameter('dom'), $this->getUser()->getCulture());
$family->setDom("{$y}-{$m}-{$d}");
}
$family->setDomflag($this->getRequestParameter('domflag'));
$family->setSpousename($this->getRequestParameter('spousename'));
$family->setSpousenameflag($this->getRequestParameter('spousenameflag'));
$family->setSpouseemployer($this->getRequestParameter('spouseemployer'));
$family->setSpouseemployerflag($this->getRequestParameter('spouseemployerflag'));
$family->setSpousetitle($this->getRequestParameter('spousetitle'));
$family->setSpousetitleflag($this->getRequestParameter('spousetitleflag'));
$family->setChildren($this->getRequestParameter('children'));
$family->setChildrenflag($this->getRequestParameter('childrenflag'));
$family->save();
$user = $family->getUser();
$user->setCurrentlyat($this->getRequestParameter('currentlyat'));
$user->setCurrentlyatflag($this->getRequestParameter('currentlyatflag'));
$user->save();
return $this->redirect('family/show?id=' . $family->getId());
}