Skip to content

Commit

Permalink
Rename to timezone instead of zone
Browse files Browse the repository at this point in the history
  • Loading branch information
systemcatch committed May 2, 2021
1 parent 59b4454 commit 66a1496
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions arrow/__init__.py
@@ -1,5 +1,5 @@
from ._version import __version__
from .api import get, now, utcnow, zone
from .api import get, now, timezone, utcnow
from .arrow import Arrow
from .factory import ArrowFactory
from .formatter import (
Expand All @@ -23,7 +23,7 @@
"get",
"now",
"utcnow",
"zone",
"timezone",
"Arrow",
"ArrowFactory",
"FORMAT_ATOM",
Expand Down
8 changes: 3 additions & 5 deletions arrow/api.py
Expand Up @@ -9,8 +9,6 @@
from time import struct_time
from typing import Any, List, Optional, Tuple, Type, Union, overload

from dateutil import tz as dateutil_tz

from arrow.arrow import TZ_EXPR, Arrow
from arrow.constants import DEFAULT_LOCALE
from arrow.factory import ArrowFactory
Expand Down Expand Up @@ -114,8 +112,8 @@ def now(tz: Optional[TZ_EXPR] = None) -> Arrow:
now.__doc__ = _factory.now.__doc__


def zone(zone_name: str) -> dateutil_tz:
return _factory.zone(zone_name)
def timezone(zone_name: str) -> dt_tzinfo:
return _factory.timezone(zone_name)


def factory(type: Type[Arrow]) -> ArrowFactory:
Expand All @@ -129,4 +127,4 @@ def factory(type: Type[Arrow]) -> ArrowFactory:
return ArrowFactory(type)


__all__ = ["get", "utcnow", "now", "factory", "zone"]
__all__ = ["get", "utcnow", "now", "factory", "timezone"]
2 changes: 1 addition & 1 deletion arrow/factory.py
Expand Up @@ -345,7 +345,7 @@ def now(self, tz: Optional[TZ_EXPR] = None) -> Arrow:
return self.type.now(tz)

@staticmethod
def zone(zone_name: str) -> dateutil_tz:
def timezone(zone_name: str) -> dt_tzinfo:
"""docstring here"""
zone = parser.TzinfoParser.parse(zone_name)

Expand Down
12 changes: 12 additions & 0 deletions tests/test_factory.py
Expand Up @@ -385,3 +385,15 @@ def test_tzinfo(self):
def test_tz_str(self):

assert_datetime_equality(self.factory.now("EST"), datetime.now(tz.gettz("EST")))


@pytest.mark.usefixtures("arrow_factory")
class TestTimezone:
def test_timezone(self):

assert self.factory.timezone("Australia/Darwin") == tz.gettz("Australia/Darwin")

def test_bad_input(self):

with pytest.raises(ParserError):
self.factory.timezone("absolute garbage#!?")

0 comments on commit 66a1496

Please sign in to comment.