l($weekday, 'weekdays'); } /** * @param $weekday_index * @param $short_form * @param $module_instance * @return mixed|string */ public static function getWeekdayTranslatedByIndex($weekday_index, $short_form, $module_instance) { $weekday_name = $module_instance->l(self::$weekday_map[$weekday_index], 'weekdays'); if ($weekday_name == '') { $weekday_name = self::$weekday_map[$weekday_index]; } if ($short_form === true) { $weekday_name = Tools::substr($weekday_name, 0, 3); } return $weekday_name; } /** * @param $month_index * @param $short_form * @param $module_instance * @return mixed|string */ public static function getMonthNameTranslatedByIndex($month_index, $short_form, $module_instance) { $month_index -= 1; $month_name = $module_instance->l(self::$month_map[$month_index], 'months'); if ($month_name == '') { $month_name = self::$month_map[$month_index]; } if ($short_form === true) { $month_name = Tools::substr($month_name, 0, 3); } return $month_name; } /** * Determine if a date time string represents the epoch date time * @param $str_datetime * @return bool */ public static function isStrDateTimeEpoch($str_datetime) { if ($str_datetime == '1970-01-01 00:00:00' || $str_datetime == '0000-00-00 00:00:00' || $str_datetime == '1970-01-01') { error_log('epoch'); return true; } else { return false; } } /** * @param $date (YYYY-MM-DD) * @return bool * @throws Exception */ public static function isDateInPast($date) { $date = new DateTime($date); $now = new DateTime(date('Y-m-d')); if ($date < $now) { return true; } return false; } /** * ghet date of the first day of week for the given date * @param $date * @return string */ public static function getFirstDayOfWeekDate($date) { $day = DateTime::createFromFormat('Y-m-d', $date); $day->setISODate((int)$day->format('o'), (int)$day->format('W'), 1); return $day->format('Y-m-d'); } /** * return the start date of the week number specified * @param $week * @param $year * @return false|string */ public static function getStartDateByWeekNumber($week, $year) { $start_Date = date("Y-m-d", strtotime($year . 'W' . str_pad($week, 2, 0, STR_PAD_LEFT))); return $start_Date; } /** * get number of weeks 9in a year * @param $year * @return int */ public static function getNumberOfWeeksInYear($year) { // december 28th is always in the last week of the year return date('W', strtotime($year.'-12-28')); } }