本文整理汇总了PHP中Cake\I18n\Time::defaultLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP Time::defaultLocale方法的具体用法?PHP Time::defaultLocale怎么用?PHP Time::defaultLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\I18n\Time
的用法示例。
在下文中一共展示了Time::defaultLocale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeFilter
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
Time::$defaultLocale = 'en-CA';
Time::setToStringFormat('YYYY-MM-dd');
$this->Session = $this->request->session();
$this->set('Session', $this->Session);
$this->_icons = $this->Utilities->setIcons();
$this->set('icons', $this->_icons);
$title = $this->Utilities->setDefaultTitle();
$breadcrumbs = $this->Utilities->setDefaultBreadcrumbs();
$this->set(compact('title', 'breadcrumbs'));
if (empty($this->request->params['prefix'])) {
$this->Auth->allow();
$this->viewBuilder()->layout('public');
}
// Set the user logged in
if (!is_null($this->Auth->user('id'))) {
$Users = TableRegistry::get('Users');
$this->_user = $Users->get($this->Auth->user('id'));
$this->set('authUser', $this->_user);
} else {
$this->set('authUser', false);
}
// $this->set(compact($authUser));
$nav = $this->_setNav();
$this->set(compact('nav'));
}
示例2: setUp
/**
* setUp method
*
* @return void
*/
public function setUp()
{
parent::setUp();
$this->View = new View();
$this->Time = new TimeHelper($this->View);
Time::$defaultLocale = 'en_US';
}
示例3: initialize
/**
* Initialization hook method.
*
* Use this method to add common initialization code like loading components.
*
* e.g. `$this->loadComponent('Security');`
*
* @return void
*/
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler');
$this->loadComponent('Flash');
$this->loadComponent('Auth', ['authorize' => ['Controller'], 'loginRedirect' => ['controller' => 'Pages', 'action' => 'display', 'home'], 'logoutRedirect' => ['controller' => 'Pages', 'action' => 'display', 'home']]);
Time::$defaultLocale = 'fr-FR';
}
示例4: initialize
/**
* Initialization hook method.
*
* Use this method to add common initialization code like loading components.
*
* @return void
*/
public function initialize()
{
parent::initialize();
$this->loadComponent('Flash');
$this->loadComponent('Paginator');
Time::$defaultLocale = 'es-ES';
Time::setToStringFormat('dd-MM-YYYY HH:mm');
}
示例5: initialize
/**
* Initialization hook method.
*
* Use this method to add common initialization code like loading components.
*
* e.g. `$this->loadComponent('Security');`
*
* @return void
*/
public function initialize()
{
$this->loadComponent('Flash');
$this->loadComponent('RequestHandler');
// added in line to format date correctly
Time::$defaultLocale = 'en-AU';
Time::setToStringFormat('dd/MM/YYYY');
$this->loadComponent('Auth', ['authorize' => ['Controller'], 'authenticate' => ['Form' => ['fields' => ['username' => 'email', 'password' => 'password']]], 'loginRedirect' => ['controller' => 'pages', 'action' => 'home'], 'logoutRedirect' => ['controller' => 'Pages', 'action' => 'display', 'home']]);
}
示例6: initialize
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler');
$this->loadComponent('Flash');
$this->loadComponent('Auth', ['authorize' => ['Controller'], 'loginRedirect' => ['controller' => 'Characters', 'action' => 'index'], 'logoutRedirect' => ['controller' => 'Users', 'action' => 'login']]);
$this->loadComponent('Cookie');
$this->loadComponent('Slack', ['webhook_url' => Configure::read('Slack.webhook_url'), 'enabled' => Configure::read('Slack.enabled')]);
Time::$defaultLocale = 'en-GB';
}
示例7: tearDown
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
parent::tearDown();
Time::setTestNow($this->now);
Time::$defaultLocale = $this->locale;
Time::resetToStringFormat();
FrozenTime::setTestNow($this->frozenNow);
FrozenTime::$defaultLocale = $this->locale;
FrozenTime::resetToStringFormat();
date_default_timezone_set('UTC');
}
示例8: viewAllInfo
/**
* viewAllInfo method
*
* @author Gustavo Marques | Genival Rocha | Caroline Machado
* @param UUID $idlotebandejas Primary key loteBandejas.
* @return void
*/
public function viewAllInfo($idlotebandejas = null)
{
Time::$defaultLocale = 'pt-BR';
$this->loadModel('Alimentacao');
$alimeQuery = $this->Alimentacao->find('all')->where(['fk_lotebandejas' => $idlotebandejas]);
$lotebandeja = $this->Lotebandejas->get($idlotebandejas, ['contain' => []]);
$this->paginate = ['maxLimit' => 11];
$this->set('alimentacao', $this->paginate($alimeQuery));
$this->set('lotebandeja', $lotebandeja);
$this->set('_serialize', ['lotebandeja']);
}
示例9: list_add
/**
* list_add method
* @author Gustavo Marques | Genival Rocha | Caroline Machado
* @param string|null $idBequer Bequer id, string|null $idBequer Numero do Bequer
* @return void Redireciona para mesma pagina.
*/
public function list_add($idBequer = null, $n_bequer = null)
{
Time::$defaultLocale = 'pt-BR';
$ovosQuery = $this->Ovos->find('all')->where(['fk_bequer' => $idBequer]);
$this->paginate = ['maxLimit' => 3];
$this->set('ListOvos', $this->paginate($ovosQuery));
$ovo = $this->Ovos->newEntity();
$this->set('n_bequer', $n_bequer);
if ($this->request->is('post')) {
$ovo = $this->Ovos->patchEntity($ovo, $this->request->data);
$ovo->set(['fk_bequer' => $idBequer]);
if ($this->Ovos->save($ovo)) {
$this->Flash->success('Ovo salvo com sucesso.');
return $this->redirect(['action' => 'list_add', $idBequer, $n_bequer]);
} else {
$this->Flash->error('Não foi possível salvar o ovo. Por favor, tente novamente.');
}
}
$this->set(compact('ovo'));
$this->set('_serialize', ['ovo']);
}
示例10: list_add
/**
* list_add method
* @author Gustavo Marques | Genival Rocha | Caroline Machado
* @param UUID|null idAlimentacao Alimentacao id, UUID|null $fk_lotebandejas Foreign key lotebandejas, int|null $n_bandeja Numero da bandeja
* @return void Redireciona para mesma pagina.
*/
public function list_add($fk_lotebandejas = null, $n_bandeja = null)
{
Time::$defaultLocale = 'pt-BR';
$alimentacaoQuery = $this->Alimentacao->find('all')->where(['fk_lotebandejas' => $fk_lotebandejas]);
$this->paginate = ['maxLimit' => 3];
$this->set('ListAlimentacao', $this->paginate($alimentacaoQuery));
$alimentacao = $this->Alimentacao->newEntity();
$this->set('n_bandeja', $n_bandeja);
if ($this->request->is('post')) {
$alimentacao = $this->Alimentacao->patchEntity($alimentacao, $this->request->data);
$alimentacao->set(['fk_lotebandejas' => $fk_lotebandejas]);
if ($this->Alimentacao->save($alimentacao)) {
$this->Flash->success('Cadastro de Alimentação adicionado com sucesso.');
return $this->redirect(['action' => 'list_add', $fk_lotebandejas, $n_bandeja]);
} else {
$this->Flash->error('Não foi possível adicionar o cadastro de alimentação. Por favor, tente novamente.');
}
}
$this->set(compact('alimentacao'));
$this->set('_serialize', ['alimentacao']);
}
示例11: add
/**
* Add method
*
* @return void Redirects on successful add, renders view otherwise.
*/
public function add()
{
Time::$defaultLocale = 'pt-BR';
$this->loadModel('Lotetransporte');
$lotesDisponiveis = $this->Lotetransporte->find('all');
$lotesList = $lotesDisponiveis->find('list', ['value' => 'lotetransporteid', 'valueField' => 'n_transporte']);
$this->set('optionLotes', $lotesList);
$temperaturatransporte = $this->Temperaturatransporte->newEntity();
if ($this->request->is('post')) {
$temperaturatransporte = $this->Temperaturatransporte->patchEntity($temperaturatransporte, $this->request->data);
$hora_leitura = $this->request->data('hora_leitura');
$temperaturatransporte->set(['hora_leitura' => $hora_leitura['hour'] . ':' . $hora_leitura['minute']]);
if ($this->Temperaturatransporte->save($temperaturatransporte)) {
$this->Flash->success('The temperaturatransporte has been saved.');
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error('The temperaturatransporte could not be saved. Please, try again.');
}
}
$this->set(compact('temperaturatransporte'));
$this->set('_serialize', ['temperaturatransporte']);
}
示例12: add
/**
* Add method
*
* @author Gustavo Marques | Genival Rocha | Caroline Machado
* @return void Redirects on successful add, renders view otherwise.
*/
public function add()
{
Time::$defaultLocale = 'pt-BR';
$this->loadModel('Lotebandejas');
$this->loadModel('Bequer');
//$lotesRecentes = $this->Lotebandejas->find('all', ['fields' => 'codigo']);
$lotesDisponiveis = $this->Lotebandejas->find('all')->join(['table' => 'montagem', 'type' => 'LEFT', 'alias' => 'c', 'conditions' => ['c.fk_lotebandejas = lotebandejas.lotebandejasid']])->where(['c.fk_bequer IS NULL']);
$lotesList = $lotesDisponiveis->find('list', ['value' => 'lotebandejasid', 'valueField' => 'codigo']);
$this->set('optionLotes', $lotesList);
$bequerList = $this->Bequer->find('list', ['value' => 'bequerid', 'valueField' => 'n_bequer', 'order' => ['n_bequer' => 'desc']]);
$this->set('optionBequer', $bequerList);
$montagem = $this->Montagem->newEntity();
if ($this->request->is('post')) {
$arrayBequer = $this->request->data('list_bequer');
if ($arrayBequer == '') {
$this->Flash->error('Por favor selecione um béquer.');
} else {
$lotebandejasForm = $this->request->data('fk_lotebandejas');
$lotebandejasQuery = $this->Lotebandejas->get($lotebandejasForm);
$tipoBandejaConst = $this->request->data('tipo_bandeja') . $lotebandejasQuery->codigo;
foreach ($arrayBequer as $value) {
$montagem = $this->Montagem->newEntity();
$montagem = $this->Montagem->patchEntity($montagem, $this->request->data);
$montagem->set(['fk_bequer' => $value]);
$montagem->set(['tipo_bandeja' => $tipoBandejaConst]);
if ($this->Montagem->save($montagem)) {
$this->Flash->success('Cadastro de montagem adicionado com sucesso.');
} else {
$this->Flash->error('Não foi possível adicionar o cadastro de montagem. Por favor, tente novamente.');
}
}
return $this->redirect(['action' => 'index']);
}
}
$this->set(compact('montagem'));
$this->set('_serialize', ['montagem']);
}
示例13: testParseDateDifferentTimezone
/**
* Tests that parsing a date respects de default timezone in PHP.
*
* @return void
*/
public function testParseDateDifferentTimezone()
{
date_default_timezone_set('Europe/Paris');
Time::$defaultLocale = 'fr-FR';
$result = Time::parseDate('12/03/2015');
$this->assertEquals('2015-03-12', $result->format('Y-m-d'));
$this->assertEquals(new \DateTimeZone('Europe/Paris'), $result->tz);
}
示例14: testFormat
/**
* test formatting dates taking in account preferred i18n locale file
*
* @return void
*/
public function testFormat()
{
$time = strtotime('Thu Jan 14 13:59:28 2010');
$result = $this->Time->format($time);
$expected = '1/14/10, 1:59 PM';
$this->assertTimeFormat($expected, $result);
$result = $this->Time->format($time, \IntlDateFormatter::FULL);
$expected = 'Thursday, January 14, 2010 at 1:59:28 PM GMT';
$this->assertTimeFormat($expected, $result);
$result = $this->Time->format('invalid date', null, 'Date invalid');
$expected = 'Date invalid';
$this->assertEquals($expected, $result);
I18n::locale('fr_FR');
Time::$defaultLocale = 'fr_FR';
$time = new \Cake\I18n\FrozenTime('Thu Jan 14 13:59:28 2010');
$result = $this->Time->format($time, \IntlDateFormatter::FULL);
$expected = 'jeudi 14 janvier 2010 13:59:28 UTC';
$this->assertTimeFormat($expected, $result);
}
示例15: testToString
/**
* Tests that __toString uses the i18n formatter
*
* @return void
*/
public function testToString()
{
$time = new Time('2014-04-20 22:10');
Time::$defaultLocale = 'fr-FR';
Time::setToStringFormat(\IntlDateFormatter::FULL);
$this->assertTimeFormat('dimanche 20 avril 2014 22:10:00 UTC', (string) $time);
}