Skip to content

Commit

Permalink
Rough draft of arrow.zone()
Browse files Browse the repository at this point in the history
  • Loading branch information
systemcatch committed Nov 6, 2021
1 parent 56e58ee commit bc3f7b1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion arrow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ._version import __version__
from .api import get, now, utcnow
from .api import get, now, utcnow, zone
from .arrow import Arrow
from .factory import ArrowFactory
from .formatter import (
Expand All @@ -23,6 +23,7 @@
"get",
"now",
"utcnow",
"zone",
"Arrow",
"ArrowFactory",
"FORMAT_ATOM",
Expand Down
8 changes: 7 additions & 1 deletion arrow/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
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 @@ -112,6 +114,10 @@ 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 factory(type: Type[Arrow]) -> ArrowFactory:
"""Returns an :class:`.ArrowFactory` for the specified :class:`Arrow <arrow.arrow.Arrow>`
or derived type.
Expand All @@ -123,4 +129,4 @@ def factory(type: Type[Arrow]) -> ArrowFactory:
return ArrowFactory(type)


__all__ = ["get", "utcnow", "now", "factory"]
__all__ = ["get", "utcnow", "now", "factory", "zone"]
7 changes: 7 additions & 0 deletions arrow/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,10 @@ def now(self, tz: Optional[TZ_EXPR] = None) -> Arrow:
tz = parser.TzinfoParser.parse(tz)

return self.type.now(tz)

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

return zone

0 comments on commit bc3f7b1

Please sign in to comment.