How to use the workalendar.core.ChineseNewYearCalendar.lunar function in workalendar

To help you get started, we’ve selected a few workalendar 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 peopledoc / workalendar / workalendar / asia / singapore.py View on Github external
def get_variable_days(self, year):
        """
        Singapore variable days
        """
        days = super().get_variable_days(year)

        # Vesak Day
        days.append(
            (ChineseNewYearCalendar.lunar(year, 4, 15), "Vesak Day"),
        )

        # Add in Deepavali (hardcoded dates, so no need to shift)
        deepavali = self.DEEPAVALI.get(year)
        if not deepavali:
            msg = 'Missing date for Singapore Deepavali for year: %s' % year
            raise KeyError(msg)
        days.append((deepavali, 'Deepavali'))
        return days
github peopledoc / workalendar / workalendar / asia / china.py View on Github external
def get_variable_days(self, year):
        days = super().get_variable_days(year)
        # Spring Festival, eve, 1.1, and 1.2 - 1.6 in lunar day
        for i in range(2, 7):
            days.append((ChineseNewYearCalendar.lunar(year, 1, i),
                         "Spring Festival"))
        # other holidays
        for holiday_name, day_list in holidays[year].items():
            for v in day_list:
                days.append((date(year, v[0], v[1]), holiday_name))
        return days
github peopledoc / workalendar / workalendar / asia / hong_kong.py View on Github external
# rolls to the following Wed
        if year < 2011:
            self.shift_start_cny_sunday = True

        days = super().get_variable_days(year)
        chingming = solar_term(year, 15, 'Asia/Hong_Kong')
        solar_term_chingming = chingming
        dupe_holiday = [chingming for day in days if chingming == day[0]]
        if dupe_holiday:
            # Roll Chingming forward a day as it clashes with another holiday
            chingming = chingming + timedelta(days=1)
        mid_autumn_label = "Day After Mid-Autumn Festival"
        days.extend([
            (ChineseNewYearCalendar.lunar(year, 4, 8), "Buddha's Birthday"),
            (chingming, "Ching Ming Festival"),
            (ChineseNewYearCalendar.lunar(year, 5, 5), "Tuen Ng Festival"),
            (ChineseNewYearCalendar.lunar(year, 8, 16), mid_autumn_label),
            (ChineseNewYearCalendar.lunar(year, 9, 9), "Chung Yeung Festival"),
        ])

        # All holidays that fall on SUN are shifted in
        # ``ChineseNewYearCalendar.get_calendar_holidays()``
        # Special case for Boxing Day.
        # If Christmas day is on SUN, the December 27th is also a holiday
        if date(year, 12, 25).weekday() == SUN:
            days.append(
                (date(year, 12, 27), "The second weekday after Christmas")
            )

        # Special case when Ching Ming and Easter overlap
        # Ching Ming is shifted to easter monday (but it's handled elsewhere)
        # Easter Monday is also shifted
github peopledoc / workalendar / workalendar / asia / taiwan.py View on Github external
def get_variable_days(self, year):
        days = super().get_variable_days(year)
        # Qingming begins when the sun reaches the celestial
        # longitude of 15° (usually around April 4th or 5th)
        qingming = solar_term(year, 15, 'Asia/Taipei')

        days.extend([
            (
                ChineseNewYearCalendar.lunar(year, 1, 3),
                "Chinese New Year (3rd day)"
            ),
            (qingming, "Qingming Festival"),
            (ChineseNewYearCalendar.lunar(year, 5, 5), "Dragon Boat Festival"),
            (ChineseNewYearCalendar.lunar(year, 8, 15), "Mid-Autumn Festival"),
        ])
        return days
