Skip to content

Commit

Permalink
Make it work for any country
Browse files Browse the repository at this point in the history
  • Loading branch information
Éric Lemoine committed Apr 12, 2017
1 parent 41bf983 commit c8a622f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ Activate virtual env if `workalendar` was installed in a virtual env:
SELECT workalendar.workon('/patch/to/virtual/env');
```

Get the french holidays for a given year:
Get the french holidays for 2017:

```sql
SELECT * from workalendar.holidays(2017);
SELECT * from workalendar.holidays(2017, 'europe', 'France');
date | name
------------+------------------------------
2017-01-01 | New year
Expand Down
7 changes: 4 additions & 3 deletions workalendar--1.0.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ CREATE TYPE holiday AS (
name text
);

CREATE OR REPLACE FUNCTION holidays(year int)
CREATE OR REPLACE FUNCTION holidays(year int, continent text, country text)
RETURNS SETOF holiday AS
$BODY$
from datetime import date
from workalendar.europe import France
cal = France()
from importlib import import_module
imp = import_module('workalendar.' + continent)
cal = getattr(imp, country)()
for holiday in cal.holidays(year):
yield holiday
$BODY$
Expand Down

0 comments on commit c8a622f

Please sign in to comment.