func BeginOf(t time.Time, unit UnitOfTime) time.Time {
	year := t.Year()
	month := t.Month()
	day := t.Day()
	hour := t.Hour()
	minute := t.Minute()
	second := t.Second()
	loc := t.Location()
	switch unit {
	case Second:
		return time.Date(year, month, day, hour, minute, second, 0, loc)
	case Minute:
		return time.Date(year, month, day, hour, minute, 0, 0, loc)
	case Hour:
		return time.Date(year, month, day, hour, 0, 0, 0, loc)
	case Day:
		return time.Date(year, month, day, 0, 0, 0, 0, loc)
	case Month:
		return time.Date(year, month, 1, 0, 0, 0, 0, loc)
	case Year:
		return time.Date(year, time.January, 1, 0, 0, 0, 0, loc)
	default:
		return t
	}
}
BeginOf returns the begin of the passed unit for the given time.
package timex
import (
	"time"
)
func YearInList(t time.Time, years []int) bool {
	for _, year := range years {
		if t.Year() == year {
			return true
		}
	}
	return false
}
func YearInRange(t time.Time, minYear, maxYear int) bool {
	return (minYear <= t.Year()) && (t.Year() <= maxYear)
}
func MonthInList(t time.Time, months []time.Month) bool {
	for _, month := range months {
		if t.Month() == month {
			return true
		}
	}
	return false
}
func MonthInRange(t time.Time, minMonth, maxMonth time.Month) bool {
	return (minMonth <= t.Month()) && (t.Month() <= maxMonth)
}
func DayInList(t time.Time, days []int) bool {
	for _, day := range days {
		if t.Day() == day {
			return true
		}
	}
	return false
}
func DayInRange(t time.Time, minDay, maxDay int) bool {
	return (minDay <= t.Day()) && (t.Day() <= maxDay)
}
func HourInList(t time.Time, hours []int) bool {
	for _, hour := range hours {
		if t.Hour() == hour {
			return true
		}
	}
	return false
}
func HourInRange(t time.Time, minHour, maxHour int) bool {
	return (minHour <= t.Hour()) && (t.Hour() <= maxHour)
}
func MinuteInList(t time.Time, minutes []int) bool {
	for _, minute := range minutes {
		if t.Minute() == minute {
			return true
		}
	}
	return false
}
func MinuteInRange(t time.Time, minMinute, maxMinute int) bool {
	return (minMinute <= t.Minute()) && (t.Minute() <= maxMinute)
}
func SecondInList(t time.Time, seconds []int) bool {
	for _, second := range seconds {
		if t.Second() == second {
			return true
		}
	}
	return false
}
func SecondInRange(t time.Time, minSecond, maxSecond int) bool {
	return (minSecond <= t.Second()) && (t.Second() <= maxSecond)
}
func WeekdayInList(t time.Time, weekdays []time.Weekday) bool {
	for _, weekday := range weekdays {
		if t.Weekday() == weekday {
			return true
		}
	}
	return false
}
func WeekdayInRange(t time.Time, minWeekday, maxWeekday time.Weekday) bool {
	return (minWeekday <= t.Weekday()) && (t.Weekday() <= maxWeekday)
}
type UnitOfTime int
const (
	Second UnitOfTime = iota + 1
	Minute
	Hour
	Day
	Month
	Year
)