Documentation
¶
Index ¶
- Variables
- type DateTime
- func (dt *DateTime) Add(d time.Duration) *DateTime
- func (dt *DateTime) AddDate(years int, months int, days int) *DateTime
- func (dt *DateTime) After(t *DateTime) bool
- func (dt *DateTime) Before(t *DateTime) bool
- func (dt *DateTime) Day() int
- func (dt *DateTime) EndOfDay() *DateTime
- func (dt *DateTime) EndOfHour() *DateTime
- func (dt *DateTime) EndOfMonth() *DateTime
- func (dt *DateTime) EndOfWeek() *DateTime
- func (dt *DateTime) EndOfYear() *DateTime
- func (dt *DateTime) Equal(t *DateTime) bool
- func (dt *DateTime) Format(pattern ...string) string
- func (dt *DateTime) Hour() int
- func (dt *DateTime) Location() *time.Location
- func (dt *DateTime) Millisecond() int
- func (dt *DateTime) Minute() int
- func (dt *DateTime) Month() int
- func (dt *DateTime) Second() int
- func (dt *DateTime) SetTimeZone(timezone string) error
- func (dt *DateTime) StartOfDay() *DateTime
- func (dt *DateTime) StartOfHour() *DateTime
- func (dt *DateTime) StartOfMonth() *DateTime
- func (dt *DateTime) StartOfWeek() *DateTime
- func (dt *DateTime) StartOfYear() *DateTime
- func (dt *DateTime) Sub(t *DateTime) time.Duration
- func (dt *DateTime) Time() time.Time
- func (dt *DateTime) Timestamp() int64
- func (dt *DateTime) WeekDay() int
- func (dt *DateTime) Year() int
Constants ¶
This section is empty.
Variables ¶
var DefaultFormatPattern = "YYYY-MM-DD HH:mm:ss"
DefaultFormatPattern is the default format pattern.
var LocalesWeekDays = []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}
LocalesWeekDays is the week days.
var LocalesWeekDaysMin = []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}
LocalesWeekDaysMin is the week days in minium.
var LocalesWeekDaysShort = []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}
LocalesWeekDaysShort is the week days in short.
Functions ¶
This section is empty.
Types ¶
type DateTime ¶
type DateTime struct {
// contains filtered or unexported fields
}
DateTime is a struct that represents a datetime.
func FromDate ¶
FromDate returns a DateTime from a Date. Example:
FromDate(2022, 4, 12, 10, 39, 12) FromDate(2022, 4, 12, 10, 39, 12, "Asia/Shanghai")
func FromPattern ¶
FromPattern returns a DateTime from a pattern and a datetime string. Example:
pattern := "YYYY/MM/DD HH:mm:ss" datetime := "2022/04/12 10:39:12" dt, err := FromPattern(pattern, datetime) dt, err := FromPattern(pattern, datetime, "Asia/Shanghai")
func FromTime ¶
FromTime returns a DateTime from time.Time. Example:
t := time.Now() dt := FromTime(t)
func New ¶
New returns a DateTime Support:
time.Time example: New(time.Now())
YYYY/MM/DD HH:mm:ss, datetime string example: New("YYYY/MM/DD HH:mm:ss", "2022/04/12 10:39:12") New("YYYY/MM/DD HH:mm:ss", "2022/04/12 10:39:12", "Asia/Shanghai")
year, month, day, hour, minute, second example: New(2022, 4, 12, 10, 39, 12) New(2022, 4, 12, 10, 39, 12, "Asia/Shanghai")
func (*DateTime) EndOfMonth ¶
EndOfMonth returns the end of the month.
func (*DateTime) Millisecond ¶
Millisecond returns the milliseconds.
func (*DateTime) SetTimeZone ¶
SetTimeZone sets the time zone of the datetime.
func (*DateTime) StartOfDay ¶
StartOfDay returns the start of the day.
func (*DateTime) StartOfHour ¶
StartOfHour returns the start of the hour.
func (*DateTime) StartOfMonth ¶
StartOfMonth returns the start of the month.
func (*DateTime) StartOfWeek ¶
StartOfWeek returns the start of the week.
func (*DateTime) StartOfYear ¶
StartOfYear returns the start of the year.