github peopledoc / workalendar / workalendar / asia / hong_kong.py View on Github external
if year < 2011:
            self.shift_start_cny_sunday = True

        days = super().get_variable_days(year)
        chingming = solar_term(year, 15, 'Asia/Hong_Kong')
        solar_term_chingming = chingming
        dupe_holiday = [chingming for day in days if chingming == day[0]]
        if dupe_holiday:
            # Roll Chingming forward a day as it clashes with another holiday
            chingming = chingming + timedelta(days=1)
        mid_autumn_label = "Day After Mid-Autumn Festival"
        days.extend([
            (ChineseNewYearCalendar.lunar(year, 4, 8), "Buddha's Birthday"),
            (chingming, "Ching Ming Festival"),
            (ChineseNewYearCalendar.lunar(year, 5, 5), "Tuen Ng Festival"),
            (ChineseNewYearCalendar.lunar(year, 8, 16), mid_autumn_label),
            (ChineseNewYearCalendar.lunar(year, 9, 9), "Chung Yeung Festival"),
        ])

        # All holidays that fall on SUN are shifted in
        # ``ChineseNewYearCalendar.get_calendar_holidays()``
        # Special case for Boxing Day.
        # If Christmas day is on SUN, the December 27th is also a holiday
        if date(year, 12, 25).weekday() == SUN:
            days.append(
                (date(year, 12, 27), "The second weekday after Christmas")
            )

        # Special case when Ching Ming and Easter overlap
        # Ching Ming is shifted to easter monday (but it's handled elsewhere)
        # Easter Monday is also shifted
        easter_sunday = self.get_easter_sunday(year)
github peopledoc / workalendar / workalendar / asia / taiwan.py View on Github external
def get_variable_days(self, year):
        days = super().get_variable_days(year)
        # Qingming begins when the sun reaches the celestial
        # longitude of 15° (usually around April 4th or 5th)
        qingming = solar_term(year, 15, 'Asia/Taipei')

        days.extend([
            (
                ChineseNewYearCalendar.lunar(year, 1, 3),
                "Chinese New Year (3rd day)"
            ),
            (qingming, "Qingming Festival"),
            (ChineseNewYearCalendar.lunar(year, 5, 5), "Dragon Boat Festival"),
            (ChineseNewYearCalendar.lunar(year, 8, 15), "Mid-Autumn Festival"),
        ])
        return days
github peopledoc / workalendar / workalendar / asia / south_korea.py View on Github external
def get_variable_days(self, year):
        days = super().get_variable_days(year)
        days.extend([
            (ChineseNewYearCalendar.lunar(year, 4, 8), "Buddha's Birthday"),
            # Midautumn Festival (3 days)
            (ChineseNewYearCalendar.lunar(year, 8, 14), "Midautumn Festival"),
            (ChineseNewYearCalendar.lunar(year, 8, 15), "Midautumn Festival"),
            (ChineseNewYearCalendar.lunar(year, 8, 16), "Midautumn Festival"),
        ])
        return days
github peopledoc / workalendar / workalendar / asia / hong_kong.py View on Github external
self.shift_start_cny_sunday = True

        days = super().get_variable_days(year)
        chingming = solar_term(year, 15, 'Asia/Hong_Kong')
        solar_term_chingming = chingming
        dupe_holiday = [chingming for day in days if chingming == day[0]]
        if dupe_holiday:
            # Roll Chingming forward a day as it clashes with another holiday
            chingming = chingming + timedelta(days=1)
        mid_autumn_label = "Day After Mid-Autumn Festival"
        days.extend([
            (ChineseNewYearCalendar.lunar(year, 4, 8), "Buddha's Birthday"),
            (chingming, "Ching Ming Festival"),
            (ChineseNewYearCalendar.lunar(year, 5, 5), "Tuen Ng Festival"),
            (ChineseNewYearCalendar.lunar(year, 8, 16), mid_autumn_label),
            (ChineseNewYearCalendar.lunar(year, 9, 9), "Chung Yeung Festival"),
        ])

        # All holidays that fall on SUN are shifted in
        # ``ChineseNewYearCalendar.get_calendar_holidays()``
        # Special case for Boxing Day.
        # If Christmas day is on SUN, the December 27th is also a holiday
        if date(year, 12, 25).weekday() == SUN:
            days.append(
                (date(year, 12, 27), "The second weekday after Christmas")
            )

        # Special case when Ching Ming and Easter overlap
        # Ching Ming is shifted to easter monday (but it's handled elsewhere)
        # Easter Monday is also shifted
        easter_sunday = self.get_easter_sunday(year)
        if easter_sunday == solar_term_chingming:
github peopledoc / workalendar / workalendar / asia / south_korea.py View on Github external
def get_variable_days(self, year):
        days = super().get_variable_days(year)
        days.extend([
            (ChineseNewYearCalendar.lunar(year, 4, 8), "Buddha's Birthday"),
            # Midautumn Festival (3 days)
            (ChineseNewYearCalendar.lunar(year, 8, 14), "Midautumn Festival"),
            (ChineseNewYearCalendar.lunar(year, 8, 15), "Midautumn Festival"),
            (ChineseNewYearCalendar.lunar(year, 8, 16), "Midautumn Festival"),
        ])
        return days