comparison extension/modules/feed.js @ 130:7d13369f7d01

use the updated timestamp if available, otherwise the published timestamp, and finally the dc:date, which the feed parser appears to always provide (if necessary, it gives the time downloaded)
author Myk Melez <myk@mozilla.org>
date Sun, 15 Jun 2008 01:05:03 -0700
parents 110b9b8aed1f
children 8f3137f7cc0a
comparison
equal deleted inserted replaced
129:909d00d0d7a7 130:7d13369f7d01
2 2
3 const Cc = Components.classes; 3 const Cc = Components.classes;
4 const Ci = Components.interfaces; 4 const Ci = Components.interfaces;
5 const Cr = Components.results; 5 const Cr = Components.results;
6 const Cu = Components.utils; 6 const Cu = Components.utils;
7
8 Cu.import("resource://gre/modules/ISO8601DateUtils.jsm");
7 9
8 Cu.import("resource://snowl/modules/log4moz.js"); 10 Cu.import("resource://snowl/modules/log4moz.js");
9 Cu.import("resource://snowl/modules/datastore.js"); 11 Cu.import("resource://snowl/modules/datastore.js");
10 Cu.import("resource://snowl/modules/URI.js"); 12 Cu.import("resource://snowl/modules/URI.js");
11 Cu.import("resource://snowl/modules/source.js"); 13 Cu.import("resource://snowl/modules/source.js");
162 } 164 }
163 else if (email) 165 else if (email)
164 author = email; 166 author = email;
165 } 167 }
166 168
167 // Convert the publication date/time string into a JavaScript Date object. 169 // Pick a timestamp, which is one of (by priority, high to low):
168 let timestamp = aEntry.published ? new Date(aEntry.published) : null; 170 // 1. when the entry was last updated;
171 // 2. when the entry was published;
172 // 3. the Dublin Core timestamp associated with the entry;
173 // XXX Should we separately record when we added the entry so that the user
174 // can sort in the "order received" and view "when received" separately from
175 // "when published/updated"?
176 let timestamp = aEntry.updated ? new Date(aEntry.updated) :
177 aEntry.published ? new Date(aEntry.published) :
178 ISO8601DateUtils.parse(aEntry.get("dc:date"));
169 179
170 // FIXME: handle titles that contain markup or are missing. 180 // FIXME: handle titles that contain markup or are missing.
171 let messageID = this.addSimpleMessage(this.id, aExternalID, 181 let messageID = this.addSimpleMessage(this.id, aExternalID,
172 aEntry.title.text, author, 182 aEntry.title.text, author,
173 timestamp, aEntry.link); 183 timestamp, aEntry.link);