Skip to content

Commit

Permalink
Added the American Samoa calendar (US territory)
Browse files Browse the repository at this point in the history
closes #218
  • Loading branch information
brunobord committed Feb 14, 2019
1 parent 31e64cc commit b5a4ed4
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## master (unreleased)

Nothing here yet.
- Added the American Samoa territory to the USA calendars (#218).

## v4.1.0 (2019-02-07)

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ America
* Mexico
* Panama
* Paraguay
* United States of America (including state holidays)
* United States of America (including State holidays for all the 50 States, and American Samoa)
* Canada (including provincial and territory holidays)

Asia
Expand Down
21 changes: 20 additions & 1 deletion workalendar/tests/test_usa.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
Montana, Nebraska, Nevada, NewHampshire, NewJersey, NewMexico, NewYork,
NorthCarolina, NorthDakota, Ohio, Oklahoma, Oregon, Pennsylvania,
RhodeIsland, SouthCarolina, SouthDakota, Tennessee, TexasBase, Texas,
Utah, Vermont, Virginia, Washington, WestVirginia, Wisconsin, Wyoming
Utah, Vermont, Virginia, Washington, WestVirginia, Wisconsin, Wyoming,
# Not a state, but an American territory
AmericanSamoa,
)


Expand Down Expand Up @@ -1334,3 +1336,20 @@ def test_mlk_label(self):
label,
"Martin Luther King, Jr. / Wyoming Equality Day"
)


class AmericanSamoaTest(UnitedStatesTest):
cal_class = AmericanSamoa

def test_family_day(self):
holidays = self.cal.holidays_set(2019)
self.assertIn(date(2019, 12, 26), holidays) # Family Day

def test_flag_day(self):
holidays = self.cal.holidays_set(2019)
self.assertIn(date(2019, 4, 17), holidays) # Flag Day

def test_family_day_label(self):
holidays = self.cal.holidays(2019)
holidays_dict = dict(holidays)
self.assertEqual(holidays_dict[date(2019, 12, 26)], "Family Day")
4 changes: 4 additions & 0 deletions workalendar/usa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
from .west_virginia import WestVirginia
from .wisconsin import Wisconsin
from .wyoming import Wyoming
# American Territory
from .american_samoa import AmericanSamoa


__all__ = [
Expand Down Expand Up @@ -112,4 +114,6 @@
'WestVirginia',
'Wisconsin',
'Wyoming',
# American territory
'AmericanSamoa',
]
29 changes: 29 additions & 0 deletions workalendar/usa/american_samoa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from datetime import date

from .core import UnitedStates
from ..registry import iso_register


@iso_register('US-AS')
class AmericanSamoa(UnitedStates):
"American Samoa"
include_boxing_day = True
boxing_day_label = "Family Day"

def get_flag_day(self, year):
"""
Flag day is on April 17th
"""
return (
date(year, 4, 17),
"Flag Day"
)

def get_variable_days(self, year):
days = super(AmericanSamoa, self).get_variable_days(year)
days.extend([
self.get_flag_day(year),
])
return days

0 comments on commit b5a4ed4

Please sign in to comment.