Exemple #1
0
func main() {
	cal, err := calendar.NewCalendar("en_US", true)
	if err != nil {
		panic("Could not create a US calendar!")
	}

	//year := time.Now().Year()
	year := 2016

	// When is easter this year?
	easter := calendar.EasterDay(year)
	fmt.Printf("Easter %d is at %s\n", year, easter.String()[:10])

	// Show some info for March this year
	//datebonanza(year, time.Month(3))

	// Show some info for March 2000
	//datebonanza(2000, time.Month(3))

	// Show some info for the current month
	datebonanza(cal, year, time.Month(time.Now().Month()))

	notable(cal, year)
	notable(cal, year+1)

	flag(cal, year)

	fmt.Println(cal.DayName(1))
	fmt.Println(cal.MonthName(time.Month(12)))
}
Exemple #2
0
func (pp *PersonPlan) String() string {
	cal, err := calendar.NewCalendar(pp.locale, true)
	if err != nil {
		panic("No calendar available for " + pp.locale)
	}
	s := "User: "******"\n"
	s += "-----------------------------------------------\n"
	for _, day := range pp.workdays {
		s += "\n"
		s += "\t" + day.dayoftheweek.String() + " (" + cal.DayName(day.dayoftheweek) + ")\n"
		s += fmt.Sprintf("\tFrom this hour: \t%d\n", day.fromHour)
		s += fmt.Sprintf("\tUp to this hour:\t%d\n", day.uptoHour)
		s += fmt.Sprintf("\tAt this location:\t%s\n", day.location)
	}
	return s
}
func RenderWeekFrom(t time.Time, locale string) string {

	allPlans := AllPlansDummyContent()

	cal, err := calendar.NewCalendar(locale, true)
	if err != nil {
		panic("Could not create a calendar for locale " + locale + "!")
	}

	retval := ""
	retval += "<table>"

	// Headers
	retval += "<tr>"
	retval += "<td></td>"

	// Loop through 7 days from the given date
	current := t
	for i := 0; i < 7; i++ {

		// Cell
		retval += "<td><b>"

		// Contents
		retval += Num2dd(current.Day()) + ". " + cal.MonthName(current.Month())

		// End of cell
		retval += "</b></td>"

		// Advance to the next day
		current = current.AddDate(0, 0, 1)
	}

	// End of headers
	retval += "</tr>"

	// Each row is an hour
	for hour := 8; hour < 22; hour++ {
		retval += "<tr>"

		// Each column is a day
		retval += "<td>kl. " + Num2dd(hour) + ":00</td>"

		// Loop through 7 days from the given date, while using the correct hour
		current := time.Date(t.Year(), t.Month(), t.Day(), hour, 0, 0, 0, time.UTC)

		for i := 0; i < 7; i++ {

			// Cell with contents
			red, desc, _ := cal.RedDay(current)
			if red {
				retval += "<td bgcolor='#ffb0b0'>" + desc + "</td>"
			} else {
				retval += "<td>" + allPlans.HTMLHourEvents(current) + "</td>"
			}

			// Advance to the next day
			current = current.AddDate(0, 0, 1)
		}

		retval += "</tr>"
	}

	retval += "</table>"
	return retval
}