mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 16:44:07 +01:00
Better handling of date-times without times, prevent double-conversion to server time
This commit is contained in:
parent
aef04880e9
commit
caec90f104
@ -316,37 +316,50 @@ class importexport_import_csv implements importexport_iface_import_record { //,
|
||||
}
|
||||
}
|
||||
foreach((array)$fields['date-time'] as $name) {
|
||||
if ($record[$name] && !is_numeric($record[$name])) {
|
||||
if ($record[$name] && !is_numeric($record[$name]))
|
||||
{
|
||||
// Need to handle format first
|
||||
if($format == 1)
|
||||
{
|
||||
$formatted = egw_time::createFromFormat(
|
||||
'!'.egw_time::$user_dateformat . '*' .egw_time::$user_timeformat,
|
||||
$record[$name]
|
||||
'!'.egw_time::$user_dateformat . ' ' .egw_time::$user_timeformat,
|
||||
$record[$name],
|
||||
egw_time::$user_timezone
|
||||
);
|
||||
|
||||
if(!$formatted && $errors = egw_time::getLastErrors())
|
||||
{
|
||||
// Try again, more options
|
||||
try {
|
||||
$formatted = new egw_time($record[$name]);
|
||||
} catch (Exception $e) {
|
||||
$warnings[] = $name.': ' . $e->getMessage();
|
||||
continue;
|
||||
}
|
||||
$errors = egw_time::getLastErrors();
|
||||
foreach($errors['errors'] as $char => $msg)
|
||||
// Try again, without time
|
||||
$formatted = egw_time::createFromFormat(
|
||||
'!'.egw_time::$user_dateformat,
|
||||
trim($record[$name]),
|
||||
egw_time::$user_timezone
|
||||
);
|
||||
|
||||
if(!$formatted && $errors = egw_time::getLastErrors())
|
||||
{
|
||||
$warnings[] = "$name: [$char] $msg";
|
||||
// Try again, anything goes
|
||||
try {
|
||||
$formatted = new egw_time($record[$name]);
|
||||
} catch (Exception $e) {
|
||||
$warnings[] = $name.': ' . $e->getMessage();
|
||||
continue;
|
||||
}
|
||||
$errors = egw_time::getLastErrors();
|
||||
foreach($errors['errors'] as $char => $msg)
|
||||
{
|
||||
$warnings[] = "$name: [$char] $msg";
|
||||
}
|
||||
}
|
||||
}
|
||||
if($errors = egw_time::getLastErrors() && $errors['error_count'] == 0)
|
||||
if($formatted)
|
||||
{
|
||||
$record[$name] = $formatted->getTimestamp();
|
||||
// Timestamp is apparently in server time, but apps will do the same conversion
|
||||
$record[$name] = egw_time::server2user($record[$name],'ts');
|
||||
}
|
||||
}
|
||||
|
||||
$record[$name] = egw_time::user2server($record[$name],'ts');
|
||||
if(is_array(self::$cf_parse_cache[$appname][0]['date-time']) &&
|
||||
in_array($name, self::$cf_parse_cache[$appname][0]['date-time'])) {
|
||||
// Custom fields stored in a particular format (from customfields_widget)
|
||||
@ -365,7 +378,7 @@ class importexport_import_csv implements importexport_iface_import_record { //,
|
||||
$record[$name] = $formatted->getTimestamp();
|
||||
}
|
||||
}
|
||||
$record[$name] = egw_time::user2server($record[$name],'ts');
|
||||
$record[$name] = egw_time::server2user($record[$name],'ts');
|
||||
if(is_array(self::$cf_parse_cache[$appname][0]['date']) &&
|
||||
in_array($name, self::$cf_parse_cache[$appname][0]['date'])) {
|
||||
// Custom fields stored in a particular format (from customfields_widget)
|
||||
|
Loading…
Reference in New Issue
Block a user