Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STALE-BRANCH-BACKUP - remove unused import #3

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2c9928f
Refactor NetherlandsWithSchoolHolidays.get_christmas_holidays. The lo…
jaraco Sep 3, 2022
6d5906a
Add changelog entry.
jaraco Oct 25, 2022
b7c03ea
Remove parameters, no longer needed or used.
jaraco Oct 25, 2022
b6a689a
Removed compatibility with Python 3.6
brunobord Dec 30, 2022
f95ffcd
Merge pull request #731 from workalendar/remove-python36
brunobord Dec 30, 2022
3d7a07f
Upgraded `tox` usage, now compatble with tox 4+
brunobord Dec 30, 2022
2e76756
Confirm support of Python 3.10
brunobord Dec 30, 2022
38b8b6e
Confirm support of Python 3.11
brunobord Dec 30, 2022
cd6194e
Merge pull request #733 from workalendar/upgrade-python-and-tox
brunobord Dec 30, 2022
fa0c3d8
Add Tunisia
macharmi Jan 29, 2022
947d683
update changelog
macharmi Jan 29, 2022
a65bc91
Add 2022 tests
macharmi Mar 1, 2022
ce4cd95
Merge pull request #734 from workalendar/macharmi-add-tunisia
brunobord Dec 30, 2022
f852f73
Adding holidays for El Salvador.
hersoncruz Mar 31, 2022
0267afd
Revert "Adding holidays for El Salvador."
hersoncruz Mar 31, 2022
876f1e9
Adding new calendar for El Salvador.
hersoncruz Mar 31, 2022
b6f4494
Merge pull request #735 from workalendar/hersoncruz-el_salvador
brunobord Dec 30, 2022
2b419d1
Merge branch 'master' into refactor/netherlands-christmas
brunobord Dec 30, 2022
1812e21
Merge pull request #717 from jaraco/refactor/netherlands-christmas
brunobord Dec 30, 2022
9ca9bed
feat: China's public holidays for 2023
Dec 31, 2022
8473c32
Merge pull request #728 from RyoLee/master
brunobord Jan 1, 2023
124e4ef
v17.0.0
brunobord Jan 1, 2023
2744b5a
Back to dev => 17.1.0.dev0
brunobord Jan 1, 2023
91723a9
Coronation of His Majesty King Charles III Bank holiday in 2023 to th…
mountinash789 Nov 7, 2022
8dd3a23
add to changelog
mountinash789 Jan 2, 2023
d662a11
Coronation of His Majesty King Charles III Bank holiday in 2023 to th…
mountinash789 Nov 7, 2022
038ba51
Merge pull request #4 from oraclefinance/feature/king-charles-coronation
mountinash789 Jan 2, 2023
b131f2b
Merge pull request #727 from oraclefinance/master
brunobord Jan 3, 2023
795a5eb
Replace lunardate with lunarcalendar
derlikh-smart May 10, 2022
de411cc
update Changelog.md
derlikh-smart May 10, 2022
ba43a85
remove unused import
derlikh-smart Jun 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,18 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9, '3.10', 3.11]
include:
- python-version: 3.6
tox-env: py36
- python-version: 3.7
tox-env: py37
- python-version: 3.8
tox-env: py38
- python-version: 3.9
tox-env: py39
- python-version: '3.10'
tox-env: py310
- python-version: 3.11
tox-env: py311

