Handle invalid timestamps

* calibre-db.el (calibre-db--parse-timestamp): Return nil instead of
  signalling an error when calling parse-iso8601-time-string with an
  invalid string.

* calibre-core.el (calibre-book--print-info): Check that pubdate is
  non-nil before attempting to format it.

* etc/NEWS: Mention the fixing of this bug.

Some time strings which parse successfully (although potentially to
nonsensical time stamps) on GNU/Linux signal an error on Windows,
making it impossible to open the *Library* buffer if a library
contains a book with such a time string.
This commit is contained in:
Kjartan Oli Agustsson 2023-12-12 10:56:45 +00:00
parent 4422899b7d
commit 9e532313c9
Signed by: kjartanoli
GPG Key ID: D7572FE3605EE6B0
3 changed files with 9 additions and 2 deletions

View File

@ -189,7 +189,9 @@ BOOK is a `calibre-book'."
(series-index (if (calibre-book-series book) (format "%.1f" (calibre-book-series-index book)) ""))
(tags (string-join (calibre-book-tags book) ", "))
(formats (string-join (mapcar (lambda (f) (upcase (symbol-name f))) (calibre-book-formats book)) ", "))
(pubdate (format-time-string calibre-library-time-format (calibre-book-pubdate book))))))
(pubdate (if (calibre-book-pubdate book)
(format-time-string calibre-library-time-format (calibre-book-pubdate book))
"Invalid")))))
calibre-library-columns))))
(defun calibre-book--file (book format)

View File

@ -34,7 +34,7 @@
(defun calibre-db--parse-timestamp (timestamp)
"Return a Lisp timestamp from TIMESTAMP.
TIMESTAMP is a string of the form YYYY-MM-DD HH:MM:SS.xxxxxx+00:00."
(parse-iso8601-time-string (string-replace " " "T" timestamp)))
(ignore-errors (parse-iso8601-time-string (string-replace " " "T" timestamp))))
(defun calibre-db--make-book (entry)
"Create a `calibre-book' from ENTRY.

View File

@ -6,6 +6,11 @@ See the end of the file for license conditions.
This file is about changes in calibre.el, the Emacs client for
Calibre.
* Changes in calibre.el 1.3.4
** Fix a timestamp parsing bug on Windows
Some timestamps signalled errors when parsed on Windows.
* Changes in calibre.el 1.3.3