forked from DGNum/gestioCOF
using strftime instead of a personnal function
This commit is contained in:
parent
de3db1405e
commit
e6854d7987
1 changed files with 6 additions and 46 deletions
|
@ -1,73 +1,33 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
french_days = {
|
|
||||||
1: "lundi",
|
|
||||||
2: "mardi",
|
|
||||||
3: "mercredi",
|
|
||||||
4: "jeudi",
|
|
||||||
5: "vendredi",
|
|
||||||
6: "samedi",
|
|
||||||
7: "dimanche",
|
|
||||||
}
|
|
||||||
|
|
||||||
french_months = {
|
# donne le nom des jours d'une liste de dates
|
||||||
1: "janvier",
|
|
||||||
2: "février",
|
|
||||||
3: "mars",
|
|
||||||
4: "avril",
|
|
||||||
5: "mai",
|
|
||||||
6: "juin",
|
|
||||||
7: "juillet",
|
|
||||||
8: "août",
|
|
||||||
9: "septembre",
|
|
||||||
10: "octobre",
|
|
||||||
11: "novembre",
|
|
||||||
12: "décembre",
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def dayname(date):
|
|
||||||
return french_days[date.isoweekday()]
|
|
||||||
|
|
||||||
|
|
||||||
def weekname(date):
|
|
||||||
(_, a, _) = date.isocalendar()
|
|
||||||
week_num = a
|
|
||||||
return "semaine %d" % week_num
|
|
||||||
|
|
||||||
|
|
||||||
def monthname(date):
|
|
||||||
return french_months[date.month]
|
|
||||||
|
|
||||||
|
|
||||||
# Pareil mais pour une liste de dates
|
|
||||||
# dans un dico ordonné
|
# dans un dico ordonné
|
||||||
def daynames(dates):
|
def daynames(dates):
|
||||||
names = {}
|
names = {}
|
||||||
for i in dates:
|
for i in dates:
|
||||||
names[i] = dayname(dates[i])
|
names[i] = dates[i].strftime("%A")
|
||||||
return names
|
return names
|
||||||
|
|
||||||
|
|
||||||
# Pareil mais pour une liste de dates
|
# donne le nom des semaines une liste de dates
|
||||||
# dans un dico ordonné
|
# dans un dico ordonné
|
||||||
def weeknames(dates):
|
def weeknames(dates):
|
||||||
names = {}
|
names = {}
|
||||||
for i in dates:
|
for i in dates:
|
||||||
names[i] = weekname(dates[i])
|
names[i] = dates[i].strftime("Semaine %W")
|
||||||
return names
|
return names
|
||||||
|
|
||||||
|
|
||||||
# Pareil mais pour une liste de dates
|
# donne le nom des mois d'une liste de dates
|
||||||
# dans un dico ordonné
|
# dans un dico ordonné
|
||||||
def monthnames(dates):
|
def monthnames(dates):
|
||||||
names = {}
|
names = {}
|
||||||
for i in dates:
|
for i in dates:
|
||||||
names[i] = monthname(dates[i])
|
names[i] = dates[i].strftime("%B")
|
||||||
return names
|
return names
|
||||||
|
|
||||||
|
|
||||||
# rend les dates des nb derniers jours
|
# rend les dates des nb derniers jours
|
||||||
# dans l'ordre chronologique
|
# dans l'ordre chronologique
|
||||||
# aujourd'hui compris
|
# aujourd'hui compris
|
||||||
|
|
Loading…
Reference in a new issue