Пример #1
0
func easter(year int) time.Time {
	if _, ok := easterCache[year]; !ok {
		easter, _ := eastertime.CatholicByYear(year)
		easterCache[year] = &easter
	}

	return *easterCache[year]
}
Пример #2
0
func handlerDayOff(w http.ResponseWriter, r *http.Request) {
	year, _ := strconv.Atoi(r.URL.Query()["annee"][0])

	easterTime, _ := eastertime.CatholicByYear(year)
	easterTimeNextYear, _ := eastertime.CatholicByYear(year + 1)
	dates := map[time.Time]string{
		time.Date(year, 1, 1, 0, 0, 0, 0, time.Local):                                    "jour de l'an",
		time.Date(year, 5, 1, 0, 0, 0, 0, time.Local):                                    "F\u00eate du travail",
		time.Date(year, 5, 8, 0, 0, 0, 0, time.Local):                                    "Victoire des alliés",
		time.Date(year, 7, 14, 0, 0, 0, 0, time.Local):                                   "Fête nationale",
		time.Date(year, 8, 15, 0, 0, 0, 0, time.Local):                                   "Assomption",
		time.Date(year, 11, 1, 0, 0, 0, 0, time.Local):                                   "Toussaint",
		time.Date(year, 11, 11, 0, 0, 0, 0, time.Local):                                  "Armistice",
		time.Date(year, 12, 25, 0, 0, 0, 0, time.Local):                                  "Noel",
		time.Date(year, easterTime.Month(), easterTime.Day()+1, 0, 0, 0, 0, time.Local):  "Lundi de Pâques",
		time.Date(year, easterTime.Month(), easterTime.Day()+39, 0, 0, 0, 0, time.Local): "Ascension",
		time.Date(year, easterTime.Month(), easterTime.Day()+50, 0, 0, 0, 0, time.Local): "Pentecôte",

		time.Date(year+1, 1, 1, 0, 0, 0, 0, time.Local):                                                    "jour de l'an",
		time.Date(year+1, 5, 1, 0, 0, 0, 0, time.Local):                                                    "F\u00eate du travail",
		time.Date(year+1, 5, 8, 0, 0, 0, 0, time.Local):                                                    "Victoire des alliés",
		time.Date(year+1, 7, 14, 0, 0, 0, 0, time.Local):                                                   "Fête nationale",
		time.Date(year+1, 8, 15, 0, 0, 0, 0, time.Local):                                                   "Assomption",
		time.Date(year+1, 11, 1, 0, 0, 0, 0, time.Local):                                                   "Toussaint",
		time.Date(year+1, 11, 11, 0, 0, 0, 0, time.Local):                                                  "Armistice",
		time.Date(year+1, 12, 25, 0, 0, 0, 0, time.Local):                                                  "Noel",
		time.Date(year+1, easterTimeNextYear.Month(), easterTimeNextYear.Day()+1, 0, 0, 0, 0, time.Local):  "Lundi de Pâques",
		time.Date(year+1, easterTimeNextYear.Month(), easterTimeNextYear.Day()+39, 0, 0, 0, 0, time.Local): "Ascension",
		time.Date(year+1, easterTimeNextYear.Month(), easterTimeNextYear.Day()+50, 0, 0, 0, 0, time.Local): "Pentecôte",
	}

	fmt.Fprint(w, "var joursferies = {")
	for date, label := range dates {
		fmt.Fprintf(w, "\"%s\":\"%s\",", date.Format("02012006"), label)
	}
	fmt.Fprint(w, "};$( document ).ready(function() { jourSetCustomization(joursferies,true) ;});")
}