1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-11 16:44:30 +02:00

Use DateTime instead of date()

On 32bits systems, date() is affected bug the 2038 bug
DateTime always uses 64bits representation [Closes #110]

Signed-off-by: Etienne CHAMPETIER <etienne.champetier@fiducial.net>
This commit is contained in:
Etienne CHAMPETIER
2013-10-04 01:19:20 +02:00
committed by David Grudl
parent ddf7b74bf0
commit 7318658017
13 changed files with 51 additions and 50 deletions

View File

@@ -46,7 +46,7 @@ class DibiRow implements ArrayAccess, IteratorAggregate, Countable
if ((int) $time === 0) { // '', NULL, FALSE, '0000-00-00', ...
return NULL;
}
$time = new DibiDateTime(is_numeric($time) ? date('Y-m-d H:i:s', $time) : $time);
$time = new DibiDateTime($time);
}
return $format === NULL ? $time : $time->format($format);
}
@@ -61,9 +61,10 @@ class DibiRow implements ArrayAccess, IteratorAggregate, Countable
{
trigger_error(__METHOD__ . '() is deprecated.', E_USER_WARNING);
$time = $this[$key];
return (int) $time === 0 // '', NULL, FALSE, '0000-00-00', ...
? NULL
: (is_numeric($time) ? (int) $time : strtotime($time));
if ((int) $time !== 0) { // '', NULL, FALSE, '0000-00-00', ...
$time = new DibiDateTime($time);
return $time->getTimestamp();
}
}