[pLog-svn] r3509 - in plog/trunk/class: dao data
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Fri Jun 2 04:42:17 GMT 2006
Author: oscar
Date: 2006-06-02 04:42:14 +0000 (Fri, 02 Jun 2006)
New Revision: 3509
Modified:
plog/trunk/class/dao/articles.class.php
plog/trunk/class/data/timestamp.class.php
Log:
Fixed issue http://bugs.lifetype.net/view.php?id=906, where some databases might have timestamps stored as 2006-06-01 14:00:00 (for example) while we were expecting 2006060114000000.
Also, does anybody know why in some databases TIMESTAMP(14) defaults to one format and sometimes to another?
Modified: plog/trunk/class/dao/articles.class.php
===================================================================
--- plog/trunk/class/dao/articles.class.php 2006-06-01 22:47:21 UTC (rev 3508)
+++ plog/trunk/class/dao/articles.class.php 2006-06-02 04:42:14 UTC (rev 3509)
@@ -600,7 +600,7 @@
// check whether we're supposed to show posts that happen in the future or not
$prefix = $this->getPrefix();
- $numPostsPerDayQuery = "SELECT date
+ $numPostsPerDayQuery = "SELECT date
FROM {$prefix}articles
WHERE status = 1
AND blog_id = $blogId";
@@ -623,9 +623,8 @@
$postsPerDay = Array();
while( $row = $result->FetchRow()) {
// we can use this auxiliary function to help us...
- $date = Timestamp::getDateWithOffset( $row['date'], $timeDifference );
-
- $day = substr($date,6,2);
+ $date = Timestamp::getTimestampWithOffset( $row['date'], $timeDifference );
+ $day = $date->getDay();
$postsPerDay[intval($day)] = 1;
}
$result->Close();
Modified: plog/trunk/class/data/timestamp.class.php
===================================================================
--- plog/trunk/class/data/timestamp.class.php 2006-06-01 22:47:21 UTC (rev 3508)
+++ plog/trunk/class/data/timestamp.class.php 2006-06-02 04:42:14 UTC (rev 3509)
@@ -279,6 +279,21 @@
}
/**
+ * Equivalent to Timestamp::getDateWithOffset but instead of returning a date,
+ * it returns a Timestamp object with the given time difference applied to the starting
+ * timestamp
+ *
+ * @param timeStamp
+ * @param timeDiff
+ * @see getDateWithOffset
+ * @return A Timestamp object
+ */
+ function getTimestampWithOffset( $timeStamp, $timeDiff )
+ {
+ return( new Timestamp( Timestamp::getDateWithOffset( $timeStamp, $timeDiff )));
+ }
+
+ /**
* @static
* returns a Timestamp object with the blog time difference already
* applied, if needed
More information about the pLog-svn
mailing list