Skip to content

Commit

Permalink
use aliases on reference and target timezones
Browse files Browse the repository at this point in the history
  • Loading branch information
kjmeagher committed Oct 28, 2024
1 parent 0b9c78b commit 6a2960f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
9 changes: 3 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,19 @@ repos:
rev: v4.0.3
hooks:
- id: reuse
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
rev: v0.7.1
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
- repo: https://github.com/pycqa/pylint
rev: v3.3.1
hooks:
- id: pylint
additional_dependencies: [babel, tabulate, tzlocal, xdg-base-dirs, termcolor, pytest]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
rev: v1.13.0
hooks:
- id: mypy
additional_dependencies: [types-tabulate, types-tzlocal, types-termcolor]
Expand Down
5 changes: 3 additions & 2 deletions multizone.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,13 @@ def zone_table(
zones.append((name, time))

if not found_local:
zones.append((str(localzone), localdt))
localname = str(localzone)
zones.append((aliases.get(localname, localname), localdt))

if not found_ref and localoffset != refoffset:
tzname = refdt.tzname()
assert tzname is not None
zones.append((tzname, refdt))
zones.append((aliases.get(tzname, tzname), refdt))

zones.sort(key=time_offset)
return zones
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ include = ["multizone.py"]
max-line-length = "108"

[tool.pylint.message_control]
disable = "R0912"
disable = "R0912,R0914"

[tool.ruff]
fixable = ["D", "I", "COM"]
Expand Down
5 changes: 4 additions & 1 deletion test_mz.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ def test_zone_table() -> None:
tab4 = multizone.zone_table(["ROK", "EST", "UTC"], {"ROK": "Korea", "EST": "Eastern"}, time0, rok)
assert tab4 == [("Korea", time_rok), ("UTC", time0), ("Eastern", time_est)]

tab5 = multizone.zone_table(["EST"], {"ROK": "Korea", "UTC": "London"}, time0, rok)
assert tab5 == [("Korea", time_rok), ("London", time0), ("EST", time_est)]


def test_table_to_string() -> None:
"""Test table_to_string()."""
Expand All @@ -197,4 +200,4 @@ def test_table_to_string() -> None:


if __name__ == "__main__":
pytest.main(["-v", __file__])
sys.exit(pytest.main(["-v", __file__, *sys.argv[1:]]))

0 comments on commit 6a2960f

Please sign in to comment.