Commit 7123201b authored by stimpy's avatar stimpy
Browse files

convert utc to and from local timezone

parent ddd208d5
......@@ -181,6 +181,11 @@
$msg['SUBJECT'][0] = $this->mime_decode( $msg['SUBJECT'][0] );
}
$tz = 0;
if ( array_key_exists( 'TZUTCINFO', $msg ) ) {
$msg['datewritten'] = $this->utctime( $msg['datewritten'], $msg['TZUTCINFO'][0] );
$msg['datereceived'] = $this->utctime( $msg['datereceived'], $msg['TZUTCINFO'][0] );
$msg['dateprocessed'] = $this->utctime( $msg['dateprocessed'], $msg['TZUTCINFO'][0] );
}
$ret[] = $msg;
}
}
......@@ -225,7 +230,7 @@
break;
case 'UTF-8':
case 'UTF-8 4':
$chrs = 'UTF-8';
$chrs = 'UTF8';
break;
case 'IBMPC 2':
case 'IBMPC':
......@@ -290,6 +295,10 @@
foreach ( $flags as $f ) {
$attribute1 = $attribute1 | $this->attributes[$f];
}
$datewritten = $this->localtime( $datewritten, date('O') );
$datereceived = $this->localtime( $datereceived, date('O') );
$dateprocessed = $this->localtime( $dateprocessed, date('O') );
$msgid = $senderaka .' '. dechex($this->crc(time()));
$replyidcrc = ( $replyid == false ? 0 : dechex($this->crc($replyid)) );
......@@ -448,4 +457,30 @@
}
return $input;
}
function utctime( $time, $offset ) {
$pm = substr( $offset, 0, 1 );
if ( ( $pm != '-' ) AND( $pm != '+' ) ) {
$offset = '+'.$offset;
}
$add = (intval( substr( $offset, 1, 2 ) )*3600)+(intval( substr( $offset, 3, 2 ) )*60);
if ( $pm === '-' ) {
$time += $add;
} else {
$time -= $add;
}
return $time;
}
function localtime( $time, $offset ) {
$pm = substr( $offset, 0, 1 );
if ( ( $pm != '-' ) AND( $pm != '+' ) ) {
$offset = '+'.$offset;
}
$add = (intval( substr( $offset, 1, 2 ) )*3600)+(intval( substr( $offset, 3, 2 ) )*60);
if ( $pm === '-' ) {
$time -= $add;
} else {
$time += $add;
}
return $time;
}
}
......@@ -181,6 +181,11 @@
$msg['SUBJECT'][0] = $this->mime_decode( $msg['SUBJECT'][0] );
}
$tz = 0;
if ( array_key_exists( 'TZUTCINFO', $msg ) ) {
$msg['datewritten'] = $this->utctime( $msg['datewritten'], $msg['TZUTCINFO'][0] );
$msg['datereceived'] = $this->utctime( $msg['datereceived'], $msg['TZUTCINFO'][0] );
$msg['dateprocessed'] = $this->utctime( $msg['dateprocessed'], $msg['TZUTCINFO'][0] );
}
$ret[] = $msg;
}
}
......@@ -225,7 +230,7 @@
break;
case 'UTF-8':
case 'UTF-8 4':
$chrs = 'UTF-8';
$chrs = 'UTF8';
break;
case 'IBMPC 2':
case 'IBMPC':
......@@ -290,6 +295,10 @@
foreach ( $flags as $f ) {
$attribute1 = $attribute1 | $this->attributes[$f];
}
$datewritten = $this->localtime( $datewritten, date('O') );
$datereceived = $this->localtime( $datereceived, date('O') );
$dateprocessed = $this->localtime( $dateprocessed, date('O') );
$msgid = $senderaka .' '. dechex($this->crc(time()));
$replyidcrc = ( $replyid == false ? 0 : dechex($this->crc($replyid)) );
......@@ -448,4 +457,30 @@
}
return $input;
}
function utctime( $time, $offset ) {
$pm = substr( $offset, 0, 1 );
if ( ( $pm != '-' ) AND( $pm != '+' ) ) {
$offset = '+'.$offset;
}
$add = (intval( substr( $offset, 1, 2 ) )*3600)+(intval( substr( $offset, 3, 2 ) )*60);
if ( $pm === '-' ) {
$time += $add;
} else {
$time -= $add;
}
return $time;
}
function localtime( $time, $offset ) {
$pm = substr( $offset, 0, 1 );
if ( ( $pm != '-' ) AND( $pm != '+' ) ) {
$offset = '+'.$offset;
}
$add = (intval( substr( $offset, 1, 2 ) )*3600)+(intval( substr( $offset, 3, 2 ) )*60);
if ( $pm === '-' ) {
$time -= $add;
} else {
$time += $add;
}
return $time;
}
}
<?php
require_once( 'assets/include/init.inc.php' );
echo "time: ". time() ."\n";
echo "date: ". date( 'U' ) ."\n";
echo "mktime: ". mktime( date("H"), date("i"), date("s"), date("n"), date("j"), date("Y") ) ."\n";
echo "gmmktime: ". gmmktime( date("H"), date("i"), date("s"), date("n"), date("j"), date("Y") ) ."\n";
\ No newline at end of file
echo "tzinfo: ". date('O') ."\n";
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment