Calculators

Calculators implement specific algorithms for holiday calculations.

Easter Calculator

class workingless.calculators.EasterCalculator(days: int)[source]

Holidays calculations based in easter date. The holiday could be n days +/- from easter date.

Parameters

days (int) – days of difference from easter date

calculate(year: int) → datetime.date[source]

It returns easter date +/- days passed in constructor.

Parameters

year (int) – year for calculate holiday

Returns

holiday date

Return type

datetime.date

Fixed Calculator

class workingless.calculators.FixedCalculator(month: int, day: int)[source]

This is the simpliest implementation. It returns exactly the same date.

Parameters
  • month – month

  • day – day

calculate(year: int) → datetime.date[source]

It returns exactly the same date given.

Parameters

year (int) – year for calculate holiday

Returns

holiday date

Return type

datetime.date

Moving Calculator

class workingless.calculators.MovingCalculator(month, day, next_day=0)[source]

Holidays calculation based in moving date if date isn’t the specific date. For example: base date is january 6, if that date is not monday, holiday will be next monday.

Parameters
  • month (int) – base month

  • day (int) – base day

  • next_day (int) – next day to move holiday

calculate(year)[source]

Calculate holiday from base date

Parameters

year (int) – year for calculate holiday

Returns

holiday date

Return type

datetime.date

Position Day Calculator

class workingless.calculators.PositionDayCalculator(month: int, day: int, position: int, weekday: int = 0)[source]

Holidays calculation when holiday is position day of month.

For example:
  • First monday of february

  • Third monday of march

Parameters
  • month (int) – month

  • day (int) – base day, usually first (1)

  • position (int) – position of the month

  • weekday (int) – day of week

calculate(year: int) → datetime.date[source]

Calculate holiday based in position day of month

Parameters

year (int) – year for calculate holiday

Returns

holiday date

Return type

datetime.date

Every N Years Calculator

class workingless.calculators.EveryNYearsCalculator(month: int, day: int, base_year: int, every: int)[source]

Holidays calculations based in every years from base year

Parameters
  • month (int) – month if every year is satisfied

  • day (int) – day if every year is satisfied

  • base_year (int) – base year for calculation

  • every (int) – how often

calculate(year: int) → Optional[datetime.date][source]

It return base date if the year meets the condition

Parameters

year (int) – year for calculate holiday

Returns

if year meets the condition, None otherwise.

Return type

datetime.date