Fixed UTC time
This commit is contained in:
@@ -4,7 +4,7 @@ from secrets import token_urlsafe
|
||||
from shutil import move
|
||||
from typing import List, Union
|
||||
from magic import Magic
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from os import makedirs, path, remove, system
|
||||
from classes.models import Photo, SearchResults
|
||||
from modules.exif_reader import extract_location
|
||||
@@ -84,8 +84,8 @@ async def photo_upload(file: UploadFile, album: str, ignore_duplicates: bool = F
|
||||
"hash": file_hash,
|
||||
"filename": filename,
|
||||
"dates": {
|
||||
"uploaded": datetime.utcnow(),
|
||||
"modified": datetime.utcnow()
|
||||
"uploaded": datetime.now(tz=timezone.utc),
|
||||
"modified": datetime.now(tz=timezone.utc)
|
||||
},
|
||||
"location": [
|
||||
coords["lng"],
|
||||
@@ -146,7 +146,7 @@ async def photo_move(id: str, album: str, current_user: User = Security(get_curr
|
||||
else:
|
||||
filename = image["filename"]
|
||||
|
||||
col_photos.find_one_and_update( {"_id": ObjectId(id)}, {"$set": {"album": album, "filename": filename, "dates.modified": datetime.utcnow()}} )
|
||||
col_photos.find_one_and_update( {"_id": ObjectId(id)}, {"$set": {"album": album, "filename": filename, "dates.modified": datetime.now(tz=timezone.utc)}} )
|
||||
|
||||
move(
|
||||
path.join("data", "users", current_user.user, "albums", image["album"], image["filename"]),
|
||||
@@ -170,7 +170,7 @@ async def photo_patch(id: str, caption: str, current_user: User = Security(get_c
|
||||
except InvalidId:
|
||||
return HTTPException(status_code=HTTP_404_NOT_FOUND, detail="Could not find an image with such id.")
|
||||
|
||||
col_photos.find_one_and_update( {"_id": ObjectId(id)}, {"$set": {"caption": caption, "dates.modified": datetime.utcnow()}} )
|
||||
col_photos.find_one_and_update( {"_id": ObjectId(id)}, {"$set": {"caption": caption, "dates.modified": datetime.now(tz=timezone.utc)}} )
|
||||
|
||||
return UJSONResponse(
|
||||
{
|
||||
|
Reference in New Issue
Block a user