Implement Next and Previous for month datatype
This commit is contained in:
parent
a48509e041
commit
704a520993
@ -22,6 +22,22 @@ func (m Month) FirstOfMonth() time.Time {
|
|||||||
return time.Date(m.Year, time.Month(m.Month), 1, 0, 0, 0, 0, time.Now().Location())
|
return time.Date(m.Year, time.Month(m.Month), 1, 0, 0, 0, 0, time.Now().Location())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m Month) Previous() Month {
|
||||||
|
if m.Month == 1 {
|
||||||
|
return Month{Year: m.Year - 1, Month: 12}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Month{Year: m.Year, Month: m.Month - 1}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m Month) Next() Month {
|
||||||
|
if m.Month == 12 {
|
||||||
|
return Month{Year: m.Year + 1, Month: 1}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Month{Year: m.Year, Month: m.Month + 1}
|
||||||
|
}
|
||||||
|
|
||||||
func (m Month) InFuture(date time.Time) bool {
|
func (m Month) InFuture(date time.Time) bool {
|
||||||
if m.Year < date.Year() {
|
if m.Year < date.Year() {
|
||||||
return true
|
return true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user