changeset 32fd4ee9cfca in modules/attendance:default details: https://hg.tryton.org/modules/attendance?cmd=changeset&node=32fd4ee9cfca description: Replace pytz by trytond timezone tools
issue11756 review421841003 diffstat: attendance.py | 12 ++++-------- setup.py | 1 - 2 files changed, 4 insertions(+), 9 deletions(-) diffs (47 lines): diff -r 2b88317d8850 -r 32fd4ee9cfca attendance.py --- a/attendance.py Mon May 02 16:59:05 2022 +0200 +++ b/attendance.py Sun Oct 09 13:27:55 2022 +0200 @@ -5,11 +5,6 @@ from collections import defaultdict from itertools import chain -try: - import pytz -except ImportError: - pytz = None - from sql import Column, Literal, Null, Window from sql.aggregate import Min, Sum from sql.conditionals import Coalesce @@ -21,6 +16,7 @@ from trytond.model import ModelSQL, ModelView, Workflow, fields from trytond.pool import Pool, PoolMeta from trytond.pyson import Eval +from trytond.tools import timezone as tz from trytond.transaction import Transaction from .exceptions import PeriodClosedError, PeriodTransitionError @@ -80,9 +76,9 @@ if not self.at: return at = self.at - if pytz and self.company and self.company.timezone: - timezone = pytz.timezone(self.company.timezone) - at = pytz.utc.localize(self.at, is_dst=None).astimezone(timezone) + if self.company and self.company.timezone: + timezone = tz.ZoneInfo(self.company.timezone) + at = self.at.replace(tzinfo=tz.UTC) .astimezone(timezone) return at.date() def get_rec_name(self, name): diff -r 2b88317d8850 -r 32fd4ee9cfca setup.py --- a/setup.py Mon May 02 16:59:05 2022 +0200 +++ b/setup.py Sun Oct 09 13:27:55 2022 +0200 @@ -143,7 +143,6 @@ install_requires=requires, extras_require={ 'test': tests_require, - 'timezone': ['pytz'], }, dependency_links=dependency_links, zip_safe=False,