forked from studio1247/gertrude
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparameters.py
executable file
·56 lines (49 loc) · 2.56 KB
/
parameters.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- coding: utf-8 -*-
## This file is part of Gertrude.
##
## Gertrude is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## Gertrude is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Gertrude; if not, see <http://www.gnu.org/licenses/>.
import datetime
from paques import getPaquesDate
import __builtin__
def getWeekDays(year, weekday):
result = []
date = datetime.date(year, 1, 1)
while date.weekday() != weekday:
date += datetime.timedelta(1)
while date <= datetime.date(year, 12, 31):
result.append(date)
date += datetime.timedelta(7)
return result
def getWeekEnds(year):
return getWeekDays(year, 5) + getWeekDays(year, 6)
# Période de visualisation
today = datetime.date.today()
__builtin__.first_date = today - datetime.timedelta(24*30)
last_date = today + datetime.timedelta(24*30)
# Jours fériés
jours_fermeture = []
jours_fermeture.append(("Week-end", lambda year: getWeekEnds(year), True))
jours_fermeture.append(("Lundi", lambda year: getWeekDays(year, 0), True))
jours_fermeture.append(("Mercredi", lambda year: getWeekDays(year, 2), True))
jours_fermeture.append(("1er janvier", lambda year: datetime.date(year, 1, 1), True))
jours_fermeture.append(("1er mai", lambda year: datetime.date(year, 5, 1), True))
jours_fermeture.append(("8 mai", lambda year: datetime.date(year, 5, 8), True))
jours_fermeture.append(("14 juillet", lambda year: datetime.date(year, 7, 14), True))
jours_fermeture.append((u"15 août", lambda year: datetime.date(year, 8, 15), True))
jours_fermeture.append(("1er novembre", lambda year: datetime.date(year, 11, 1), True))
jours_fermeture.append(("11 novembre", lambda year: datetime.date(year, 11, 11), True))
jours_fermeture.append((u"25 décembre", lambda year: datetime.date(year, 12, 25), True))
jours_fermeture.append((u"Lundi de Pâques", lambda year: getPaquesDate(year) + datetime.timedelta(1), True))
jours_fermeture.append(("Jeudi de l'Ascension", lambda year: getPaquesDate(year) + datetime.timedelta(39), True))
jours_fermeture.append((u"Lundi de Pentecôte", lambda year: getPaquesDate(year) + datetime.timedelta(50), False))