TimeAgo class tests!";
echo "
";
echo "
testing TimeAgo class
";
echo "rule 1 (0 <-> 29 secs # => less than a minute)
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 22:03:29","2010/4/26 22:03:58");
echo "
";
echo "
rule 2 (30 secs <-> 1 min, 29 secs # => 1 minute)
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 22:03:30","2010/4/26 22:04:58");
echo "
";
echo "
rule 3 (1 min, 30 secs <-> 44 mins, 29 secs # => [2..44] minutes)
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 22:03:28","2010/4/26 22:04:58");
echo "
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 22:03:28","2010/4/26 22:15:58");
echo "
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 22:03:28","2010/4/26 22:47:57");
echo "
";
echo "
rule 4 (44 mins, 30 secs <-> 89 mins, 29 secs # => about 1 hour)
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 22:03:28","2010/4/26 22:47:58");
echo "
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 22:03:28","2010/4/26 23:32:57");
echo "
";
echo "
rule 5(89 mins, 29 secs <-> 23 hrs, 59 mins, 29 secs # => about [2..24] hours)
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/4/26 01:30:00");
echo "
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/4/26 13:49:00");
echo "
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/4/26 23:59:29");
echo "
";
echo "
rule 6 (23 hrs, 59 mins, 29 secs <-> 47 hrs, 59 mins, 29 secs # => 1 day)
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/4/26 23:59:30");
echo "
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/4/27 13:10:00");
echo "
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/4/27 23:59:29");
echo "
";
echo "
rule 7 (47 hrs, 59 mins, 30 secs <-> 29 days, 23 hrs, 59 mins, 29 secs # => [2..29] days)
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/4/27 23:59:30");
echo "
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/5/10 00:00:00");
echo "
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/5/25 23:59:29");
echo "
";
echo "
rule 8 (29 days, 23 hrs, 59 mins, 30 secs <-> 59 days, 23 hrs, 59 mins, 29 secs # => about 1 month)
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/5/25 23:59:30");
echo "
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/5/28 10:05:30");
echo "
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/6/24 23:59:29");
echo "
";
echo "
rule 9 (59 days, 23 hrs, 59 mins, 30 secs <-> 1 yr minus 1 sec # => [2..12] months)
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/6/24 23:59:30");
echo "
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2009/10/01 00:00:00","2010/5/28 10:05:30");
echo "
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2009/4/26 00:00:00","2010/4/20 00:00:00");
echo "
";
echo "
rule 10 (1 yr <-> 2 yrs minus 1 secs # => about 1 year)
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2009/4/26 00:00:00","2010/4/26 00:00:00");
echo "
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2009/01/01 00:00:00","2010/5/01 00:00:00");
echo "
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2011/4/26 23:59:59");
echo "
";
echo "
rule 11 (2 yrs <-> max time or date # => over [2..X] years)
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2009/4/26 00:00:00","2011/4/26 00:00:00");
echo "
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2005/4/26 00:00:00","2011/4/26 00:00:00");
echo "
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("1999/4/26 00:00:00","2011/4/26 00:00:00");
echo "
";
echo "";
echo "TimeAgo class tests (dateDifference)
";
echo "";
$timeAgo = new TimeAgo();
echo "
";
print_r($timeAgo->dateDifference("2010/4/01 00:00:00","2010/5/12 03:05:30"));
echo "
";
echo "";
echo "WWDateTime class tests!
";
function test_time($timeAgo, $timeAsItShouldBe) {
echo "";
$datetime = new WWDateTime($timeAgo);
echo $datetime->format(DATE_RFC3339);
echo " = ";
echo $datetime->timeAgoInWords();
echo " === ";
echo $timeAsItShouldBe;
echo "
";
}
test_time("-2 year", "over 2 years");
timeAgoInWords("-2 year");
test_time("-1 year", "about 1 year");
timeAgoInWords("-1 year");
test_time("-1 month", "about 1 month");
timeAgoInWords("-1 month");
test_time("-2 month", "about 2 months");
timeAgoInWords("-2 month");
test_time("-1 day", "1 day");
timeAgoInWords("-1 day");
test_time("-2 day", "2 days");
timeAgoInWords("-2 day");
test_time("-1 hour", "about 1 hour");
timeAgoInWords("-1 hour");
test_time("-2 hour", "about 2 hours");
timeAgoInWords("-2 hour");
test_time("-1 minute", "about 1 minute");
timeAgoInWords("-1 minute");
test_time("-2 minute", "about 2 minutes");
timeAgoInWords("-2 minute");
test_time("-44 minute", "about 44 minutes");
timeAgoInWords("-44 minute");
test_time("-45 minute", "about 1 hour");
timeAgoInWords("-45 minute");
test_time("-1 second", "less than a minute");
timeAgoInWords("-1 second");
test_time("-31 second", "1 minute");
timeAgoInWords("-31 second");
echo "Language testing
";
echo "";
echo "
English
";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2015/5/26 10:00:10","2015/5/26 10:00:20");
echo "
";
echo "
Danish
";
$timeAgo = new TimeAgo(NULL, 'da');
echo $timeAgo->inWords("2015/5/26 10:00:10","2015/5/26 10:00:20");
echo "
";
echo "
";
?>