Using egw_time for date/time handling; handle unrecognized timezones like 'Westeuropäische Sommerzeit' by splitting them off, when strtotime failes

This commit is contained in:
Klaus Leithoff 2010-08-30 14:30:49 +00:00
parent 57e1782236
commit 50ac49a195
3 changed files with 34 additions and 13 deletions

View File

@ -1998,7 +1998,7 @@
$retValue['header'][$sortOrder[$uid]]['subject'] = $this->decode_subject($headerObject['SUBJECT']);
$retValue['header'][$sortOrder[$uid]]['size'] = $headerObject['SIZE'];
$retValue['header'][$sortOrder[$uid]]['date'] = strtotime($headerObject['DATE']);
$retValue['header'][$sortOrder[$uid]]['date'] = self::_strtotime($headerObject['DATE']);
$retValue['header'][$sortOrder[$uid]]['mimetype'] = $headerObject['MIMETYPE'];
$retValue['header'][$sortOrder[$uid]]['id'] = $headerObject['MSG_NUM'];
$retValue['header'][$sortOrder[$uid]]['uid'] = $headerObject['UID'];
@ -2806,7 +2806,7 @@
if ( preg_match('/\b'.$identity->emailAddress.'\b/',$headers['TO']) ) {
$send->From = $identity->emailAddress;
$send->FromName = $identity->realName;
error_log('Not Default '.$send->From);
error_log('using identity for send from:'.$send->From.' to match header information:'.$headers['TO']);
break;
}
if($identity->default) {
@ -2929,4 +2929,22 @@
$needle = '/(=[0-9][A-F])|(=[A-F][0-9])|(=[A-F][A-F])|(=[0-9][0-9])/';
return preg_match("$needle",$string);
}
/**
* Helper function to handle wrong or unrecognized timezones
*/
static function _strtotime($date='')
{
if (strtotime($date)===false)
{
$dtarr = explode(' ',$date);
$test = false;
while ($test===false)
{
array_pop($dtarr);
$test=strtotime(implode(' ',$dtarr));
if ($test) $date = implode(' ',$dtarr);
}
}
return $date;
}
}

View File

@ -445,9 +445,9 @@
} else {
$this->t->set_var("bcc_data_part",'');
}
$headerdate = new egw_time(bofelamimail::_strtotime($headers['DATE']));
$this->t->set_var("date_received",
@htmlspecialchars($GLOBALS['egw']->common->show_date(strtotime($headers['DATE'])),
@htmlspecialchars($headerdate->format($GLOBALS['egw_info']['user']['preferences']['common']['dateformat']).' - '.$headerdate->format('H:i:s'),
ENT_QUOTES,$this->displayCharset));
$this->t->set_var("subject_data",
@ -1426,9 +1426,9 @@
} else {
$this->t->set_var("cc_data_part",'');
}
$headerdate = new egw_time(bofelamimail::_strtotime($headers['DATE']));
$this->t->set_var("date_data",
@htmlspecialchars($GLOBALS['egw']->common->show_date(strtotime($headers['DATE'])), ENT_QUOTES,$this->displayCharset));
@htmlspecialchars($headerdate->format($GLOBALS['egw_info']['user']['preferences']['common']['dateformat']).' - '.$headerdate->format('H:i:s'), ENT_QUOTES,$this->displayCharset));
// link to go back to the message view. the link differs if the print was called from a normal viewing window, or from compose
$subject = @htmlspecialchars($this->bofelamimail->decode_subject(preg_replace($nonDisplayAbleCharacters, '', $envelope['SUBJECT'])), ENT_QUOTES, $this->displayCharset);

View File

@ -399,13 +399,15 @@
$this->t->set_var('message_counter', $i);
$this->t->set_var('message_uid', $header['uid']);
if ($dateToday == date('Y-m-d', $header['date'])) {
$this->t->set_var('date', $GLOBALS['egw']->common->show_date($header['date'],'H:i:s'));
$headerdate = new egw_time($header['date']);
if ($dateToday == $headerdate->format('Y-m-d')) {
$this->t->set_var('date', $headerdate->format('H:i:s')); //$GLOBALS['egw']->common->show_date($header['date'],'H:i:s'));
} else {
$this->t->set_var('date', $GLOBALS['egw']->common->show_date($header['date'],$GLOBALS['egw_info']['user']['preferences']['common']['dateformat']));
$this->t->set_var('date', $headerdate->format($GLOBALS['egw_info']['user']['preferences']['common']['dateformat']));
}
$this->t->set_var('datetime', $GLOBALS['egw']->common->show_date($header['date']/*,$GLOBALS['egw_info']['user']['preferences']['common']['dateformat']*/));
$this->t->set_var('datetime', $headerdate->format($GLOBALS['egw_info']['user']['preferences']['common']['dateformat']).
' - '.$headerdate->format('H:i:s'));
$this->t->set_var('size', $this->show_readable_size($header['size']));
if ($firstuid === null)
@ -634,13 +636,14 @@
'uid' => $headerData['uid'],
'mailbox' => base64_encode($_folderName)
);
$headerdate = new egw_time($headerData['date']);
//_debug_array($GLOBALS['egw']->link('/index.php',$linkData));
$IFRAMEBody = "<TABLE BORDER=\"1\" rules=\"rows\" style=\"table-layout:fixed;width:100%;\">
<TR class=\"th\" style=\"width:100%;\">
<TD nowrap valign=\"top\" style=\"overflow:hidden;\">
".($_folderType > 0?lang('to'):lang('from')).':<b>'.$full_address.' '.($fromAddress?$fromAddress:'') .'</b><br> '.
lang('date').':<b>'.$GLOBALS['egw']->common->show_date($headerData['date']/*,$GLOBALS['egw_info']['user']['preferences']['common']['dateformat']*/)."</b><br>
lang('date').':<b>'.$headerdate->format($GLOBALS['egw_info']['user']['preferences']['common']['dateformat']).
' - '.$headerdate->format('H:i:s')."</b><br>
".lang('subject').":<b>".$subject."</b>
</TD>
<td style=\"width:20px;\" align=\"right\">