コード例 #1
0
ファイル: UtilTest.php プロジェクト: aiddroid/utilphp
 public function test_human_time_diff()
 {
     $this->assertEquals('1 second ago', util::human_time_diff(time() - 1));
     $this->assertEquals('30 seconds ago', util::human_time_diff(time() - 30));
     $this->assertEquals('1 minute ago', util::human_time_diff(time() - util::SECONDS_IN_A_MINUTE * 1.4));
     $this->assertEquals('5 minutes ago', util::human_time_diff(time() - util::SECONDS_IN_A_MINUTE * 5));
     $this->assertEquals('1 hour ago', util::human_time_diff(time() - util::SECONDS_IN_AN_HOUR));
     $this->assertEquals('2 hours ago', util::human_time_diff(time() - util::SECONDS_IN_AN_HOUR * 2));
     $this->assertEquals('1 day ago', util::human_time_diff(time() - util::SECONDS_IN_AN_HOUR * 24));
     $this->assertEquals('5 days ago', util::human_time_diff(time() - util::SECONDS_IN_AN_HOUR * 24 * 5));
     $this->assertEquals('1 week ago', util::human_time_diff(time() - util::SECONDS_IN_AN_HOUR * 24 * 7));
     $this->assertEquals('2 weeks ago', util::human_time_diff(time() - util::SECONDS_IN_AN_HOUR * 24 * 14));
     $this->assertEquals('1 month ago', util::human_time_diff(time() - util::SECONDS_IN_A_WEEK * 5));
     $this->assertEquals('2 months ago', util::human_time_diff(time() - util::SECONDS_IN_A_WEEK * 10));
     $this->assertEquals('1 year ago', util::human_time_diff(time() - util::SECONDS_IN_A_MONTH * 15));
     $this->assertEquals('2 years ago', util::human_time_diff(time() - util::SECONDS_IN_A_MONTH * 36));
     $this->assertEquals('11 years ago', util::human_time_diff(time() - util::SECONDS_IN_A_MONTH * 140));
     $this->assertEquals('fifteen minutes ago', util::human_time_diff(time() - util::SECONDS_IN_A_MINUTE * 15, '', TRUE));
 }