name: Test (python ${{ matrix.python-version }}/${{ matrix.os }})
runs-on: ${{ matrix.os }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.pyc
*.egg-info
.eggs/
dist/
build/
.coverage
Expand Down
19 changes: 18 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,24 @@

## master (unreleased)

Nothing here yet.
- Coronation of His Majesty King Charles III Bank holiday in 2023 to the UK calendar.
- Replace `lunardate` GPL-3 dependency with `lunarcalendar` which is MIT licensed (#709)

## v17.0.0 (2023-01-01)

### New calendars

- New calendar: Added Tunisia calendar by @macharmi (#702)
- New calendar: Added El Salvador calendar by @hersoncruz (#708).

### Other changes

- Update China's public holidays for 2023 (#728).
- Removed compatibility with Python 3.6, also, removed tests & amended documentation (#705).
- Upgraded `tox` usage, now compatble with tox 4+ (added `allowlist_externals`).
- Added support for Python 3.10 (#706).
- Added support for Python 3.11 (#732).
- Refactor ``NetherlandsWithSchoolHolidays.get_christmas_holidays`` for simplicity and readability.

## v16.4.0 (2022-09-16)

Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ For a more complete documentation and advanced usage, go to [the official workal

## External dependencies

**Workalendar will require you to use Python 3.6+.**
**Workalendar will require you to use Python 3.7+.**

Workalendar is tested on Python 3.6, 3.7, 3.8, 3.9, and on Linux (Ubuntu), Mac OS and Windows using Github actions.
Workalendar is tested on Python 3.7, 3.8, 3.9, 3.10, 3.11, and on Linux (Ubuntu), Mac OS and Windows using Github actions.

### Conditional dependencies

As of v15.0.0:

* If you're using \*Nix and Python 3.6, 3.7, 3.8, the package `backports.zoneinfo` is required
* If you're using Windows and Python 3.6, 3.7, 3.8, the package `tzdata` is *also* a requirement (with the `backports.zoneinfo`).
* If you're using \*Nix and Python 3.7, 3.8, the package `backports.zoneinfo` is required
* If you're using Windows and Python 3.7, 3.8, the package `tzdata` is *also* a requirement (with the `backports.zoneinfo`).
* If you're using Python 3.9+, the stdlib `zoneinfo` package will be used.

## Tests
Expand Down Expand Up @@ -155,6 +155,7 @@ from the command line.
- Canada (including provincial and territory holidays)
- Chile
- Colombia
- El Salvador
- Mexico
- Panama
- Paraguay
Expand Down Expand Up @@ -201,6 +202,7 @@ from the command line.
- Nigeria
- São Tomé
- South Africa
- Tunisia

And more to come (I hope!)

Expand Down
2 changes: 1 addition & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pip install -e ./
When you provide a patch for workalendar, whether it would be a new calendar or a fix to an existing one, or else, you will have to make sure that your contribution follows these basic requirements:

* Your code should pass the `flake8` test ; that is to say that it follows the [PEP8](https://www.python.org/dev/peps/pep-0008/) guidelines. You can check using the `tox -e flake8` command. If you can't, our CI jobs will do it, and you'll be able to know where are your mistakes, if any.
* Your code should be compatible with our supported Python version. Currently: Python 3.6, 3.7, 3.8 and 3.9. Again, the CI (powered by Github Actions) will check your code against all those versions so you won't have to.
* Your code should be compatible with our supported Python version. Currently: Python 3.7, 3.8, 3.9, 3.10 and 3.11. Again, the CI (powered by Github Actions) will check your code against all those versions so you won't have to.
* If you encounter a failure in the `pyupgrade` tox job, you can fix it by running the followinf command: `tox -r pyupgrade`. It'll modify your code so it will pass this test. **Warning:** sometimes, this change can break the `flake8` standards, so you'll have to make sure that both linters will pass.

#### Test-driven start
Expand Down
9 changes: 5 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = workalendar
version = 16.5.0.dev0
version = 17.1.0.dev0
description = Worldwide holidays and working days helper and toolkit.
author = Bruno Bord
author_email = [email protected]
Expand All @@ -14,20 +14,21 @@ classifiers =
License :: OSI Approved :: MIT License
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11


[options]
python_requires = >=3.6
python_requires = >=3.7
zip_safe = False
include_package_data = True
packages = find:
install_requires =
python-dateutil
lunardate
LunarCalendar
backports.zoneinfo;python_version<"3.9"
tzdata;platform_system=="Windows"
convertdate
Expand Down
8 changes: 6 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
[tox]
envlist = pyupgrade,flake8,py36,py37,py38,py39
envlist = pyupgrade,flake8,py37,py38,py39,py310,py311

[testenv]
allowlist_externals =
flake8
py.test
pyup_dirs
deps =
pytest
pandas
Expand All @@ -28,4 +32,4 @@ deps =
pyupgrade-directories
commands_pre =
skip_install = true
commands = pyup_dirs --py36-plus --recursive .
commands = pyup_dirs --py37-plus --recursive .
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 .angola import Angola
from .mozambique import Mozambique
from .nigeria import Nigeria
from .tunisia import Tunisia

__all__ = (
'Algeria',
Expand All @@ -20,4 +21,5 @@
'Angola',
'Mozambique',
'Nigeria',
'Tunisia',
)
50 changes: 50 additions & 0 deletions workalendar/africa/tunisia.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from datetime import date

from ..core import IslamicCalendar, SAT, SUN
from ..registry_tools import iso_register


@iso_register('TN')
class Tunisia(IslamicCalendar):
"Tunisia"
# Civil holidays
include_labour_day = True
# Islamic holidays
include_prophet_birthday = True
include_eid_al_fitr = True
length_eid_al_fitr = 2
include_day_of_sacrifice = True
length_eid_al_adha = 4
include_islamic_new_year = True

FIXED_HOLIDAYS = IslamicCalendar.FIXED_HOLIDAYS + (
(3, 20, "Independence Day"),
(7, 25, "Republic Day"),
(4, 9, "Martyrs' Day"),
(8, 13, "Women's Day"),
(10, 15, "Evacuation Day")
)

# Tunisia has adopted the "western" workweek.
WEEKEND_DAYS = (SAT, SUN)

def get_fixed_holidays(self, year):
"""Get fixed holidays.

Args:
year (int): Year

Returns:
tuple: Tuple of date and label
"""
days = super().get_fixed_holidays(year)

revolution_day_label = "Revolution Day"

if 2011 < year <= 2020:
days.append((date(year, 1, 14), revolution_day_label))

if year >= 2021:
days.append((date(year, 12, 17), revolution_day_label))

return days
2 changes: 2 additions & 0 deletions workalendar/america/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from .panama import Panama
from .paraguay import Paraguay
from .argentina import Argentina
from .el_salvador import ElSalvador


__all__ = (
Expand Down Expand Up @@ -116,4 +117,5 @@
'Panama',
'Paraguay',
'Argentina',
'ElSalvador',
)
21 changes: 21 additions & 0 deletions workalendar/america/el_salvador.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from ..core import WesternCalendar
from ..registry_tools import iso_register


@iso_register('SV')
class ElSalvador(WesternCalendar):
"El Salvador"
# Civil holidays
include_labour_day = True
# Christian holidays
include_holy_thursday = True
include_good_friday = True
include_easter_saturday = True

FIXED_HOLIDAYS = WesternCalendar.FIXED_HOLIDAYS + (
(5, 10, "Mothers' Day"),
(6, 17, "Fathers' Day"),
(8, 6, "Celebrations of San Salvador"),
(9, 15, "Independence Day"),
(11, 2, "All Saints Day"),
)
26 changes: 21 additions & 5 deletions workalendar/asia/china.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@
'Dragon Boat Festival': [(6, 3), (6, 4), (6, 5)],
'Mid-Autumn Festival': [(9, 10), (9, 11), (9, 12)]
},
2023:
{
'Ching Ming Festival': [(4, 5)],
'Labour Day Holiday': [(4, 29), (4, 30), (5, 1), (5, 2), (5, 3)],
'Dragon Boat Festival': [(6, 22), (6, 23), (6, 24)],
'Mid-Autumn Festival': [(9, 29)],
'National Day': [(9, 30)]
},
}

workdays = {
Expand Down Expand Up @@ -80,18 +88,21 @@
'Labour Day Holiday Shift': [(4, 24), (5, 7)],
'National Day Shift': [(10, 8), (10, 9)]
},
2023:
{
'Spring Festival Shift': [(1, 28), (1, 29)],
'Labour Day Holiday Shift': [(4, 23), (5, 6)],
'Dragon Boat Festival Shift': [(6, 25)],
'National Day Shift': [(10, 7), (10, 8)]
},
}


@iso_register('CN')
class China(ChineseNewYearCalendar):
"China"
# WARNING: Support 2018-2022 currently, need update every year.
# WARNING: Support 2018-2023 currently, need update every year.
shift_new_years_day = True
# National Days, 10.1 - 10.7
national_days = [(10, i, "National Day") for i in range(1, 8)]
FIXED_HOLIDAYS = tuple(national_days)

include_chinese_new_year_eve = True

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -119,6 +130,11 @@ def get_variable_days(self, year):
for i in range(2, 7):
days.append((ChineseNewYearCalendar.lunar(year, 1, i),
"Spring Festival"))
# National Days, 10.1 - 10.7 in general
for i in range(1, 8):
if date(year, 10, i) not in self.extra_working_days:
days.append((date(year, 10, i), "National Day"))

# other holidays
for holiday_name, day_list in holidays[year].items():
for v in day_list:
Expand Down
4 changes: 2 additions & 2 deletions workalendar/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import convertdate
from dateutil import easter
from lunardate import LunarDate
from lunarcalendar import Lunar

from .exceptions import (
UnsupportedDateType, CalendarError,
Expand Down Expand Up @@ -272,7 +272,7 @@ class LunarMixin:
"""
@staticmethod
def lunar(year, month, day):
return LunarDate(year, month, day).toSolarDate()
return Lunar(year, month, day, isleap=False).to_date()


class ChineseNewYearMixin(LunarMixin):
Expand Down
32 changes: 15 additions & 17 deletions workalendar/europe/netherlands.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,32 +159,30 @@ def get_fall_holidays(self, year):
(start + timedelta(days=i), "Fall holiday") for i in range(n_days)
]

def get_christmas_holidays(self, year, in_december=True, in_january=True):
def get_christmas_holidays(self, year):
"""
Return Christmas holidays

Christmas holidays run partially in December and partially in January
(spillover from previous year).
"""
return (
self._get_christmas_holidays_december(year) +
self._get_christmas_holidays_january(year)
)

if in_december:

# 27 December is always in a full week of holidays
week = date(year, 12, 27).isocalendar()[1]

# Holiday starts on the preceding Saturday
start = self.get_iso_week_date(year, week - 1, ISO_SAT)
dates = [
(start + timedelta(days=i), "Christmas holiday")
for i in range((date(year, 12, 31) - start).days + 1)
]
def _get_christmas_holidays_december(self, year):
# 27 December is always in a full week of holidays
week = date(year, 12, 27).isocalendar()[1]

if in_january:
dates.extend(
self.get_christmas_holidays(year, in_december=False)
)
return dates
# Holiday starts on the preceding Saturday
start = self.get_iso_week_date(year, week - 1, ISO_SAT)
return [
(start + timedelta(days=i), "Christmas holiday")
for i in range((date(year, 12, 31) - start).days + 1)
]

def _get_christmas_holidays_january(self, year):
# 27 December is always in a full week of holidays
week = date(year - 1, 12, 27).isocalendar()[1]

Expand Down
3 changes: 3 additions & 0 deletions workalendar/europe/united_kingdom.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class UnitedKingdom(WesternCalendar):
2012: [(date(2012, 6, 5), "Queen’s Diamond Jubilee"), ],
2022: [(date(2022, 6, 3), "Queen’s Platinum Jubilee bank holiday"),
(date(2022, 9, 19), "State Funeral of Queen Elizabeth II"), ],
2023: [
(date(2023, 5, 8), "Coronation of His Majesty King Charles III"),
],
}

def get_early_may_bank_holiday(self, year):
Expand Down
Loading
Loading