Skip to content

Commit

Permalink
Added type hints for the public functions
Browse files Browse the repository at this point in the history
  • Loading branch information
regebro committed Oct 9, 2023
1 parent bfb32da commit cbf0496
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions tzlocal/unix.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sys
import warnings
from datetime import timezone
from zoneinfo import ZoneInfo

from tzlocal import utils

Expand Down Expand Up @@ -202,7 +203,7 @@ def _get_localzone(_root="/"):
return tz


def get_localzone_name():
def get_localzone_name() -> str:
"""Get the computers configured local timezone name, if any."""
global _cache_tz_name
if _cache_tz_name is None:
Expand All @@ -211,7 +212,7 @@ def get_localzone_name():
return _cache_tz_name


def get_localzone():
def get_localzone() -> ZoneInfo:
"""Get the computers configured local timezone, if any."""

global _cache_tz
Expand All @@ -221,7 +222,7 @@ def get_localzone():
return _cache_tz


def reload_localzone():
def reload_localzone() -> ZoneInfo:
"""Reload the cached localzone. You need to call this if the timezone has changed."""
global _cache_tz_name
global _cache_tz
Expand Down
7 changes: 4 additions & 3 deletions tzlocal/win32.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
from datetime import datetime
from zoneinfo import ZoneInfo

try:
import _winreg as winreg
Expand Down Expand Up @@ -112,7 +113,7 @@ def _get_localzone_name():
return timezone


def get_localzone_name():
def get_localzone_name() -> str:
"""Get the zoneinfo timezone name that matches the Windows-configured timezone."""
global _cache_tz_name
if _cache_tz_name is None:
Expand All @@ -121,7 +122,7 @@ def get_localzone_name():
return _cache_tz_name


def get_localzone():
def get_localzone() -> ZoneInfo:
"""Returns the zoneinfo-based tzinfo object that matches the Windows-configured timezone."""

global _cache_tz
Expand All @@ -137,7 +138,7 @@ def get_localzone():
return _cache_tz


def reload_localzone():
def reload_localzone() -> ZoneInfo:
"""Reload the cached localzone. You need to call this if the timezone has changed."""
global _cache_tz
global _cache_tz_name
Expand Down

0 comments on commit cbf0496

Please sign in to comment.