/** * Return a text field linked to a datepicker (see frequency-decoder.com) * The date format is set according to the current locale that may have been set with the DateTool :: set_current_locale() method. * * When the date is entered manually in the textbox, the date is automatically completed when the textbox loose focus * ex: '10.08' => automatically completed to '10.08.2010' * '10' => automatically completed to '10.08.2010' * * @param string $fieldname * @param array $options */ public function input_date($fieldname, $options = array()) { $this->AlaxosHtml->include_js_datepicker(); $this->AlaxosHtml->include_js_jquery(); $this->AlaxosHtml->include_js_jquery_no_conflict(); $this->AlaxosHtml->include_js_alaxos(); /* * include CSS needed to show the datepicker */ $this->AlaxosHtml->css('/alaxos/css/datepicker', null, array('inline' => false)); /* * Set the class attribute needed to display the datepicker * The class has to be retrieved from a PHP function, because it depends on the current locale */ if (!array_key_exists('class', $options)) { $options = array_merge($options, array('class' => $this->get_datepicker_css_class())); } if (!array_key_exists('value', $options)) { $options = $this->value($options, $fieldname); $options['value'] = DateTool::sql_to_date($options['value']); } // $options['readonly'] = 'true'; if (!array_key_exists('maxlength', $options)) { $options['maxlength'] = '10'; } $input_field = $this->text($fieldname, $options); $input_field .= $this->_get_validation_error_zone($this->_get_validation_error($fieldname)); return $input_field; }
function format_date_interval($dateStr, $separator = ' - ', $locale = null) { $dateStr = trim($dateStr); $separator_pos = strpos($dateStr, $separator); if ($separator_pos !== false) { $first_date = substr($dateStr, 0, $separator_pos); $second_date = substr($dateStr, $separator_pos + strlen($separator)); return DateTool::sql_to_date($first_date, $locale) . ' - ' . DateTool::sql_to_date($second_date, $locale); } else { return DateTool::sql_to_date($dateStr, $locale); } }