From b1b47325d7426599dc6f4767f26b1726b8edd81b Mon Sep 17 00:00:00 2001
From: Christian Boos <cboos@neuf.fr>
Date: Fri, 30 Apr 2010 22:55:20 +0200
Subject: [PATCH] #9282: use microsecond timestamps for storing and comparing lastread.

---
 trac/timeline/templates/timeline.html |    9 ++++-----
 trac/timeline/web_ui.py               |    4 ++--
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/trac/timeline/templates/timeline.html b/trac/timeline/templates/timeline.html
index 77556fd..292ae36 100644
--- a/trac/timeline/templates/timeline.html
+++ b/trac/timeline/templates/timeline.html
@@ -32,13 +32,12 @@
        </div>
       </form>
 
-      <py:for each="day, events in groupby(events, key=lambda e: format_date(e.date))">
+      <py:for each="day, events in groupby(events, key=lambda e: format_date(e.date))"
+              py:with="highlight = precision and precisedate and timedelta(0) &lt;= (event.date - precisedate) &lt; precision">
         <h2>${day}: ${day == today and _("Today") or day == yesterday and _("Yesterday") or None}</h2>
-        <dl py:for="unread, events in groupby(events, key=
-                lambda e: lastread and lastread &lt; e.date.isoformat())"
+        <dl py:for="unread, events in groupby(events, key=lambda e: lastread and lastread &lt; e.dateuid)"
             class="${unread and 'unread' or None}">
-          <py:for each="event in events"
-            py:with="highlight = precision and precisedate and timedelta(0) &lt;= (event.date - precisedate) &lt; precision">
+          <py:for each="event in events">
             <dt class="${classes(event.kind, highlight=highlight, unread=unread)}">
               <a href="${event.render('url', context)}" py:choose="">
                 <py:when test="event.author"><i18n:msg params="time, title, author">
diff --git a/trac/timeline/web_ui.py b/trac/timeline/web_ui.py
index a8ce4eb..da559c2 100644
--- a/trac/timeline/web_ui.py
+++ b/trac/timeline/web_ui.py
@@ -89,7 +89,7 @@ class TimelineModule(Component):
 
         format = req.args.get('format')
         maxrows = int(req.args.get('max', 0))
-        lastread = req.session.get('timeline.lastread', '')
+        lastread = int(req.session.get('timeline.lastread', '0'))
 
         # Parse the from date and adjust the timestamp to the last second of
         # the day
@@ -208,7 +208,7 @@ class TimelineModule(Component):
             req.session['timeline.authors'] = authors
             # store lastread
             if events:
-                lastviewed = events[0]['date'].isoformat()
+                lastviewed = to_utimestamp(events[0]['date'])
                 req.session['timeline.lastread'] = max(lastread, lastviewed)
             html_context = Context.from_request(req)
             html_context.set_hints(wiki_flavor='oneliner', 
-- 
1.7.0.4


