package mhayaTime import "time" func (c *MhayaTime) SetTimezone(timezone string) error { loc, err := time.LoadLocation(timezone) if err != nil { return err } c.Time = c.Time.In(loc) return nil } // SetYear 设置年 func (c MhayaTime) SetYear(year int) MhayaTime { c.Time = time.Date(year, c.Time.Month(), c.Day(), c.Hour(), c.Minute(), c.Second(), c.Nanosecond(), c.Location()) return c } // SetMonth 设置月 func (c MhayaTime) SetMonth(month int) MhayaTime { c.Time = time.Date(c.Year(), time.Month(month), c.Day(), c.Hour(), c.Minute(), c.Second(), c.Nanosecond(), c.Location()) return c } // SetDay 设置日 func (c MhayaTime) SetDay(day int) MhayaTime { c.Time = time.Date(c.Year(), c.Time.Month(), day, c.Hour(), c.Minute(), c.Second(), c.Nanosecond(), c.Location()) return c } // SetHour 设置时 func (c MhayaTime) SetHour(hour int) MhayaTime { c.Time = time.Date(c.Year(), c.Time.Month(), c.Day(), hour, c.Minute(), c.Second(), c.Nanosecond(), c.Location()) return c } // SetMinute 设置分 func (c MhayaTime) SetMinute(minute int) MhayaTime { c.Time = time.Date(c.Year(), c.Time.Month(), c.Day(), c.Hour(), minute, c.Second(), c.Nanosecond(), c.Location()) return c } // SetSecond 设置秒 func (c MhayaTime) SetSecond(second int) MhayaTime { c.Time = time.Date(c.Year(), c.Time.Month(), c.Day(), c.Hour(), c.Minute(), second, c.Nanosecond(), c.Location()) return c } // SetNanoSecond 设置纳秒 func (c MhayaTime) SetNanoSecond(nanoSecond int) MhayaTime { c.Time = time.Date(c.Year(), c.Time.Month(), c.Day(), c.Hour(), c.Minute(), c.Second(), nanoSecond, c.Location()) return c }