From 171c8d889c58aada9081bf94a74d888ec8aacd41 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 19 Feb 2010 12:50:20 -0700 Subject: [PATCH] Store datetimes in db in same format as before --- Changelog.yaml | 65 ++++++++++++++++++++++++++++++++ src/calibre/library/database2.py | 18 +++++++-- src/calibre/library/sqlite.py | 2 +- 3 files changed, 81 insertions(+), 4 deletions(-) diff --git a/Changelog.yaml b/Changelog.yaml index 3b5dcd8d10..a4b7984a40 100644 --- a/Changelog.yaml +++ b/Changelog.yaml @@ -4,6 +4,71 @@ # for important features/bug fixes. # Also, each release can have new and improved recipes. +- version: 0.6.41 + date: 2010-02-19 + + new features: + - title: "Make calibre timezone aware. This required lots of internal changes, so I may have broken something" + type: major + + - title: "Allow editing of metadata in DRMed MOBI files" + type: major + + - title: "ebook-convert: Allow passing URLs as argument to --cover" + tickets: [4909] + + - title: "OS X/linux driver for EB511" + + - title: "ebook-meta: Allow changing of published date" + + - title: "Make replacing of files in ZIP archives faster and (hopefully) more robust" + + - title: "Speed optimization for viewing large EPUB files" + + - title: "Speed up parsing of OPF files" + tickets: [4908] + + bug fixes: + - title: "Fix drag and drop of multiple books to OS X dock icon" + tickets: [4849] + + - title: "MOBI Output: Encode titles as UTF-8 in the PalmDoc header as well as the EXTH header, since there are apparently MOBI readers that use the title from the PalmDoc header in preference to the title from the EXTH header." + + - title: "MOBI Output: Remove soft hyphens as the Kindle doesn't support them." + tickets: [4887] + + - title: "Fix Boox main mem and SD card swapped on windows" + + - title: "Fix sending large ebook fiels to devices" + tickets: [4896] + + - title: "EPUB Output: Strip invalid anchors from NCX TOC as Adobe Digital Editions cries when it sees one" + tickets: [4907] + + - title: "EPUB metadata: Don't set title_sort as a file_as attribute, as the brain-dead OPF spec doesn't allow this" + + - title: "Make publishing the content server via mDNS a little more robust" + + - title: "Content server: Use new exact matching for greater precision when generating OPDS catalogs. Also fix regression that broke rowsing by Tags on Stanza." + + - title: "Proper fix for breakage in LRF viewer caused by API change in QGraphicsItem in Qt 4.6" + + new recipes: + - title: Various Polish news sources + author: Tomaz Dlugosz + + - title: Que Leer, Wired UK + author: Darko Miletic + + - title: Kathermini and Ta Nea + author: Pan + + - title: Winter Olympics + author: Starson17 + + improved recipes: + - Wired Magazine + - version: 0.6.40 date: 2010-02-12 diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 2f3319b2c9..27c009b10a 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -1482,7 +1482,7 @@ class LibraryDatabase2(LibraryDatabase): mi.title, mi.authors = title, ['calibre'] mi.tags = [_('Catalog')] - mi.pubdate = mi.timestamp = nowf() + mi.pubdate = mi.timestamp = utcnow() self.set_metadata(db_id, mi) self.add_format(db_id, format, stream, index_is_id=True) @@ -1511,6 +1511,10 @@ class LibraryDatabase2(LibraryDatabase): self.data.books_added([id], self) self.set_path(id, index_is_id=True) self.conn.commit() + if mi.pubdate is None: + mi.pubdate = utcnow() + if mi.timestamp is None: + mi.timestamp = utcnow() self.set_metadata(id, mi) self.add_format(id, format, stream, index_is_id=True) @@ -1548,6 +1552,10 @@ class LibraryDatabase2(LibraryDatabase): self.data.books_added([id], self) self.set_path(id, True) self.conn.commit() + if mi.timestamp is None: + mi.timestamp = utcnow() + if mi.pubdate is None: + mi.pubdate = utcnow() self.set_metadata(id, mi) if cover is not None: self.set_cover(id, cover) @@ -1583,7 +1591,9 @@ class LibraryDatabase2(LibraryDatabase): self.set_path(id, True) self.conn.commit() if mi.timestamp is None: - mi.timestamp = nowf() + mi.timestamp = utcnow() + if mi.pubdate is None: + mi.pubdate = utcnow() self.set_metadata(id, mi) npath = self.run_import_plugins(path, format) format = os.path.splitext(npath)[-1].lower().replace('.', '').upper() @@ -1616,7 +1626,9 @@ class LibraryDatabase2(LibraryDatabase): self.data.books_added([id], self) self.set_path(id, True) if mi.timestamp is None: - mi.timestamp = nowf() + mi.timestamp = utcnow() + if mi.pubdate is None: + mi.pubdate = utcnow() self.set_metadata(id, mi, ignore_errors=True) for path in formats: ext = os.path.splitext(path)[1][1:].lower() diff --git a/src/calibre/library/sqlite.py b/src/calibre/library/sqlite.py index 498d00005a..39b857952d 100644 --- a/src/calibre/library/sqlite.py +++ b/src/calibre/library/sqlite.py @@ -23,7 +23,7 @@ def convert_timestamp(val): return parse_date(val, as_utc=False) def adapt_datetime(dt): - return isoformat(dt) + return isoformat(dt, sep=' ') sqlite.register_adapter(datetime, adapt_datetime) sqlite.register_converter('timestamp', convert_timestamp)