mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-08 06:59:46 +01:00
document EGroupware timestamps and remove own __toString() method to be able to compare objects
This commit is contained in:
parent
362b74e669
commit
7960831180
@ -42,6 +42,13 @@ use DateInterval;
|
|||||||
* The constructor itself throws an \Exception in that case (to be precise it does not handle the one thrown by DateTime constructor).
|
* The constructor itself throws an \Exception in that case (to be precise it does not handle the one thrown by DateTime constructor).
|
||||||
* Static methods server2user, user2server and to return NULL, if given time could not be parsed.
|
* Static methods server2user, user2server and to return NULL, if given time could not be parsed.
|
||||||
*
|
*
|
||||||
|
* Please note: EGroupware historically uses timestamps, which are NOT in UTC!
|
||||||
|
* -----------
|
||||||
|
* So in general the following thre are NOT the same value:
|
||||||
|
* a) (new Api\DateTime($time))->getTimestamp() - regular timestamp in UTC like time()
|
||||||
|
* b) (new Api\DateTime($time))->format('ts') - EGroupware timestamp in user-timezone, UI and BO objects
|
||||||
|
* c) Api\DateTime($time)::user2server('ts') - EGroupware timestamp in server-timezone, SO / integer in database
|
||||||
|
*
|
||||||
* @link http://www.php.net/manual/en/class.datetime.php
|
* @link http://www.php.net/manual/en/class.datetime.php
|
||||||
* @link http://www.php.net/manual/en/class.datetimezone.php
|
* @link http://www.php.net/manual/en/class.datetimezone.php
|
||||||
*/
|
*/
|
||||||
@ -348,7 +355,8 @@ class DateTime extends \DateTime
|
|||||||
case 'ts':
|
case 'ts':
|
||||||
// ToDo: Check if PHP5.3 getTimestamp does the same, or always returns UTC timestamp
|
// ToDo: Check if PHP5.3 getTimestamp does the same, or always returns UTC timestamp
|
||||||
return mktime(parent::format('H'),parent::format('i'),parent::format('s'),parent::format('m'),parent::format('d'),parent::format('Y'));
|
return mktime(parent::format('H'),parent::format('i'),parent::format('s'),parent::format('m'),parent::format('d'),parent::format('Y'));
|
||||||
|
case 'utc': // alias for "U" / timestamp in UTC
|
||||||
|
return $this->getTimestamp();
|
||||||
case 'object':
|
case 'object':
|
||||||
case 'datetime':
|
case 'datetime':
|
||||||
case 'egw_time':
|
case 'egw_time':
|
||||||
@ -382,16 +390,6 @@ class DateTime extends \DateTime
|
|||||||
return parent::format($type);
|
return parent::format($type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Cast object to string
|
|
||||||
*
|
|
||||||
* @return string eg. "Wednesday, 2009-11-11 11:11:11 (Europe/Berlin)"
|
|
||||||
*/
|
|
||||||
public function __toString()
|
|
||||||
{
|
|
||||||
return $this->format('l, '.self::DATABASE).' ('.$this->getTimezone()->getName().')';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a server time into a user time
|
* Convert a server time into a user time
|
||||||
*
|
*
|
||||||
|
@ -122,7 +122,7 @@ class Date extends Transformer
|
|||||||
if($date)
|
if($date)
|
||||||
{
|
{
|
||||||
// postfix date-string with "Z" so javascript doesn't add/subtract anything
|
// postfix date-string with "Z" so javascript doesn't add/subtract anything
|
||||||
$value = $date->format('Y-m-d\TH:i:s\Z');
|
$value = $date->format(Api\DateTime::ET2);
|
||||||
}
|
}
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user