Skip to content

Zmanim vary by time when using a datetime object as input #18

@hudcap

Description

@hudcap

Different times yield different zmanim.
MWE:

import datetime as dt
from zmanim.util.geo_location import GeoLocation
from zmanim.zmanim_calendar import ZmanimCalendar
location = GeoLocation('Lakewood, NJ', 40.0721087, -74.2400243, 'America/New_York', elevation=15)
print(ZmanimCalendar(geo_location=location, date=dt.datetime(2023,8,7)).shkia())
print(ZmanimCalendar(geo_location=location, date=dt.datetime(2023,8,7,1)).shkia())

Even worse, when no date is passed, the default is a datetime object with the current time, so

print(ZmanimCalendar(geo_location=location).shkia())

will yield different, incorrect times throughout the day.

As per @pinnymz, ZmanimCalendar should require a date object.
While a datetime object can be coerced to a date, since the caller may possibly want the next day's zmanim (e.g., if it's after nightfall), we agreed that the input should be restricted to date object, placing the onus on the caller to decide which date.

PR to follow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions