How to use the hdate.HDate function in hdate

To help you get started, we’ve selected a few hdate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github home-assistant / home-assistant / homeassistant / components / jewish_calendar / sensor.py View on Github external
async def async_update(self):
        """Update the state of the sensor."""
        now = dt_util.now()
        _LOGGER.debug("Now: %s Location: %r", now, self._location)

        today = now.date()
        sunset = dt_util.as_local(
            get_astral_event_date(self.hass, SUN_EVENT_SUNSET, today)
        )

        _LOGGER.debug("Now: %s Sunset: %s", now, sunset)

        date = hdate.HDate(today, diaspora=self._diaspora, hebrew=self._hebrew)

        # The Jewish day starts after darkness (called "tzais") and finishes at
        # sunset ("shkia"). The time in between is a gray area (aka "Bein
        # Hashmashot" - literally: "in between the sun and the moon").

        # For some sensors, it is more interesting to consider the date to be
        # tomorrow based on sunset ("shkia"), for others based on "tzais".
        # Hence the following variables.
        after_tzais_date = after_shkia_date = date
        today_times = self.make_zmanim(today)

        if now > sunset:
            after_shkia_date = date.next_day

        if today_times.havdalah and now > today_times.havdalah:
            after_tzais_date = date.next_day

hdate

Jewish/Hebrew date and Zmanim in native Python 2.7/3.x

GPL-3.0
Latest version published 5 months ago

Package Health Score

68 / 100
Full package analysis