diff options
author | Christian Schneider | 2011-11-08 17:33:33 +0000 |
---|---|---|
committer | Christian Schneider | 2011-11-08 17:33:33 +0000 |
commit | 684195f906f6c274ef6e95d46660fe9516311b8f (patch) | |
tree | e3b9769920b07173b49c23d82c7942b5d069fa1d | |
parent | 75dec80e40bdff05d84fe02ebde51eebedbf3989 (diff) | |
download | itools-684195f906f6c274ef6e95d46660fe9516311b8f.tar.gz itools-684195f906f6c274ef6e95d46660fe9516311b8f.tar.bz2 itools-684195f906f6c274ef6e95d46660fe9516311b8f.zip |
Change it::date() to treat float as timestamp, only string with dots like 10.45 are handed to strtotime()
-rw-r--r-- | it.class | 2 | ||||
-rwxr-xr-x | tests/it.t | 10 |
2 files changed, 6 insertions, 6 deletions
@@ -723,7 +723,7 @@ static function date($format = "", $stamp = null) if (!isset($stamp)) $stamp = time(); - else if (!is_int($stamp) && !ctype_digit($stamp) && (!is_float($stamp) || strstr($stamp, '.'))) + else if (is_string($stamp) && !ctype_digit($stamp)) $stamp = strtotime($stamp); list($name, $language) = explode(":", $format); @@ -236,11 +236,11 @@ is(it::date('datetime', time() . ''), it::date('datetime'), 'recognize digit str is(it::date('datetime', '@' . time()), it::date('datetime'), 'recognize strtotime timestamp format'); is(it::date('datetime', 10), it::date('datetime', "10"), 'numeric and string give same result'); is(it::date('datetime', 10.0), it::date('datetime', "10"), '... as long as num is properly truncated'); -is(it::date('datetime', 10.5), it::date('datetime', "10.5"), '... with one digit after point'); -is(it::date('datetime', 10.56), it::date('datetime', "10.56"), '... with two digits after point'); +is(it::date('datetime', 10.5), it::date('datetime', "10"), '... with one digit after point'); +is(it::date('datetime', 10.56), it::date('datetime', "10"), '... with two digits after point'); is(it::date('datetime', 1000000), it::date('datetime', "1000000"), '... large nummer'); -is(it::date('datetime', 1000000.543), it::date('datetime', "1000000.543"), '... large nummer and point'); -is(it::date('time', 10.5), "10:05", 'interpret floating points with strtotime'); -is(it::date('time', 10.05), "10:05", 'interpret floating points with strtotime'); +is(it::date('datetime', 1000000.543), it::date('datetime', "1000000"), '... large nummer and point'); +is(it::date('time', "10.5"), "10:05", 'interpret string with points with strtotime'); +is(it::date('time', "10.05"), "10:05", 'interpret string with points with strtotime'); ?> |