コード例 #1
0
 /**
  * generates an archive link given a date. 
  *
  * @param date A Timestamp object
  * @return A valid archive link
  */
 function getArchiveLink($date)
 {
     $archiveLinkFormat = $this->_config->getValue('archive_link_format');
     $ownerInfo = $this->_blogInfo->getOwnerInfo();
     // this is quite a dirty one but it works...
     $newDate = $date;
     if (strlen($date) == 6) {
         $newDate = $date . "00000000";
     }
     if (strlen($date) == 8) {
         $newDate = $date . "000000";
     }
     $t = new Timestamp($newDate);
     $params = array("{year}" => $t->getYear(), "{month}" => $t->getMonth(), "{blogname}" => $this->_blogInfo->getMangledBlog(), "{blogowner}" => $ownerInfo->getUsername(), "{blogid}" => $this->_blogInfo->getId());
     if (strlen($date) == 6) {
         $params["{day}"] = "";
     } else {
         $day = $t->getDay();
         if ($day < 10) {
             $day = "0" . $day;
         }
         $params["{day}"] = $day;
     }
     $archiveLink = $this->getBaseUrl() . $this->_replaceTags($archiveLinkFormat, $params);
     return $archiveLink;
 }
コード例 #2
0
 function getNumberOfPostsToday()
 {
     $today = new Timestamp();
     $todayTimestamp = $today->getYear() . $today->getMonth() . $today->getDay();
     $query = "SELECT COUNT(*) AS total FROM " . $this->getPrefix() . "articles" . " WHERE date LIKE '{$todayTimestamp}%' AND status = 1";
     return $this->getTotalFromQuery($query);
 }
コード例 #3
0
 public function testNonEpoch()
 {
     $future = '4683-03-04';
     $after = new Timestamp($future);
     $this->assertEquals('04', $after->getDay());
     $this->assertEquals('03', $after->getMonth());
     $this->assertEquals('4683', $after->getYear());
     $past = '1234-04-03';
     $before = new Timestamp($past);
     $this->assertEquals('03', $before->getDay());
     $this->assertEquals('04', $before->getMonth());
     $this->assertEquals('1234', $before->getYear());
     $this->assertFalse($after->equals($before));
     $this->assertEquals($future, $after->toDate());
     $this->assertEquals($past, $before->toDate());
     $time = ' 00:00.00';
     $this->assertEquals($future . $time, $after->toDateTime());
     $this->assertEquals($past . $time, $before->toDateTime());
     $past = '1-04-03';
     $before = new Timestamp($past);
     $this->assertEquals('03', $before->getDay());
     $this->assertEquals('04', $before->getMonth());
     $this->assertEquals(substr(date('Y', time()), 0, 2) . '01', $before->getYear());
     $past = '14-01-02';
     $before = new Timestamp($past);
     $this->assertEquals('02', $before->getDay());
     $this->assertEquals('01', $before->getMonth());
     $this->assertEquals(substr(date('Y', time()), 0, 2) . '14', $before->getYear());
     $past = '113-01-02';
     $before = new Timestamp($past);
     $this->assertEquals('02', $before->getDay());
     $this->assertEquals('01', $before->getMonth());
     $this->assertEquals('0113', $before->getYear());
 }
コード例 #4
0
 public function testNonEpoch()
 {
     $future = '4683-03-04';
     $after = new Timestamp($future);
     $this->assertEquals($after->getDay(), '04');
     $this->assertEquals($after->getMonth(), '03');
     $this->assertEquals($after->getYear(), '4683');
     $past = '1234-04-03';
     $before = new Timestamp($past);
     $this->assertEquals($before->getDay(), '03');
     $this->assertEquals($before->getMonth(), '04');
     $this->assertEquals($before->getYear(), '1234');
     $this->assertFalse($after->equals($before));
     $this->assertEquals($future, $after->toDate());
     $this->assertEquals($past, $before->toDate());
     $time = ' 00:00.00';
     $this->assertEquals($future . $time, $after->toDateTime());
     $this->assertEquals($past . $time, $before->toDateTime());
 }
コード例 #5
0
 /**
  * Checks if there is at least a year and a month in the request
  */
 function checkDateParameter()
 {
     $date = $this->_request->getValue('Date');
     if ($date) {
         $year = substr($date, 0, 4);
         $month = substr($date, 4, 2);
         $day = substr($date, 6, 2);
     } else {
         $t = new Timestamp();
         $year = $t->getYear();
         $month = $t->getMonth();
         $day = $t->getDay();
     }
     $this->_session->setValue('Year', $year);
     $this->_session->setValue('Month', $month);
     $this->_session->setValue('Day', $day);
 }