From 5441819f33de904aca40b3445b5ead3a64b06187 Mon Sep 17 00:00:00 2001 From: r350178982 <32759763+r350178982@users.noreply.github.com> Date: Tue, 12 Aug 2025 16:07:49 +0800 Subject: [PATCH] update timeutils--> remove pytz --- seahub/settings.py | 1 - seahub/utils/timeutils.py | 10 +--------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/seahub/settings.py b/seahub/settings.py index c613780d02..08c781b021 100644 --- a/seahub/settings.py +++ b/seahub/settings.py @@ -110,7 +110,6 @@ STORAGES = { }, "staticfiles": { "BACKEND": "django.contrib.staticfiles.storage.ManifestStaticFilesStorage", - # "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage", }, } diff --git a/seahub/utils/timeutils.py b/seahub/utils/timeutils.py index d1ad84b282..afcf011226 100644 --- a/seahub/utils/timeutils.py +++ b/seahub/utils/timeutils.py @@ -1,6 +1,5 @@ # Copyright (c) 2012-2016 Seafile Ltd. import logging -import pytz import datetime from django.conf import settings import six @@ -64,7 +63,6 @@ def timestamp_to_isoformat_timestr(timestamp): return '' -# https://pypi.org/project/pytz/ def datetime_to_isoformat_timestr(datetime): if not datetime: @@ -75,15 +73,9 @@ def datetime_to_isoformat_timestr(datetime): datetime = make_naive(datetime) try: - # This library only supports two ways of building a localized time. - # The first is to use the localize() method provided by the pytz library. - # This is used to localize a naive datetime (datetime with no timezone information): - datetime = datetime.replace(microsecond=0) aware_datetime = datetime.replace(tzinfo=current_timezone) - target_timezone = pytz.timezone(str(current_timezone)) - localized_datetime = target_timezone.normalize(aware_datetime.astimezone(pytz.UTC)) - isoformat_timestr = localized_datetime.isoformat() + isoformat_timestr = aware_datetime.isoformat() return isoformat_timestr except Exception as e: logger.error(e)