summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChristian Schneider2023-01-11 14:44:52 +0100
committerChristian Schneider2023-01-11 14:44:52 +0100
commit056614f0f59f5ee5d633b0e4e48fe5edec6dd3cb (patch)
tree1fffcd99a1d9076648e207f919ad55a7ea91d7e0 /test
parent78e3077d55fd6c7322f6c542dda328c0a19b7693 (diff)
downloaditools-056614f0f59f5ee5d633b0e4e48fe5edec6dd3cb.tar.gz
itools-056614f0f59f5ee5d633b0e4e48fe5edec6dd3cb.tar.bz2
itools-056614f0f59f5ee5d633b0e4e48fe5edec6dd3cb.zip
Normalize double sign --/+-/-+/++ calculations in it::date for PHP 8.2 and add tests for it
Diffstat (limited to 'test')
-rwxr-xr-xtest/it.t14
1 files changed, 13 insertions, 1 deletions
diff --git a/test/it.t b/test/it.t
index 41758da..34279ce 100755
--- a/test/it.t
+++ b/test/it.t
@@ -388,7 +388,19 @@ _time("152715", it::date('', '15:27:15'));
_time("yesterday", it::date('', 'yesterday'));
is(it::date('date', '2011-10-25'), '25.10.2011', 'parse date string with strtotime');
-is(it::date('date', '2011-10-25 + 3 days'), '28.10.2011', 'some date arithmetic');
+is(it::date('date', '2011-10-25 + 3 days'), '28.10.2011', 'date arithmetic (add)');
+is(it::date('date', '2011-10-25 - 3 days'), '22.10.2011', 'date arithmetic (subtract)');
+is(it::date('date', '2011-10-25 +-3 days'), '22.10.2011', 'date arithmetic (negative value)');
+is(it::date('date', '2011-10-25 --3 days'), '28.10.2011', 'date arithmetic (double negative)');
+is(it::date('date', '2011-10-25 ++ 3 days'), '28.10.2011', 'date arithmetic (double positive with space)');
+is(it::date('date', '2011-10-25 -+ 3 days'), '22.10.2011', 'date arithmetic (negative positive with space)');
+is(it::date('datetime', '2011-10-25 +12 hours +30 minutes'), '25.10.2011 12:30', 'datetime arithmetic (hours minutes)');
+is(it::date('datetime', '2011-10-25 +24 hours +30 minutes'), '26.10.2011 00:30', 'datetime arithmetic (hours minutes over midnight)');
+is(it::date('datetime', '2011-10-25 8:00 +10 minutes'), '25.10.2011 08:10', 'time arithmetic (add)');
+is(it::date('datetime', '2011-10-25 8:00 -10 minutes'), '25.10.2011 07:50', 'time arithmetic (subtract)');
+is(it::date('datetime', '2011-10-25 8:00 +-10 minutes'), '25.10.2011 07:50', 'time arithmetic (negative value)');
+is(it::date('datetime', '2011-10-25 8:00 --10 minutes'), '25.10.2011 08:10', 'time arithmetic (double negative)');
+is(it::date('datetime', '2011-10-25 --1 month --3 days 8:00 +- 4 hours +-10 minutes'), '28.11.2011 03:50', 'date and time arithmetic (multiple signs)');
is(it::date('datetime', it::time()), it::date('datetime'), 'recognize int as timestamp');
is(it::date('datetime', it::time()*1.0), it::date('datetime'), 'recognize float as timestamp');
is(it::date('datetime', it::time() . ''), it::date('datetime'), 'recognize digit string as timestamp');