From 5d922e91f1c18d699491d890faa8d937471735ad Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 3 Nov 2003 12:03:17 +0000 Subject: [PATCH] fixed jscalendar to work with date-format 'd-M-Y', for multibyte charsets this needs mbstring and mbstring_overload & 2 (!) to work fully, thought it is usable without --- etemplate/inc/class.date_widget.inc.php | 3 +++ phpgwapi/inc/class.jscalendar.inc.php | 26 ++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/etemplate/inc/class.date_widget.inc.php b/etemplate/inc/class.date_widget.inc.php index 5e17ec0814..3443e47179 100644 --- a/etemplate/inc/class.date_widget.inc.php +++ b/etemplate/inc/class.date_widget.inc.php @@ -83,6 +83,7 @@ $value = array( 'Y' => date('Y',$value), 'm' => date('m',$value), + 'M' => substr(lang(date('F',$value)),0,3), 'd' => date('d',$value), 'H' => date('H',$value), 'i' => date('i',$value) @@ -133,6 +134,7 @@ $types = array( 'Y' => ($options&1 ? 'int' : 'select-year'), // if options&1 set, show an int-field 'm' => 'select-month', + 'M' => 'select-month', 'd' => 'select-day', 'H' => 'select-number', 'i' => 'select-number' @@ -144,6 +146,7 @@ $help = array( 'Y' => 'Year', 'm' => 'Month', + 'M' => 'Month', 'd' => 'Day', 'H' => 'Hour', 'i' => 'Minute' diff --git a/phpgwapi/inc/class.jscalendar.inc.php b/phpgwapi/inc/class.jscalendar.inc.php index c399b260cf..f2740dae30 100644 --- a/phpgwapi/inc/class.jscalendar.inc.php +++ b/phpgwapi/inc/class.jscalendar.inc.php @@ -65,7 +65,11 @@ class jscalendar } if ($year && $month && $day) { - $date = date($this->dateformat,mktime(12,0,0,$month,$day,$year)); + $date = date($this->dateformat,$ts = mktime(12,0,0,$month,$day,$year)); + if (strpos($this->dateformat,'M') !== False) + { + $date = str_replace(date('M',$ts),substr(lang(date('F',$ts)),0,3),$date); + } } if ($helpmsg !== '') { @@ -97,6 +101,7 @@ class jscalendar */ function input2date($datestr,$raw='raw',$day='day',$month='month',$year='year') { + //echo "

jscalendar::input2date('$datestr') ".print_r($fields,True)."

\n"; if ($datestr === '') { return False; @@ -104,6 +109,25 @@ class jscalendar $fields = split('[./-]',$datestr); foreach(split('[./-]',$this->dateformat) as $n => $field) { + if ($field == 'M') + { + if (!is_numeric($fields[$n])) + { + for($i = 1; $i <= 12; $i++) + { + $long_name = date('F',mktime(12,0,0,$i,1,2000)); + $short_name = date('M',mktime(12,0,0,$i,1,2000)); + $translated = lang($long_name); + if ($fields[$n] == $long_name || $fields[$n] == $short_name || + strstr($translated,$fields[$n]) == $translated) // multibyte save + { + $fields[$n] = $i; + break; + } + } + } + $field = 'm'; + } $date[$field] = intval($fields[$n]); } $ret = array(