value formula passing test

This commit is contained in:
Radu Ioan Fericean
2016-04-22 15:07:05 +03:00
parent 206d33242f
commit 768cdcc43a
17 changed files with 240 additions and 98 deletions

View File

@@ -277,3 +277,13 @@ func (wd WeekDays) Serialize(sep string) string {
}
return wdStr
}
func DaysInMonth(year int, month time.Month) float64 {
return float64(time.Date(year, month, 1, 0, 0, 0, 0, time.UTC).AddDate(0, 1, -1).Day())
}
func DaysInYear(year int) float64 {
first := time.Date(year, 1, 1, 0, 0, 0, 0, time.UTC)
last := first.AddDate(1, 0, 0)
return float64(last.Sub(first).Hours() / 24)
}