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

This commit is contained in:
Ralf Becker 2003-11-03 12:03:17 +00:00
parent 7e8ba5b6c5
commit 5d922e91f1
2 changed files with 28 additions and 1 deletions

View File

@ -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'

View File

@ -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 "<p>jscalendar::input2date('$datestr') ".print_r($fields,True)."</p>\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(