mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-27 16:29:22 +01:00
- Test multiple options for date format, stop when one works - Avoid deprecated format_datetime(), only format if there is a value
This commit is contained in:
parent
b09b90b8db
commit
1b30ed3870
@ -197,7 +197,7 @@ abstract class bo_merge
|
|||||||
switch($name)
|
switch($name)
|
||||||
{
|
{
|
||||||
case 'created': case 'modified':
|
case 'created': case 'modified':
|
||||||
$value = $this->format_datetime($value);
|
if($value) $value = egw_time::to($value);
|
||||||
break;
|
break;
|
||||||
case 'bday':
|
case 'bday':
|
||||||
if ($value)
|
if ($value)
|
||||||
@ -375,6 +375,7 @@ abstract class bo_merge
|
|||||||
*/
|
*/
|
||||||
protected function format_datetime($time,$format=null)
|
protected function format_datetime($time,$format=null)
|
||||||
{
|
{
|
||||||
|
trigger_error(__METHOD__ . ' is deprecated, use egw_time::to($time, $format)', E_USER_DEPRECATED);
|
||||||
if (is_null($format)) $format = $this->datetime_format;
|
if (is_null($format)) $format = $this->datetime_format;
|
||||||
|
|
||||||
return egw_time::to($time,$format);
|
return egw_time::to($time,$format);
|
||||||
@ -1045,6 +1046,13 @@ abstract class bo_merge
|
|||||||
//'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'//Excel WTF
|
//'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'//Excel WTF
|
||||||
))) return;
|
))) return;
|
||||||
|
|
||||||
|
// Some different formats dates could be in, depending what they've been through
|
||||||
|
$formats = array(
|
||||||
|
'!'.egw_time::$user_dateformat . ' ' .egw_time::$user_timeformat.':s',
|
||||||
|
'!'.egw_time::$user_dateformat . '* ' .egw_time::$user_timeformat,
|
||||||
|
'!'.egw_time::$user_dateformat . '*',
|
||||||
|
);
|
||||||
|
|
||||||
// Properly format values for spreadsheet
|
// Properly format values for spreadsheet
|
||||||
foreach($names as $idx => &$field)
|
foreach($names as $idx => &$field)
|
||||||
{
|
{
|
||||||
@ -1054,15 +1062,26 @@ abstract class bo_merge
|
|||||||
{
|
{
|
||||||
if(!is_numeric($values[$key]))
|
if(!is_numeric($values[$key]))
|
||||||
{
|
{
|
||||||
try {
|
// Try the different formats, stop when one works
|
||||||
$date = egw_time::createFromFormat(
|
foreach($formats as $f)
|
||||||
'!'.egw_time::$user_dateformat . ' ' .egw_time::$user_timeformat.':s',
|
{
|
||||||
$values[$key],
|
try {
|
||||||
egw_time::$user_timezone
|
$date = egw_time::createFromFormat(
|
||||||
);
|
$f,
|
||||||
} catch (Exception $e) {
|
$values[$key],
|
||||||
|
egw_time::$user_timezone
|
||||||
|
);
|
||||||
|
if($date) break;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$date)
|
||||||
|
{
|
||||||
// Couldn't get a date out of it... skip it
|
// Couldn't get a date out of it... skip it
|
||||||
trigger_error("Unable to parse date $key = '{$values[$key]}' - left as text", E_USER_NOTICE);
|
trigger_error("Unable to parse date $key = '{$values[$key]}' - left as text", E_USER_NOTICE);
|
||||||
|
unset($names[$idx]);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user