|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
-
- namespace Lc\SovBundle\Component;
-
- class DateComponent
- {
- public function date($format, $timestamp)
- {
- setlocale(LC_TIME, 'fr_FR.UTF8', 'fr.UTF8', 'fr_FR.UTF-8', 'fr.UTF-8');
- return strftime($format, $timestamp);
- }
-
- public function getNextDay($day)
- {
- return new \DateTime('next ' . $day);
- }
-
- public function getNextDayByNumber($number)
- {
- return $this->getNextDay($this->getDayByNumber($number, 'en'));
- }
-
- public function getDayByNumber($number, $lang = 'fr')
- {
- if ($lang == 'fr') {
- $daysArray = [
- 1 => 'Lundi',
- 2 => 'Mardi',
- 3 => 'Mercredi',
- 4 => 'Jeudi',
- 5 => 'Vendredi',
- 6 => 'Samedi',
- 7 => 'Dimanche'
- ];
- } else {
- $daysArray = [
- 1 => 'Monday',
- 2 => 'Tuesday',
- 3 => 'Wednesday',
- 4 => 'Thursday',
- 5 => 'Friday',
- 6 => 'Saturday',
- 7 => 'Sunday',
- ];
- }
-
- if (isset($daysArray[$number])) {
- return $daysArray[$number];
- }
-
- return '';
- }
-
- // getDeliverySlotHour
- public function getHour(\DateTime $date)
- {
- $timestamp = $date->getTimestamp() ;
- $hour = $this->date('%kh', $timestamp) ;
- $minutes = $this->date('%M', $timestamp) ;
-
- if($minutes != '00') {
- $hour .= $minutes ;
- }
-
- return $hour ;
- }
-
- }
|