public function validateCurrentDay($value, $field) { $month = $this->CI->input->post($field); $miladiCurrentYear = date('Y'); $miladiCurrentMonth = date('m'); $miladiCurrentDay = date('d'); $currentShamsiDate = JDateTime::toJalali($miladiCurrentYear, $miladiCurrentMonth, $miladiCurrentDay); $shamsiCurrentYear = $currentShamsiDate[0]; $shamsiCurrentMonth = $currentShamsiDate[1]; $shamsiCurrentDay = $currentShamsiDate[2]; if ($month == $shamsiCurrentMonth) { if ($value >= $shamsiCurrentDay && $value <= 31) { return TRUE; } else { $this->CI->form_validation->set_message('validateCurrentDay', "%s {$value} نا معتبر است. تاریخ پرواز باید حداقل مصادف تاریخ روز باشد."); return false; } } else { if ($value <= 31) { return TRUE; } else { $this->CI->form_validation->set_message('validateCurrentDay', "%s {$value} نا معتبر است. تاریخ پرواز باید حداقل مصادف تاریخ روز باشد."); return false; } } }
/** * Get a local date * @param int $timestamp * @param string $format * @param bool $allowInternational * @return bool|string */ public static function getLocalDate($timestamp = NULL, $format = NULL, $allowInternational = true) { if ($timestamp == NULL) { $timestamp = time(); } if ($format == NULL) { $format = DateManager::getDefaultFormat(); } if (DateManager::getCalendarType() == 'Jalali') { return JDateTime::date($format, $timestamp, false); } else { // Do we have the international date formatter? if ($allowInternational && Config::GetSetting('USE_INTL_DATEFORMAT') == 1 && Config::CheckIntlDateFormat()) { $formatter = new IntlDateFormatter(Config::GetSetting('DEFAULT_LANGUAGE'), IntlDateFormatter::FULL, IntlDateFormatter::FULL, Config::GetSetting('DEFAULT_TIMEZONE'), IntlDateFormatter::GREGORIAN, $format); return $formatter->format($timestamp); } else { return date($format, $timestamp); } } }
protected static function getSecondString(JDateTime $date) { return NumberToStringConverter::toString($date->getSecond()); }