diff --git a/Fix-datetime-serialization.patch b/Fix-datetime-serialization.patch new file mode 100644 index 0000000..90c5825 --- /dev/null +++ b/Fix-datetime-serialization.patch @@ -0,0 +1,48 @@ +From dffef385459c3bd49c33fd69b759485016a7f0b2 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Martin=20Vejn=C3=A1r?= +Date: Sat, 27 Oct 2018 21:47:28 +0200 +Subject: [PATCH] Fix datetime serialization + +--- + pytoml/writer.py | 11 ++--------- + 1 file changed, 2 insertions(+), 9 deletions(-) + +diff --git a/pytoml/writer.py b/pytoml/writer.py +index 6eaf5d7..2d8afb5 100644 +--- a/pytoml/writer.py ++++ b/pytoml/writer.py +@@ -48,13 +48,6 @@ def _escape_id(s): + def _format_list(v): + return '[{0}]'.format(', '.join(_format_value(obj) for obj in v)) + +-# Formula from: +-# https://docs.python.org/2/library/datetime.html#datetime.timedelta.total_seconds +-# Once support for py26 is dropped, this can be replaced by td.total_seconds() +-def _total_seconds(td): +- return ((td.microseconds +- + (td.seconds + td.days * 24 * 3600) * 10**6) / 10.0**6) +- + def _format_value(v): + if isinstance(v, bool): + return 'true' if v else 'false' +@@ -69,7 +62,7 @@ def _format_value(v): + return _escape_string(v) + elif isinstance(v, datetime.datetime): + offs = v.utcoffset() +- offs = _total_seconds(offs) // 60 if offs is not None else 0 ++ offs = int(offs.total_seconds()) // 60 if offs is not None else 0 + + if offs == 0: + suffix = 'Z' +@@ -79,7 +72,7 @@ def _format_value(v): + else: + suffix = '-' + offs = -offs +- suffix = '{0}{1:.02}{2:.02}'.format(suffix, offs // 60, offs % 60) ++ suffix = '{0}{1:02}:{2:02}'.format(suffix, offs // 60, offs % 60) + + if v.microsecond: + return v.strftime('%Y-%m-%dT%H:%M:%S.%f') + suffix +-- +2.27.0 + diff --git a/python-pytoml.spec b/python-pytoml.spec index b61fb65..e8a8e47 100644 --- a/python-pytoml.spec +++ b/python-pytoml.spec @@ -2,12 +2,13 @@ Name: python-%{github_name} Version: 0.1.18 -Release: 4 +Release: 5 Summary: Parser for TOML License: MIT URL: https://github.com/avakar/%{github_name} Source0: https://github.com/avakar/%{github_name}/archive/v%{version}/%{github_name}-%{version}.tar.gz Patch0: Add-.vscode-and-.pytest_cache-to-.gitignore.patch +Patch1: Fix-datetime-serialization.patch BuildArch: noarch %global my_description \ @@ -43,6 +44,9 @@ BuildRequires: python3-setuptools %{python3_sitelib}/%{github_name}/ %changelog +* Fri Dec 29 2023 fandehui - 0.1.18-5 +- Fix datetime serialization + * Mon Dec 11 2023 fandehui - 0.1.18-4 - Add .vscode and .pytest_cache to .gitignore