Actually fix the TSV timezone issue

This commit is contained in:
2023-05-31 23:08:03 -04:00
parent bcf2b9d1ea
commit 0bf4d28482
3 changed files with 25 additions and 5 deletions

View File

@ -1,10 +1,10 @@
import logging
from datetime import timedelta
from datetime import datetime, timedelta, tzinfo
from urllib.parse import unquote
import pytz
from dateutil.parser import ParserError, parse
from django.apps import apps
from django.conf import settings
from django.contrib.auth import get_user_model
from django.db import models
from django.utils import timezone
@ -17,6 +17,12 @@ logger = logging.getLogger(__name__)
User = get_user_model()
def timestamp_user_tz_to_utc(timestamp: int, user_tz: tzinfo) -> datetime:
return user_tz.localize(datetime.utcfromtimestamp(timestamp)).astimezone(
pytz.utc
)
def convert_to_seconds(run_time: str) -> int:
"""Jellyfin sends run time as 00:00:00 string. We want the run time to
actually be in seconds so we'll convert it"