How to use the workalendar.core.TUE 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 / usa / indiana.py View on Github external
def get_washington_birthday_december(self, year):
        """
        Washington birthday observance
        Similar to Christmas Eve, but with special rules.
        It's only observed in Georgia.
        """
        warnings.warn(
            "Washington birthday rules for Indiana State are confusing. "
            "Use this calendar with care")
        christmas_day = date(year, 12, 25).weekday()
        if christmas_day == MON:
            day = date(year, 12, 26)  # TUE
        elif christmas_day == TUE:
            day = date(year, 12, 24)  # MON
        elif christmas_day == WED:
            day = date(year, 12, 26)  # TUE
        elif christmas_day == THU:
            day = date(year, 12, 26)  # FRI
        elif christmas_day == FRI:
            day = date(year, 12, 24)  # THU
        elif christmas_day == SAT:
            day = date(year, 12, 23)  # THU
        else:  # christmas_day == SUN:
            day = date(year, 12, 23)  # FRI
        return (day, self.label_washington_birthday_december)
github peopledoc / workalendar / workalendar / usa / core.py View on Github external
def get_washington_birthday_december(self, year):
        """
        Floating observance, to give long weekend at christmas.
        It's only observed in Georgia and Indiana.
        """
        christmas_day = date(year, 12, 25).weekday()
        if christmas_day == MON:
            day = date(year, 12, 26)  # TUE
        elif christmas_day == TUE:
            day = date(year, 12, 24)  # MON
        elif christmas_day == WED:
            day = date(year, 12, 24)  # TUE
        elif christmas_day == THU:
            day = date(year, 12, 26)  # FRI
        elif christmas_day == FRI:
            day = date(year, 12, 24)  # THU
        elif christmas_day == SAT:
            day = date(year, 12, 23)  # THU
        else:  # christmas_day == SUN:
            day = date(year, 12, 23)  # FRI
        return (day, self.label_washington_birthday_december)
github peopledoc / workalendar / workalendar / oceania / australia.py View on Github external
def get_melbourne_cup(self, year):
        return (
            Victoria.get_nth_weekday_in_month(year, 11, TUE),
            "Melbourne Cup"
        )
github peopledoc / workalendar / workalendar / usa / vermont.py View on Github external
def get_variable_days(self, year):
        days = super().get_variable_days(year)
        days.append(
            (self.get_nth_weekday_in_month(year, 3, TUE, 1),
             "Town Meeting Day")
        )
        return days
github peopledoc / workalendar / workalendar / oceania / australia.py View on Github external
# Since this day is picked unsing the school year calendar, there's no
        # mathematical way yet to compute it.

        # This public holiday was declared in 2007. [..]
        # Per Holidays (Reconciliation Day) Amendment Bill 2017, 2017 is the
        # last year that ACT will celebrate family and community day. It is
        # being replaced by Reconciliaton day.
        if year < 2007 or year > 2018:
            # This would be interpreted as "this holiday must not be added"
            return None

        # Family & Community Day was celebrated on the first Tuesday of
        # November in 2007, 2008 and 2009
        if year in (2007, 2008, 2009):
            day = AustralianCapitalTerritory.get_nth_weekday_in_month(
                year, 11, TUE)
        # Family & Community Day was celebrated on the last Monday of
        # November in 2010, 2013, 2014, 2015, 2016, 2017
        elif year in (2010, 2013, 2014, 2015, 2016, 2017):
            day = AustralianCapitalTerritory.get_last_weekday_in_month(
                year, 9, MON)
        # Family & Community Day was celebrated on the second Monday of
        # October in 2011 and 2012
        elif year in (2011, 2012):
            day = AustralianCapitalTerritory.get_nth_weekday_in_month(
                year, 10, MON, 2)
        else:
            # If for some reason the year is not correctly provided
            # (not and int, or whatever)
            return None

        return (day, self._family_community_label)
github peopledoc / workalendar / workalendar / usa.py View on Github external
def get_variable_days(self, year):
        days = super(Vermont, self).get_variable_days(year)
        days = self.float(days)
        days.append(
            (self.get_nth_weekday_in_month(year, 3, TUE, 1),
             "Town Meeting Day")
        )
        return days
github peopledoc / workalendar / workalendar / usa / georgia.py View on Github external
Similar to Christmas Eve, but with special rules.
        It's only observed in Georgia.
        """
        warnings.warn(
            "Washington birthday rules for Georgia State are possibly wrong. "
            "Use this calendar with care")
        christmas_day = date(year, 12, 25).weekday()

        # Special case: 2011 / Source:
        # Christmas day is SUN, but doesn't follow the same rule as year 2016.
        # https://web.archive.org/web/20110927122533/http://www.georgia.gov/00/channel_modifieddate/0,2096,4802_64437763,00.html  # noqa
        if year == 2011:
            day = date(year, 12, 26)
        elif christmas_day == MON:
            day = date(year, 12, 26)  # TUE
        elif christmas_day == TUE:
            day = date(year, 12, 24)  # MON
        elif christmas_day == WED:
            day = date(year, 12, 24)  # TUE
        elif christmas_day == THU:
            day = date(year, 12, 26)  # FRI
        elif christmas_day == FRI:
            day = date(year, 12, 24)  # THU
        elif christmas_day == SAT:
            day = date(year, 12, 23)  # THU
        else:  # christmas_day == SUN:
            day = date(year, 12, 27)  # FRI
        return (day, self.label_washington_birthday_december)
github peopledoc / workalendar / workalendar / usa.py View on Github external
def get_washington_birthday(self, year):
        christmas_day = date(year, 12, 25).weekday()
        if christmas_day == MON:
            day = date(year, 12, 26)  # TUE
        elif christmas_day == TUE:
            day = date(year, 12, 24)  # MON
        elif christmas_day == WED:
            day = date(year, 12, 24)  # TUE
        elif christmas_day == THU:
            day = date(year, 12, 26)  # FRI
        elif christmas_day == FRI:
            day = date(year, 12, 24)  # THU
        elif christmas_day == SAT:
            day = date(year, 12, 23)  # THU
        else:  # christmas_day == SUN:
            day = date(year, 12, 23)  # FRI
        return (day, self.label_washington_bday_observed)
github peopledoc / workalendar / workalendar / america / argentina.py View on Github external
* If it happens on a TUE, it's shifter on the 11th of Oct.
        * If it happens on a WED, THU, FRI or SAT, it's shifted on the first
          MON after this date.
        * Else, it's on the 12th of October.
        """
        diversidad_day = date(year, 10, 12)

        if (diversidad_day.weekday() == WED or
                diversidad_day.weekday() == THU or
                diversidad_day.weekday() == FRI or
                diversidad_day.weekday() == SAT):
            diversidad_day = Argentina.get_first_weekday_after(
                date(year, 10, 12), MON
            )
        elif diversidad_day.weekday() == TUE:
            diversidad_day = diversidad_day - timedelta(days=1)
        else:
            diversidad_day

        return (diversidad_day,
                "Día del Respeto a la Diversidad Cultural")
github peopledoc / workalendar / workalendar / usa / north_carolina.py View on Github external
def get_christmas_shifts(self, year):
        """
        Return Specific Christmas days extra shifts.
        There must be 3 holidays in a row: Christmas Eve, Christmas Day and
        Boxing Day. If one or the other falls on SUN/SAT, extra days must be
        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"),
            ]