Skip to content

ht.datetime.now() raises TypeError if you specify the tz argument #126

Description

@bkeryan

ht.datetime.now() raises TypeError if you specify the tz argument.

Example:

# pip install hightime tzdata

import hightime as ht
from zoneinfo import ZoneInfo

local_time = ht.datetime.now(tz=ZoneInfo("America/Chicago"))
print(local_time)

Output:

Traceback (most recent call last):
  File "C:\Users\bkeryan\AppData\Local\Temp\test2.py", line 6, in <module>
    local_time = ht.datetime.now(tz=ZoneInfo("America/Chicago"))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\bkeryan\AppData\Local\Temp\pbt-venv\Lib\site-packages\hightime\_datetime.py", line 113, in __new__
    return cls._new_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\bkeryan\AppData\Local\Temp\pbt-venv\Lib\site-packages\hightime\_datetime.py", line 97, in _new_impl
    femtosecond = _check_arg("femtosecond", femtosecond)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\bkeryan\AppData\Local\Temp\pbt-venv\Lib\site-packages\hightime\_datetime.py", line 16, in _check_arg
    raise TypeError("an integer is required (got type %s)" % type(value).__name__) from None
TypeError: an integer is required (got type ZoneInfo)

Workaround:

ht.datetime.fromtimestamp(time.time(), tz=ZoneInfo("America/Chicago"))

AB#3826951

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions