diff options
Diffstat (limited to 'app/Helper/Datetime.php')
-rw-r--r-- | app/Helper/Datetime.php | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/app/Helper/Datetime.php b/app/Helper/Datetime.php new file mode 100644 index 00000000..3a9c4c48 --- /dev/null +++ b/app/Helper/Datetime.php @@ -0,0 +1,61 @@ +<?php + +namespace Helper; + +/** + * DateTime helpers + * + * @package helper + * @author Frederic Guillot + */ +class Datetime extends \Core\Base +{ + /** + * Get all hours for day + * + * @access public + * @return array + */ + public function getDayHours() + { + $values = array(); + + foreach (range(0, 23) as $hour) { + foreach (array(0, 30) as $minute) { + $time = sprintf('%02d:%02d', $hour, $minute); + $values[$time] = $time; + } + } + + return $values; + } + + /** + * Get all days of a week + * + * @access public + * @return array + */ + public function getWeekDays() + { + $values = array(); + + foreach (range(1, 7) as $day) { + $values[$day] = $this->getWeekDay($day); + } + + return $values; + } + + /** + * Get the localized day name from the day number + * + * @access public + * @param integer $day Day number + * @return string + */ + public function getWeekDay($day) + { + return dt('%A', strtotime('next Monday +'.($day - 1).' days')); + } +} |