Repository: peopledoc/workalendar
Pull request #254 (2017-11-07 12:30:11)

Add Lithuania's calendar
Added Lithuanian calendar!
References used:
https://en.wikipedia.org/wiki/Public_holidays_in_Lithuania
http://www.officeholidays.com/countries/lithuania/index.php
http://www.officeholidays.com/countries/lithuania/2016.php

<!-- if your contribution is a new calendar -->

- [x] Tests with a significant number of years to be tested for your calendar.
- [x] Docstrings for the Calendar class and specific methods.
- [x] Calendar country / label added to the README.rst file,
- [x] Changelog amended with a mention like: "Added ``<country>`` by ``@pseudo`` (#)"



Patch:
diff --git a/CHANGELOG b/CHANGELOG
index 4caf906..0ceb5f8 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,7 +11,7 @@ master (unreleased)
 - Update ACT holidays( #251)
 - First step iteration on the "global registry" feature. European countries are now part of a registry loaded in the ``workalenda.registry`` module. Please use with care at the moment (#248).
 - Moved from `novafloss` to the `peopledoc` organization, the core People Doc Inc. organization (#255)
-
+- Added Lithuania, by @landler
 
 2.3.1 (2017-07-27)
 ------------------
diff --git a/README.rst b/README.rst
index b231e0b..0fbc4cb 100644
--- a/README.rst
+++ b/README.rst
@@ -93,6 +93,7 @@ Europe
 * Ireland
 * Italy
 * Latvia
+* Lithuania
 * Luxembourg
 * Malta
 * Netherlands
diff --git a/workalendar/europe/__init__.py b/workalendar/europe/__init__.py
index 0eb7fb8..237c79e 100644
--- a/workalendar/europe/__init__.py
+++ b/workalendar/europe/__init__.py
@@ -16,6 +16,7 @@ from .iceland import Iceland
 from .ireland import Ireland
 from .italy import Italy
 from .latvia import Latvia
+from .lithuania import Lithuania
 from .luxembourg import Luxembourg
 from .malta import Malta
 from .netherlands import Netherlands
@@ -59,6 +60,7 @@ __all__ = (
     'Ireland',
     'Italy',
     'Latvia',
+    'Lithuania',
     'Luxembourg',
     'Malta',
     'Netherlands',
diff --git a/workalendar/europe/lithuania.py b/workalendar/europe/lithuania.py
new file mode 100644
index 0000000..dc40200
--- /dev/null
+++ b/workalendar/europe/lithuania.py
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+from workalendar.core import WesternCalendar, ChristianMixin
+from workalendar.registry import iso_register
+from workalendar.core import SUN
+
+
+@iso_register('LT')
+class Lithuania(WesternCalendar, ChristianMixin):
+    name = 'Lithuania'
+
+    FIXED_HOLIDAYS = WesternCalendar.FIXED_HOLIDAYS + (
+        (2, 16, "Restoration of the State Day"),
+        (3, 11, "Restoration of Independence Day"),
+        (5, 1, "Labour Day"),
+        (6, 24, "St. John's Day"),
+        (7, 6, "Anniversary of the Coronation of King Mindaugas"),
+        (8, 15, "Assumption Day"),
+        (11, 1, "All Saints' Day"),
+    )
+
+    include_easter_sunday = True
+    include_easter_monday = True
+    include_christmas_eve = True
+    include_christmas = True
+    include_boxing_day = True
+    boxing_day_label = "Second day of Christmas"
+
+    def get_mothers_day(self, year):
+        return (
+            Lithuania.get_nth_weekday_in_month(year, 5, SUN, 1),
+            "Mother's day"
+        )
+
+    def get_fathers_day(self, year):
+        return (
+            Lithuania.get_nth_weekday_in_month(year, 6, SUN, 1),
+            "Father's day"
+        )
+
+    def get_variable_days(self, year):
+        days = super(Lithuania, self).get_variable_days(year)
+        days.append(self.get_mothers_day(year))
+        days.append(self.get_fathers_day(year))
+        return days


Test patch:
diff --git a/workalendar/tests/test_europe.py b/workalendar/tests/test_europe.py
index 12f69e2..5af46d1 100644
--- a/workalendar/tests/test_europe.py
+++ b/workalendar/tests/test_europe.py
@@ -21,6 +21,7 @@ from workalendar.europe import Iceland
 from workalendar.europe import Ireland
 from workalendar.europe import Italy
 from workalendar.europe import Latvia
+from workalendar.europe import Lithuania
 from workalendar.europe import Luxembourg
 from workalendar.europe import Malta
 from workalendar.europe import Netherlands
@@ -1272,3 +1273,42 @@ class EstoniaTest(GenericCalendarTest):
         self.assertIn(date(2016, 12, 24), holidays)  # XMas eve
         self.assertIn(date(2016, 12, 25), holidays)  # XMas
         self.assertIn(date(2016, 12, 26), holidays)  # Boxing day
+
+
+class LithuaniaTest(GenericCalendarTest):
+    cal_class = Lithuania
+
+    def test_year_2016(self):
+        holidays = self.cal.holidays_set(2016)
+        self.assertIn(date(2016, 1, 1), holidays)  # new year
+        self.assertIn(date(2016, 2, 16), holidays)  # restoration of the state
+        self.assertIn(date(2016, 3, 11), holidays)  # restoration of independ.
+        self.assertIn(date(2016, 3, 27), holidays)  # easter sunday
+        self.assertIn(date(2016, 3, 28), holidays)  # easter monday
+        self.assertIn(date(2016, 5, 1), holidays)  # labour day / mother's day
+        self.assertIn(date(2016, 6, 5), holidays)  # father's day
+        self.assertIn(date(2016, 6, 24), holidays)  # st john's day
+        self.assertIn(date(2016, 7, 6), holidays)  # Anniversary of King Mind.
+        self.assertIn(date(2016, 8, 15), holidays)  # Assumption day
+        self.assertIn(date(2016, 11, 1), holidays)  # All saints day
+        self.assertIn(date(2016, 12, 24), holidays)  # Xmas eve
+        self.assertIn(date(2016, 12, 25), holidays)  # Xmas day
+        self.assertIn(date(2016, 12, 26), holidays)  # 2nd day of xmas
+
+    def test_year_2017(self):
+        holidays = self.cal.holidays_set(2017)
+        self.assertIn(date(2017, 1, 1), holidays)  # new year
+        self.assertIn(date(2017, 2, 16), holidays)  # restoration of the state
+        self.assertIn(date(2017, 3, 11), holidays)  # restoration of independ.
+        self.assertIn(date(2017, 4, 16), holidays)  # easter sunday
+        self.assertIn(date(2017, 4, 17), holidays)  # easter monday
+        self.assertIn(date(2017, 5, 1), holidays)  # labour day
+        self.assertIn(date(2017, 5, 7), holidays)  # mother's day
+        self.assertIn(date(2017, 6, 4), holidays)  # father's day
+        self.assertIn(date(2017, 6, 24), holidays)  # st john's day
+        self.assertIn(date(2017, 7, 6), holidays)  # Anniversary of King Mind.
+        self.assertIn(date(2017, 8, 15), holidays)  # Assumption day
+        self.assertIn(date(2017, 11, 1), holidays)  # All saints day
+        self.assertIn(date(2017, 12, 24), holidays)  # Xmas eve
+        self.assertIn(date(2017, 12, 25), holidays)  # Xmas day
+        self.assertIn(date(2017, 12, 26), holidays)  # 2nd day of xmas