mirror of
https://github.com/janeczku/calibre-web
synced 2025-10-24 20:07:41 +00:00
Make datetime utcnow compatible to older python versions
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
from datetime import datetime, UTC
|
||||
from datetime import datetime, timezone
|
||||
import json
|
||||
from shutil import copyfile
|
||||
from uuid import uuid4
|
||||
@@ -200,7 +200,7 @@ def edit_book(book_id):
|
||||
book.pubdate = db.Books.DEFAULT_PUBDATE
|
||||
|
||||
if modify_date:
|
||||
book.last_modified = datetime.now(UTC)
|
||||
book.last_modified = datetime.now(timezone.utc)
|
||||
kobo_sync_status.remove_synced_book(edited_books_id, all=True)
|
||||
calibre_db.set_metadata_dirty(book.id)
|
||||
|
||||
@@ -444,7 +444,7 @@ def edit_list_book(param):
|
||||
mimetype='application/json')
|
||||
else:
|
||||
return _("Parameter not found"), 400
|
||||
book.last_modified = datetime.now(UTC)
|
||||
book.last_modified = datetime.now(timezone.utc)
|
||||
|
||||
calibre_db.session.commit()
|
||||
# revert change for sort if automatic fields link is deactivated
|
||||
@@ -560,7 +560,7 @@ def table_xchange_author_title():
|
||||
# toDo: Handle error
|
||||
edit_error = helper.update_dir_structure(edited_books_id, config.get_book_path(), input_authors[0])
|
||||
if modify_date:
|
||||
book.last_modified = datetime.now(UTC)
|
||||
book.last_modified = datetime.now(timezone.utc)
|
||||
calibre_db.set_metadata_dirty(book.id)
|
||||
try:
|
||||
calibre_db.session.commit()
|
||||
@@ -711,8 +711,8 @@ def create_book_on_upload(modify_date, meta):
|
||||
pubdate = datetime(101, 1, 1)
|
||||
|
||||
# Calibre adds books with utc as timezone
|
||||
db_book = db.Books(title, "", sort_authors, datetime.now(UTC), pubdate,
|
||||
'1', datetime.now(UTC), path, meta.cover, db_author, [], "")
|
||||
db_book = db.Books(title, "", sort_authors, datetime.now(timezone.utc), pubdate,
|
||||
'1', datetime.now(timezone.utc), path, meta.cover, db_author, [], "")
|
||||
|
||||
modify_date |= modify_database_object(input_authors, db_book.authors, db.Authors, calibre_db.session,
|
||||
'author')
|
||||
|
||||
Reference in New Issue
Block a user