mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-25 09:23:28 +01:00
ImportExport: Another fix for exporting custom date fields with custom format.
- PHP base DateTime class was being used instead of our own Api\DateTime - User's preferred date format was not being respected - Custom formatting was only parsed if the first entry had a value in that field
This commit is contained in:
parent
e3aad386e0
commit
947755676e
@ -246,16 +246,17 @@ class importexport_export_csv implements importexport_iface_export_record
|
|||||||
switch($c_field['type']) {
|
switch($c_field['type']) {
|
||||||
case 'date':
|
case 'date':
|
||||||
case 'date-time':
|
case 'date-time':
|
||||||
if ($c_field['values']['format'] && (is_array($record) ? $record[$name] : $record->$name))
|
if ($c_field['values']['format'])
|
||||||
{
|
{
|
||||||
// Date has custom format. Convert so it's standard, don't do normal processing
|
// Date has custom format. Convert so it's standard, don't do normal processing
|
||||||
|
$type = $c_field['type'];
|
||||||
$format = $c_field['values']['format'];
|
$format = $c_field['values']['format'];
|
||||||
$methods[$name] = function($val) use ($format)
|
$methods[$name] = function($val) use ($type, $format)
|
||||||
{
|
{
|
||||||
$date = Api\DateTime::createFromFormat($format, $val, Api\DateTime::$user_timezone);
|
$date = Api\DateTime::createFromFormat($format, $val, Api\DateTime::$user_timezone);
|
||||||
if($date)
|
if($date)
|
||||||
{
|
{
|
||||||
return $date->format(APi\DateTime::DATABASE);
|
return Api\DateTime::to($date, $type == 'date' ? true : '');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user