[pLog-svn] r2165 - plog/branches/plog-1.0.2/class/data
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Sun Jun 5 10:52:02 GMT 2005
Author: oscar
Date: 2005-06-05 10:52:01 +0000 (Sun, 05 Jun 2005)
New Revision: 2165
Modified:
plog/branches/plog-1.0.2/class/data/Date.class.php
Log:
Backported Ben's memory optimization for this class.
Modified: plog/branches/plog-1.0.2/class/data/Date.class.php
===================================================================
--- plog/branches/plog-1.0.2/class/data/Date.class.php 2005-06-05 10:51:13 UTC (rev 2164)
+++ plog/branches/plog-1.0.2/class/data/Date.class.php 2005-06-05 10:52:01 UTC (rev 2165)
@@ -23,7 +23,7 @@
/**@#+
* Include supporting classes
*/
-require_once PLOG_CLASS_PATH.'class/data/Date/TimeZone.class.php';
+// require_once PLOG_CLASS_PATH.'class/data/Date/TimeZone.class.php';
require_once PLOG_CLASS_PATH.'class/data/Date/Calc.class.php';
require_once PLOG_CLASS_PATH.'class/data/Date/Span.class.php';
/**@#-*/
@@ -112,7 +112,9 @@
*/
var $tz;
+ var $offset = '+ 00:00';
+
/**
* Constructor
*
@@ -129,7 +131,7 @@
*/
function Date($date = null)
{
- $this->tz = Date_TimeZone::getDefault();
+ $this->tz = 'UTC';
if (is_null($date)) {
$this->setDate(date("Y-m-d H:i:s"));
} elseif (is_a($date, 'Date')) {
@@ -176,6 +178,7 @@
// so it has to store it as UTC
if (isset($regs[9])) {
$this->toUTCbyOffset($regs[9]);
+ $this->offset = $regs[9];
}
} elseif (is_numeric($date)) {
// UNIXTIME
@@ -210,23 +213,23 @@
break;
case DATE_FORMAT_ISO_BASIC:
$format = "%Y%m%dT%H%M%S";
- if ($this->tz->getID() == 'UTC') {
+ //if ($this->tz->getID() == 'UTC') {
$format .= "Z";
- }
+ //}
return $this->format($format);
break;
case DATE_FORMAT_ISO_EXTENDED:
$format = "%Y-%m-%dT%H:%M:%S";
- if ($this->tz->getID() == 'UTC') {
+ //if ($this->tz->getID() == 'UTC') {
$format .= "Z";
- }
+ //}
return $this->format($format);
break;
case DATE_FORMAT_ISO_EXTENDED_MICROTIME:
$format = "%Y-%m-%dT%H:%M:%s";
- if ($this->tz->getID() == 'UTC') {
+ //if ($this->tz->getID() == 'UTC') {
$format .= "Z";
- }
+ //}
return $this->format($format);
break;
case DATE_FORMAT_TIMESTAMP:
@@ -357,6 +360,9 @@
$output .= "\n";
break;
case "O":
+ // :TODO: fix me .. this is just a hack right now, we need to calculate the correct offset
+ $output .= $this->offset;
+ break;
$offms = $this->tz->getOffset($this);
$direction = $offms >= 0 ? "+" : "-";
$offmins = abs($offms) / 1000 / 60;
@@ -365,6 +371,8 @@
$output .= sprintf("%s%02d:%02d", $direction, $hours, $minutes);
break;
case "o":
+ $output = $this->offset;
+ break;
$offms = $this->tz->getRawOffset($this);
$direction = $offms >= 0 ? "+" : "-";
$offmins = abs($offms) / 1000 / 60;
@@ -513,7 +521,7 @@
} else {
$this->addSeconds(intval(abs($this->tz->getOffset($this)) / 1000));
}
- $this->tz = new Date_TimeZone('UTC');
+ // $this->tz = new Date_TimeZone('UTC');
}
/**
@@ -527,22 +535,25 @@
* @access public
* @param object Date_TimeZone $tz the Date::TimeZone object for the conversion time zone
*/
- function convertTZ($tz)
- {
- // convert to UTC
- if ($this->tz->getOffset($this) > 0) {
- $this->subtractSeconds(intval(abs($this->tz->getOffset($this)) / 1000));
- } else {
- $this->addSeconds(intval(abs($this->tz->getOffset($this)) / 1000));
- }
- // convert UTC to new timezone
- if ($tz->getOffset($this) > 0) {
- $this->addSeconds(intval(abs($tz->getOffset($this)) / 1000));
- } else {
- $this->subtractSeconds(intval(abs($tz->getOffset($this)) / 1000));
- }
- $this->tz = $tz;
- }
+//
+// disabling TZ Features
+//
+// function convertTZ($tz)
+// {
+// // convert to UTC
+// if ($this->tz->getOffset($this) > 0) {
+// $this->subtractSeconds(intval(abs($this->tz->getOffset($this)) / 1000));
+// } else {
+// $this->addSeconds(intval(abs($this->tz->getOffset($this)) / 1000));
+// }
+// // convert UTC to new timezone
+// if ($tz->getOffset($this) > 0) {
+// $this->addSeconds(intval(abs($tz->getOffset($this)) / 1000));
+// } else {
+// $this->subtractSeconds(intval(abs($tz->getOffset($this)) / 1000));
+// }
+// $this->tz = $tz;
+// }
/**
* Converts this date to a new time zone, given a valid time zone ID
@@ -555,15 +566,15 @@
* @access public
* @param string id a time zone id
*/
- function convertTZbyID($id)
- {
- if (Date_TimeZone::isValidID($id)) {
- $tz = new Date_TimeZone($id);
- } else {
- $tz = Date_TimeZone::getDefault();
- }
- $this->convertTZ($tz);
- }
+// function convertTZbyID($id)
+// {
+// if (Date_TimeZone::isValidID($id)) {
+// $tz = new Date_TimeZone($id);
+// } else {
+// $tz = Date_TimeZone::getDefault();
+// }
+// $this->convertTZ($tz);
+// }
function toUTCbyOffset($offset)
{
@@ -588,7 +599,7 @@
$this->addSeconds(intval(abs($offset)));
}
- $this->tz = new Date_TimeZone('UTC');
+ // $this->tz = new Date_TimeZone('UTC');
return true;
}
@@ -733,7 +744,7 @@
*/
function compare($d1, $d2)
{
- $d1->convertTZ(new Date_TimeZone('UTC'));
+ // $d1->convertTZ(new Date_TimeZone('UTC'));
$d2->convertTZ(new Date_TimeZone('UTC'));
$days1 = Date_Calc::dateToDays($d1->day, $d1->month, $d1->year);
$days2 = Date_Calc::dateToDays($d2->day, $d2->month, $d2->year);
More information about the pLog-svn
mailing list