[pLog-svn] r3054 - plog/trunk/class/dao
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Sun Mar 12 19:29:41 GMT 2006
Author: oscar
Date: 2006-03-12 19:29:40 +0000 (Sun, 12 Mar 2006)
New Revision: 3054
Modified:
plog/trunk/class/dao/article.class.php
Log:
solved an issue with posts, they were being updated with the wrong timestamp because the time difference was being always added when calling Articles::getArticle(), and never removed when Articles::updateArticle was being called. This ended up causing an increment ((or decrement) of posts timestamp by 'X' hours where 'X' was the time difference configured for the blog.
I wish I could do away with dynamic time differences altogether.
Modified: plog/trunk/class/dao/article.class.php
===================================================================
--- plog/trunk/class/dao/article.class.php 2006-03-12 17:59:56 UTC (rev 3053)
+++ plog/trunk/class/dao/article.class.php 2006-03-12 19:29:40 UTC (rev 3054)
@@ -104,8 +104,8 @@
$this->_pk = "id";
$this->_fields = Array(
- "date" => "getDate",
- "modification_date" => "getModificationDate",
+ "date" => "getDateWithoutOffset",
+ "modification_date" => "getModificationDateWithoutOffset",
"user_id" => "getUserId",
"blog_id" => "getBlogId",
"status" => "getStatus",
@@ -294,6 +294,24 @@
{
return $this->_date;
}
+
+ /**
+ * Return the date without the time offset applied. This is used so that we don't save
+ * the wrong date to the database when updating this post. For general purpose date queries,
+ * you don't need to use this method, please use getDate.
+ *
+ * @return an SQL timestamp
+ * @see getDate
+ */
+ function getDateWithoutOffset()
+ {
+ // get the offset
+ $offset = $this->getTimeOffset();
+ // and calculate the date without offset
+ include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+ $date = Timestamp::getDateWithOffset( $this->getDate(), -$offset );
+ return( $date );
+ }
/**
* Returns an array of UserComment objects, with all the comments that have been received for
@@ -695,11 +713,34 @@
$this->_modificationTimestamp = new Timestamp( $newDate );
}
+ /**
+ * Returns the date when the post was last modified
+ *
+ * @return an SQL timestamp
+ */
function getModificationDate()
{
return( $this->_modificationDate );
}
+ /**
+ * Return the date without the time offset applied. This is used so that we don't save
+ * the wrong date to the database when updating this post. For general purpose date queries,
+ * you don't need to use this method, please use getDate.
+ *
+ * @return an SQL timestamp
+ * @see getDate
+ */
+ function getModificationDateWithoutOffset()
+ {
+ // get the offset
+ $offset = $this->getTimeOffset();
+ // and calculate the date without offset
+ include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+ $date = Timestamp::getDateWithOffset( $this->getModificationDate(), -$offset );
+ return( $date );
+ }
+
function getModificationTimestamp()
{
return( $this->_modificationTimestamp );
More information about the pLog-svn
mailing list