From 7672a8d80224bd037386fd0d0d4345c977f8e6c7 Mon Sep 17 00:00:00 2001 From: r350178982 <32759763+r350178982@users.noreply.github.com> Date: Thu, 25 Jan 2024 10:25:49 +0800 Subject: [PATCH 1/5] update --- seatable_api/date_utils.py | 7 +++++++ seatable_api/main.py | 7 +++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/seatable_api/date_utils.py b/seatable_api/date_utils.py index a1cdfb9..aced5de 100644 --- a/seatable_api/date_utils.py +++ b/seatable_api/date_utils.py @@ -2,6 +2,7 @@ import calendar from dateutil.relativedelta import relativedelta from dateutil.parser import parse +import pytz DATETIME_FORMAT = { @@ -226,6 +227,12 @@ def between(cls, start, end, include_last=False): class DateUtils(object): + @classmethod + def utcnow(cls): + now = datetime.datetime.now() + isoformat_timestr = now.astimezone(pytz.timezone('UTC')).isoformat() + return isoformat_timestr + def _isoformat(self, d, format_str="%Y-%m-%d"): if not isinstance(d, (datetime.date, datetime.datetime)): raise ValueError('datetime type error') diff --git a/seatable_api/main.py b/seatable_api/main.py index ad15867..3a1adff 100644 --- a/seatable_api/main.py +++ b/seatable_api/main.py @@ -15,6 +15,7 @@ from .socket_io import SocketIO from .query import QuerySet from .utils import convert_db_rows +from .date_utils import dateutils def parse_headers(token): @@ -1005,7 +1006,8 @@ def upload_bytes_file(self, name, content: bytes, relative_path=None, file_type= 'type': file_type, 'size': d.get('size'), 'name': d.get('name'), - 'url': url + 'url': url, + 'upload_time': dateutils.utcnow() } @check_auth @@ -1050,7 +1052,8 @@ def upload_local_file(self, file_path, name=None, relative_path=None, file_type= 'type': file_type, 'size': d.get('size'), 'name': d.get('name'), - 'url': url + 'url': url, + 'upload_time': dateutils.utcnow() } @check_auth From dcae32791f0848f1fed1d491a96c66f112476e60 Mon Sep 17 00:00:00 2001 From: r350178982 <32759763+r350178982@users.noreply.github.com> Date: Thu, 25 Jan 2024 10:31:58 +0800 Subject: [PATCH 2/5] update --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f578135..7199d75 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,6 +20,7 @@ jobs: pip install ply pip install python_dateutil pip install python-socketio + pip install pytz - name: run dateutils test run: | From ad28661ba8d12173f44f44739d9b9f1e77a66533 Mon Sep 17 00:00:00 2001 From: r350178982 <32759763+r350178982@users.noreply.github.com> Date: Thu, 25 Jan 2024 10:44:40 +0800 Subject: [PATCH 3/5] update --- seatable_api/date_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/seatable_api/date_utils.py b/seatable_api/date_utils.py index aced5de..33ee908 100644 --- a/seatable_api/date_utils.py +++ b/seatable_api/date_utils.py @@ -2,7 +2,6 @@ import calendar from dateutil.relativedelta import relativedelta from dateutil.parser import parse -import pytz DATETIME_FORMAT = { @@ -225,12 +224,14 @@ def between(cls, start, end, include_last=False): yield end + class DateUtils(object): @classmethod def utcnow(cls): now = datetime.datetime.now() - isoformat_timestr = now.astimezone(pytz.timezone('UTC')).isoformat() + utc_timezone = datetime.timezone.utc + isoformat_timestr = now.astimezone(utc_timezone).isoformat() return isoformat_timestr def _isoformat(self, d, format_str="%Y-%m-%d"): From 9e2546db7643bbdd04a29280af27f0f179da433a Mon Sep 17 00:00:00 2001 From: r350178982 <32759763+r350178982@users.noreply.github.com> Date: Thu, 25 Jan 2024 10:56:19 +0800 Subject: [PATCH 4/5] Update test.yml --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7199d75..f578135 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,6 @@ jobs: pip install ply pip install python_dateutil pip install python-socketio - pip install pytz - name: run dateutils test run: | From 1e6c7f6af0c3e52352c58e00d4659b592829ef68 Mon Sep 17 00:00:00 2001 From: r350178982 <32759763+r350178982@users.noreply.github.com> Date: Thu, 25 Jan 2024 10:56:57 +0800 Subject: [PATCH 5/5] Update date_utils.py --- seatable_api/date_utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/seatable_api/date_utils.py b/seatable_api/date_utils.py index 33ee908..621c6db 100644 --- a/seatable_api/date_utils.py +++ b/seatable_api/date_utils.py @@ -224,7 +224,6 @@ def between(cls, start, end, include_last=False): yield end - class DateUtils(object): @classmethod