Skip to content

Commit

Permalink
Add Angola holidays
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdmgl committed Aug 23, 2018
1 parent 3d154bc commit 1a2daa4
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# CHANGELOG

## master (unreleased)

- Added Angola, by @dvdmgl (#276)
- Portugal - removed carnival from Portuguese holidays, restored missing holidays (#275)
- Added All Souls Day to common (#274)
- Allow the `add_working_days()` function to be provided a datetime, and returning a `date` (#270).
- Added a `keep_datetime` option to keep the original type of the input argument for both ``add_working_days()`` and ``sub_working_days()`` functions (#270).
- Fixed usage examples of ``get_first_weekday_after()`` docstring + in code (calendars and tests) ; do not use magic values, use MON, TUE, etc (#271).
Expand Down
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ Africa
------

* Algeria
* Angola
* Benin
* Ivory Coast
* Madagascar
Expand Down
2 changes: 2 additions & 0 deletions workalendar/africa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .madagascar import Madagascar
from .sao_tome import SaoTomeAndPrincipe
from .south_africa import SouthAfrica
from .angola import Angola


__all__ = (
Expand All @@ -17,4 +18,5 @@
'Madagascar',
'SaoTomeAndPrincipe',
'SouthAfrica',
'Angola',
)
35 changes: 35 additions & 0 deletions workalendar/africa/angola.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from datetime import timedelta
from workalendar.core import WesternCalendar
from workalendar.core import ChristianMixin
from workalendar.registry import iso_register


@iso_register('AO')
class Angola(WesternCalendar, ChristianMixin):
name = 'Angola'

include_good_friday = True
include_easter_sunday = True
include_christmas = True
include_all_souls = True

FIXED_HOLIDAYS = WesternCalendar.FIXED_HOLIDAYS + (
(2, 4, "Dia do Inicio da Luta Armada"),
(3, 8, "Dia Internacional da Mulher"),
(4, 4, "Dia da Paz"),
(5, 1, "Dia Internacional do Trabalhador"),
(9, 17, "Dia do Fundador da Nação e do Herói Nacional"),
(11, 11, "Dia da Independência Nacional"),
)

def get_variable_entrudo(self, year):
easter_sunday = self.get_easter_sunday(year)
return easter_sunday - timedelta(days=47)

def get_variable_days(self, year):
days = super(Angola, self).get_variable_days(year)
days.append((self.get_variable_entrudo(year), "Dia de Carnaval"))
return days
42 changes: 39 additions & 3 deletions workalendar/tests/test_africa.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# -*- coding: utf-8 -*-
from datetime import date
from workalendar.tests import GenericCalendarTest
from workalendar.africa import Benin, Algeria
from workalendar.africa import SouthAfrica, IvoryCoast
from workalendar.africa import SaoTomeAndPrincipe, Madagascar
from workalendar.africa import (
Algeria,
Angola,
Benin,
IvoryCoast,
Madagascar,
SaoTomeAndPrincipe,
SouthAfrica,
)
from workalendar.core import MON


Expand Down Expand Up @@ -207,3 +213,33 @@ def test_year_2013(self):
self.assertIn(date(2013, 11, 1), holidays) # All saints
self.assertIn(date(2013, 12, 21), holidays) # São Tomé Day
self.assertIn(date(2013, 12, 25), holidays) # XMas


class AngolaTest(GenericCalendarTest):
cal_class = Angola

def test_year_2018(self):
holidays = self.cal.holidays_set(2018)
# Dia de Ano Novo – 1 de Janeiro
self.assertIn(date(2018, 1, 1), holidays) # Ano Novo
# Dia do Inicio da Luta Armada – 4 de Fevereiro
self.assertIn(date(2018, 2, 4), holidays)
# Dia do Carnaval – 13 de Fevereiro
self.assertIn(date(2018, 2, 13), holidays) # Entrudo
# Dia Internacional da Mulher – 8 de Março
self.assertIn(date(2018, 3, 8), holidays)
# Dia da Paz – 4 de Abril
self.assertIn(date(2018, 4, 4), holidays) # Dia da Paz
# Sexta Feira Santa – 30 de Março
self.assertIn(date(2018, 3, 30), holidays) # Sexta-Feira Santa
# Páscoa – 01 de Abril
self.assertIn(date(2018, 4, 1), holidays) # Domingo de Páscoa
# Dia Internacional do Trabalhador – 1 de Maio
self.assertIn(date(2018, 5, 1), holidays) # Dia do Trabalhador
# Dia do Fundador da Nação e do Herói Nacional – 17 de Setembro
self.assertIn(date(2018, 9, 17), holidays)
# Dia dos Finados – 2 de Novembro
# Dia da Independência Nacional – 11 de Novembro
self.assertIn(date(2018, 11, 11), holidays)
# Dia do Natal – 25 de Dezembro
self.assertIn(date(2018, 12, 25), holidays) # Natal

0 comments on commit 1a2daa4

Please sign in to comment.