summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-12-17 12:09:02 -0800
committerBrion Vibber <brion@pobox.com>2010-12-17 12:09:02 -0800
commit7c84c355878353ae0aeefb9f6b3adbc673f758b6 (patch)
treeb8289d73095419b0e470a24be8721aa8a6453afd
parent0e7a283883bc82ca2dfa5426c254caf7d749252c (diff)
Notice::getAsTimestamp() static function to look up the timestamp for a given notice, even if it's been deleted. To be used for converting since_id/max_id processing to use timestamp sorting internally.
-rw-r--r--classes/Notice.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index a067cd374..079f56dcf 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -1978,4 +1978,26 @@ class Notice extends Memcached_DataObject
$d = new DateTime($dateStr, new DateTimeZone('UTC'));
return $d->format(DATE_W3C);
}
+
+ /**
+ * Look up the creation timestamp for a given notice ID, even
+ * if it's been deleted.
+ *
+ * @param int $id
+ * @return mixed string recorded creation timestamp, or false if can't be found
+ */
+ public static function getAsTimestamp($id)
+ {
+ $notice = Notice::staticGet('id', $id);
+ if ($notice) {
+ return $notice->created;
+ } else {
+ $deleted = Deleted_notice::staticGet('id', $id);
+ if ($deleted) {
+ return $deleted->created;
+ } else {
+ return false;
+ }
+ }
+ }
}