]> git.phdru.name Git - bookmarks_db.git/commitdiff
Write netscape-formatted datetime.
authorOleg Broytman <phd@phdru.name>
Mon, 19 Dec 2011 22:40:43 +0000 (22:40 +0000)
committerOleg Broytman <phd@phdru.name>
Mon, 19 Dec 2011 22:40:43 +0000 (22:40 +0000)
git-svn-id: file:///home/phd/archive/SVN/bookmarks_db/trunk@355 fdd5c36f-1aea-0310-aeeb-c58d7e2b6c23

Writers/bkmk_whtml.py

index ad109f82686ac70c16e514212cbc5f278659efa8..1e933faf0904a3a4314e2ce4f836da47ad76f295 100644 (file)
@@ -23,6 +23,11 @@ def dump_comment(comment):
       comment = comment.replace("\n", "<BR>\n")
    return comment
 
+def netscape_date(date):
+   if not date or (BKMK_FORMAT == "MOZILLA"):
+      return date
+   else:
+      return int(date)/(10**6)
 
 ind_s = " "*4
 
@@ -40,8 +45,8 @@ class writer_html(Writer):
       self._folder(f, 0)
 
    def start_folder(self, f, level):
-      self.outfile.write(ind_s*level + '<DT><H3 ADD_DATE="%s"' % f.add_date)
-      if (BKMK_FORMAT == "MOZILLA") and f.last_modified: self.outfile.write(' LAST_MODIFIED="%s"' % f.last_modified)
+      self.outfile.write(ind_s*level + '<DT><H3 ADD_DATE="%s"' % netscape_date(f.add_date))
+      if (BKMK_FORMAT == "MOZILLA") and f.last_modified: self.outfile.write(' LAST_MODIFIED="%s"' % netscape_date(f.last_modified))
       self.outfile.write('>%s</H3>\n' % quote_title(f.name))
       self._folder(f, level)
 
@@ -49,9 +54,9 @@ class writer_html(Writer):
       self.outfile.write(ind_s*level + "</DL><p>\n")
 
    def bookmark(self, b, level):
-      self.outfile.write(ind_s*(level+1) + '<DT><A HREF="%s" ADD_DATE="%s"' % (b.href, b.add_date))
-      if b.last_visit: self.outfile.write(' LAST_VISIT="%s"' % b.last_visit)
-      self.outfile.write(' LAST_MODIFIED="%s"' % b.last_modified)
+      self.outfile.write(ind_s*(level+1) + '<DT><A HREF="%s" ADD_DATE="%s"' % (b.href, netscape_date(b.add_date)))
+      if b.last_visit: self.outfile.write(' LAST_VISIT="%s"' % netscape_date(b.last_visit))
+      self.outfile.write(' LAST_MODIFIED="%s"' % netscape_date(b.last_modified))
       if BKMK_FORMAT == "MOZILLA":
          if b.keyword: self.outfile.write(' SHORTCUTURL="%s"' % b.keyword)
          if b.icon_href: self.outfile.write(' ICON_URI="%s"' % b.icon_href)