How to use the workalendar.core.SUN 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 / europe / netherlands.py View on Github external
def get_king_queen_day(self, year):
        """27 April unless this is a Sunday in which case it is the 26th

        Before 2013 it was called Queensday, falling on
        30 April, unless this is a Sunday in which case it is the 29th.
        """
        if year > 2013:
            king_day = date(year, 4, 27)
            if king_day.weekday() != SUN:
                return (king_day, "King's day")
            return (king_day - timedelta(days=1), "King's day")
        else:
            queen_day = date(year, 4, 30)
            if queen_day.weekday() != SUN:
                return (queen_day, "Queen's day")
            return (queen_day - timedelta(days=1), "Queen's day")
github peopledoc / workalendar / workalendar / europe / lithuania.py View on Github external
def get_fathers_day(self, year):
        return (
            Lithuania.get_nth_weekday_in_month(year, 6, SUN, 1),
            "Father's day"
        )
github peopledoc / workalendar / workalendar / usa / michigan.py View on Github external
def get_fixed_holidays(self, year):
        days = super().get_fixed_holidays(year)

        # New Year's Eve to be added
        new_years_eve = date(year, 12, 31)
        days.append(
            (new_years_eve, "New Years Eve")
        )

        # Christmas Eve & New Year's Eve shift when it falls on SUN
        xmas_eve = date(year, 12, 24)
        if xmas_eve.weekday() == SUN:
            days.append(
                (date(year, 12, 22), "Christmas Eve shift")
            )
            days.append(
                (date(year, 12, 29), "New Years Eve Shift")
            )

        return days
github peopledoc / workalendar / workalendar / asia / hong_kong.py View on Github external
# 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:
            days.append((
                easter_sunday + timedelta(days=2),
                "The day following Easter Monday"
            ))
        return days
github peopledoc / workalendar / workalendar / oceania / australia.py View on Github external
days = super().get_variable_days(year)
        days.extend([
            self.get_may_day(year),
            self.get_picnic_day(year),
        ])
        return days


@iso_register('AU-QLD')
class Queensland(Australia):
    "Queensland"
    include_easter_saturday = True
    include_queens_birthday = True
    include_boxing_day = True

    ANZAC_SHIFT_DAYS = (SUN,)

    def get_labour_day_may(self, year):
        return (
            Queensland.get_nth_weekday_in_month(year, 5, MON),
            "Labour Day"
        )

    def get_variable_days(self, year):
        days = super().get_variable_days(year)
        days.append(self.get_labour_day_may(year))
        return days


@iso_register('AU-SA')
class SouthAustralia(Australia):
    "South Australia"
github peopledoc / workalendar / workalendar / oceania / new_zealand.py View on Github external
"Waitangi Day Shift")
            )

        anzac_day = date(year, 4, 25)
        if anzac_day.weekday() in self.get_weekend_days():
            days.append((
                self.find_following_working_day(anzac_day),
                "ANZAC Day Shift")
            )

        christmas = date(year, 12, 25)
        boxing_day = date(year, 12, 26)
        if christmas.weekday() is SAT:
            shift = self.find_following_working_day(christmas)
            days.append((shift, "Christmas Shift"))
        elif christmas.weekday() is SUN:
            shift = self.find_following_working_day(christmas)
            days.append((shift + timedelta(days=1), "Christmas Shift"))

        if boxing_day.weekday() is SAT:
            shift = self.find_following_working_day(boxing_day)
            days.append((shift, "Boxing Day Shift"))
        elif boxing_day.weekday() is SUN:
            shift = self.find_following_working_day(boxing_day)
            days.append((shift + timedelta(days=1), "Boxing Day Shift"))

        new_year = date(year, 1, 1)
        day_after_new_year = date(year, 1, 2)
        if new_year.weekday() is SAT:
            shift = self.find_following_working_day(new_year)
            days.append((shift, "New Year Shift"))
        elif new_year.weekday() is SUN:
github peopledoc / workalendar / workalendar / usa / core.py View on Github external
def get_inauguration_date(self, year):
        """
        If the year is an Inauguration Year, will return the Inauguration Day
        date.

        If this day falls on SUN, it's replaced by the next MON.
        If the year is not a Inauguration Year, it raises a ValueError.
        """
        if ((year - 1) % 4) != 0:
            raise ValueError(
                "The year {} is not an Inauguration Year".format(year))
        inauguration_day = date(year, 1, 20)
        if inauguration_day.weekday() == SUN:
            inauguration_day = date(year, 1, 21)
        return inauguration_day
github peopledoc / workalendar / workalendar / asia / singapore.py View on Github external
# Christian holiday
    include_good_friday = True

    # Islamic holidays
    include_eid_al_fitr = True
    eid_al_fitr_label = "Hari Raya Puasa"
    include_day_of_sacrifice = True
    day_of_sacrifice_label = "Hari Raya Haji"

    FIXED_HOLIDAYS = ChineseNewYearCalendar.FIXED_HOLIDAYS + (
        (8, 9, "National Day"),
    )

    # Explicitly assign these WE days, Singapore calendar is too much of a mix
    WEEKEND_DAYS = (SAT, SUN)

    # Diwali/Deepavali is sometimes celebrated on a different day to India
    # so this can't be put into a HinduMixin
    DEEPAVALI = {
        2000: date(2000, 10, 26),
        2001: date(2001, 11, 14),
        2002: date(2002, 11, 3),
        2003: date(2003, 10, 23),
        2004: date(2004, 11, 11),
        2005: date(2005, 11, 1),
        2006: date(2006, 10, 21),
        2007: date(2007, 11, 8),
        2008: date(2008, 10, 27),
        2009: date(2009, 10, 17),
        2010: date(2010, 11, 5),
        2011: date(2011, 10, 26),
github peopledoc / workalendar / workalendar / america / mexico.py View on Github external
def get_calendar_holidays(self, year):
        days = super().get_calendar_holidays(year)
        # If any statutory day is on Sunday, the monday is off
        # If it's on a Saturday, the Friday is off
        for day, label in days:
            if day.weekday() == SAT:
                days.append((day - timedelta(days=1), "%s substitute" % label))
            elif day.weekday() == SUN:
                days.append((day + timedelta(days=1), "%s substitute" % label))
        # Extra: if new year's day is a saturday, the friday before is off
        next_new_year = date(year + 1, 1, 1)
        if next_new_year.weekday():
            days.append((date(year, 12, 31), "New Year Day substitute"))
        return days
github peopledoc / workalendar / workalendar / usa / north_carolina.py View on Github external
added.
        """
        xmas = date(year, 12, 25)
        if xmas.weekday() in (TUE, WED, THU):
            # No shift, move along
            return []
        if xmas.weekday() == FRI:
            return [
                (date(year, 12, 28), "Boxing day shift"),
            ]
        elif xmas.weekday() == SAT:
            return [
                (date(year, 12, 23), "Christmas Eve shift"),
                (date(year, 12, 27), "Boxing Day shift"),
            ]
        elif xmas.weekday() == SUN:
            return [
                (date(year, 12, 23), "Christmas Eve shift"),
                (date(year, 12, 27), "Boxing Day shift"),
            ]
        elif xmas.weekday() == MON:
            return [
                (date(year, 12, 27), "Christmas Eve shift"),
            ]