From cf7dd2a6afbc5477dd29352e9a6a6de735540c11 Mon Sep 17 00:00:00 2001
From: Evan Prodromou <evan@status.net>
Date: Thu, 25 Mar 2010 23:56:09 -0400
Subject: [PATCH] better query for notices by date

---
 plugins/Sitemap/SitemapPlugin.php | 17 +++--------------
 plugins/Sitemap/noticesitemap.php |  9 ++++++---
 2 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/plugins/Sitemap/SitemapPlugin.php b/plugins/Sitemap/SitemapPlugin.php
index 8889c89306..bb404cd25e 100644
--- a/plugins/Sitemap/SitemapPlugin.php
+++ b/plugins/Sitemap/SitemapPlugin.php
@@ -50,17 +50,6 @@ class SitemapPlugin extends Plugin
     /**
      * Load related modules when needed
      *
-     * Most non-trivial plugins will require extra modules to do their work. Typically
-     * these include data classes, action classes, widget classes, or external libraries.
-     *
-     * This method receives a class name and loads the PHP file related to that class. By
-     * tradition, action classes typically have files named for the action, all lower-case.
-     * Data classes are in files with the data class name, initial letter capitalized.
-     *
-     * Note that this method will be called for *all* overloaded classes, not just ones
-     * in this plugin! So, make sure to return true by default to let other plugins, and
-     * the core code, get a chance.
-     *
      * @param string $cls Name of the class to be loaded
      *
      * @return boolean hook value; true means continue processing, false means stop.
@@ -99,9 +88,9 @@ class SitemapPlugin extends Plugin
         $m->connect('/sitemaps/notice/:year/:month/:day/:index.xml',
                     array('action' => 'noticesitemap'),
                     array('year' => '[0-9]{4}',
-                          'month' => '[1]?[0-9]',
-                          'day' => '[123]?[0-9]',
-                          'index' => '[0-9]+'));
+                          'month' => '[01][0-9]',
+                          'day' => '[0123][0-9]',
+                          'index' => '[1-9][0-9]*'));
 
         $m->connect('/sitemaps/user/:index.xml',
                     array('action' => 'usersitemap'),
diff --git a/plugins/Sitemap/noticesitemap.php b/plugins/Sitemap/noticesitemap.php
index 7eec886363..0024084863 100644
--- a/plugins/Sitemap/noticesitemap.php
+++ b/plugins/Sitemap/noticesitemap.php
@@ -68,9 +68,12 @@ class NoticesitemapAction extends SitemapAction
 
         $this->notice = new Notice();
 
-        $this->notice->whereAdd("created > '$y-$m-$d 00:00:00'");
-        $this->notice->whereAdd("created <= '$y-$m-$d 11:59:59'");
-        $this->notice->whereAdd('is_local = 1');
+        $dt = sprintf('%04d-%02d-%02d', $y, $m, $d);
+
+        $this->notice->whereAdd("created > '$dt 00:00:00'");
+        $this->notice->whereAdd("created <= '$dt 23:59:59'");
+
+        $this->notice->whereAdd('is_local != 0');
 
         $this->notice->orderBy('id');
         $this->notice->limit($offset, $limit);
-- 
2.39.5