Documentation
¶
Overview ¶
Package stime provides some simplified (no time zone) time processing functions.
Example ¶
package main
import (
"fmt"
"gitee.com/erdian718/stime"
)
func main() {
date := stime.NowDate()
time := stime.NowTime()
datetime := stime.NowDateTime()
fmt.Println(date)
fmt.Println(time)
fmt.Println(datetime)
}
Index ¶
- type Date
- func (d Date) Add(dur time.Duration) Date
- func (d Date) AddWith(years int, months int, days int) Date
- func (d Date) Day() int
- func (d Date) Format(layout string) string
- func (d Date) Local() time.Time
- func (d Date) MarshalBinary() (data []byte, err error)
- func (d Date) MarshalText() (text []byte, err error)
- func (d Date) Month() time.Month
- func (d Date) String() string
- func (d Date) Sub(other Date) time.Duration
- func (d Date) UTC() time.Time
- func (d *Date) UnmarshalBinary(data []byte) error
- func (d *Date) UnmarshalText(text []byte) error
- func (d Date) Year() int
- type DateTime
- func (dt DateTime) Add(dur time.Duration) DateTime
- func (dt DateTime) AddWith(years int, months int, days int, hours int, minutes int, seconds int) DateTime
- func (dt DateTime) Day() int
- func (dt DateTime) Format(layout string) string
- func (dt DateTime) Hour() int
- func (dt DateTime) Local() time.Time
- func (dt DateTime) MarshalBinary() (data []byte, err error)
- func (dt DateTime) MarshalText() (text []byte, err error)
- func (dt DateTime) Minute() int
- func (dt DateTime) Month() time.Month
- func (dt DateTime) Second() int
- func (dt DateTime) String() string
- func (dt DateTime) Sub(other DateTime) time.Duration
- func (dt DateTime) UTC() time.Time
- func (dt *DateTime) UnmarshalBinary(data []byte) error
- func (dt *DateTime) UnmarshalText(text []byte) error
- func (dt DateTime) Year() int
- type Time
- func (t Time) Add(dur time.Duration) Time
- func (t Time) AddWith(hours int, minutes int, seconds int) Time
- func (t Time) Format(layout string) string
- func (t Time) Hour() int
- func (t Time) Local() time.Time
- func (t Time) MarshalBinary() (data []byte, err error)
- func (t Time) MarshalText() (text []byte, err error)
- func (t Time) Minute() int
- func (t Time) Second() int
- func (t Time) String() string
- func (t Time) Sub(other Time) time.Duration
- func (t Time) UTC() time.Time
- func (t *Time) UnmarshalBinary(data []byte) error
- func (t *Time) UnmarshalText(text []byte) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Date ¶
type Date uint32
Date represents a date.
func (Date) AddWith ¶
AddWith returns the date corresponding to adding the given number of years, months, and days to d.
func (Date) Format ¶
Format returns a textual representation of the date formatted according to the layout defined by the argument.
func (Date) MarshalBinary ¶
MarshalBinary encodes the receiver into a binary form and returns the result.
func (Date) MarshalText ¶
MarshalText encodes the receiver into UTF-8-encoded text and returns the result.
func (*Date) UnmarshalBinary ¶
UnmarshalBinary must be able to decode the form generated by MarshalBinary.
func (*Date) UnmarshalText ¶
UnmarshalText must be able to decode the form generated by MarshalText.
type DateTime ¶
type DateTime uint64
DateTime represents a datetime.
func NewDateTime ¶
NewDateTime creates a new datetime.
func ParseDateTime ¶
ParseDateTime parses a formatted string and returns the datetime it represents.
func (DateTime) AddWith ¶
func (dt DateTime) AddWith(years int, months int, days int, hours int, minutes int, seconds int) DateTime
AddWith returns the datetime corresponding to adding the given number of years, months, days, hours, minutes and seconds to dt.
func (DateTime) Format ¶
Format returns a textual representation of the datetime formatted according to the layout defined by the argument.
func (DateTime) MarshalBinary ¶
MarshalBinary encodes the receiver into a binary form and returns the result.
func (DateTime) MarshalText ¶
MarshalText encodes the receiver into UTF-8-encoded text and returns the result.
func (*DateTime) UnmarshalBinary ¶
UnmarshalBinary must be able to decode the form generated by MarshalBinary.
func (*DateTime) UnmarshalText ¶
UnmarshalText must be able to decode the form generated by MarshalText.
type Time ¶
type Time uint32
Time represents a time.
func (Time) AddWith ¶
AddWith returns the time corresponding to adding the given number of hours, minutes, and seconds to t.
func (Time) Format ¶
Format returns a textual representation of the time formatted according to the layout defined by the argument.
func (Time) MarshalBinary ¶
MarshalBinary encodes the receiver into a binary form and returns the result.
func (Time) MarshalText ¶
MarshalText encodes the receiver into UTF-8-encoded text and returns the result.
func (*Time) UnmarshalBinary ¶
UnmarshalBinary must be able to decode the form generated by MarshalBinary.
func (*Time) UnmarshalText ¶
UnmarshalText must be able to decode the form generated by MarshalText.