Skip to content

Commit

Permalink
Merge pull request #93 from octoenergy/parse-dt-tz-override
Browse files Browse the repository at this point in the history
Allow timezone override in localtime.parse_dt
  • Loading branch information
benthorner committed Sep 19, 2023
2 parents b311703 + d1a561d commit e2d4948
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog

## v4.2.1 - 2023-09-18

- Allow timzone override in `localtime.parse_dt` [#93](https://github.com/octoenergy/xocto/pull/93)

## v4.2.0 - 2023-09-06

- Add `localtime.parse_date` and `localtime.parse_dt` [#91](https://github.com/octoenergy/xocto/pull/91)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -5,7 +5,7 @@

REPO_ROOT = path.abspath(path.dirname(__file__))

VERSION = "4.2.0"
VERSION = "4.2.1"

with open(path.join(REPO_ROOT, "README.md"), encoding="utf-8") as f:
long_description = f.read()
Expand Down
2 changes: 1 addition & 1 deletion xocto/__init__.py
@@ -1 +1 @@
__version__ = "4.2.0"
__version__ = "4.2.1"
4 changes: 2 additions & 2 deletions xocto/localtime.py
Expand Up @@ -738,11 +738,11 @@ def parse_date(value: str) -> datetime_.date:
return datetime_.date.fromisoformat(value)


def parse_dt(value: str) -> datetime_.datetime:
def parse_dt(value: str, tz: timezone.zoneinfo.ZoneInfo | None = None) -> datetime_.datetime:
"""
Returns a datetime.datetime for a given ISO format date/time string.
The date/time must be naive - not include timezone information.
"""
_datetime = datetime_.datetime.fromisoformat(value)
return timezone.make_aware(_datetime)
return timezone.make_aware(_datetime, timezone=tz)

0 comments on commit e2d4948

Please sign in to comment.