Documentation ¶
Index ¶
- Constants
- func CurrentMillis() int64
- func Date(year int, month time.Month, day int, loc *time.Location) time.Time
- func LocalDate(year int, month time.Month, day int) time.Time
- func MustParse(layout string, value string) time.Time
- func MustParseLocal(layout string, value string) time.Time
- func OfEpochMills(millis int64) time.Time
- func OfEpochTime(secs int64) time.Time
- func ParseLocal(layout string, value string) (time.Time, error)
- func ToEpochMills(t time.Time) int64
- func TruncateToDay(t time.Time) time.Time
- func TruncateToHour(t time.Time) time.Time
- func TruncateToMinute(t time.Time) time.Time
- func TruncateToMonth(t time.Time) time.Time
- func TruncateToWeek(t time.Time) time.Time
- func TruncateToYear(t time.Time) time.Time
- type Stopwatch
Constants ¶
const SimpleDate = "2006-01-02"
const SimpleTime = "2006-01-02 15:04:05"
const SimpleTimeMills = "2006-01-02 15:04:05.000"
Variables ¶
This section is empty.
Functions ¶
func CurrentMillis ¶ added in v1.0.1
func CurrentMillis() int64
CurrentMillis return unix mills timestamp for now
func LocalDate ¶ added in v1.4.0
LocalDate create a time, at the beginning of day, at local time zone.
func MustParseLocal ¶ added in v1.8.4
MustParseLocal parse time string with layout, in local Location. If parse failed, panic
func OfEpochMills ¶ added in v1.9.0
OfEpochMills convert unix epoch mills to time
func OfEpochTime ¶ added in v1.9.0
OfEpochTime convert unix epoch seconds to time
func ParseLocal ¶ added in v1.2.0
ParseLocal parse time string with layout, in local Location
func ToEpochMills ¶
ToEpochMills convert time to unix epoch millis
func TruncateToDay ¶ added in v1.9.0
TruncateToDay return the beginning time of the day.
func TruncateToHour ¶ added in v1.9.0
TruncateToHour return the beginning time of the hour.
func TruncateToMinute ¶ added in v1.9.0
TruncateToMinute return the beginning time of the minute.
func TruncateToMonth ¶ added in v1.9.0
TruncateToMonth return the beginning time of the month.
func TruncateToWeek ¶ added in v1.9.0
TruncateToWeek return the beginning time of the week(Sunday).
Types ¶
type Stopwatch ¶ added in v1.0.1
type Stopwatch struct {
// contains filtered or unexported fields
}
Stopwatch for measure elapsed time. This class is NOT thread-safe.
func NewStopwatch ¶ added in v1.0.1
func NewStopwatch() *Stopwatch
NewStopwatch create new Stopwatch, not started.
func NewStopwatchStarted ¶ added in v1.0.1
func NewStopwatchStarted() *Stopwatch
NewStopwatchStarted create new Stopwatch, then start it.
func (*Stopwatch) Elapsed ¶ added in v1.0.1
Elapsed return elapsed time. If not started, always return zero; If started and not stopped, return time interval from begin time to now; If stopped, return elapsed time duration from started time to stopped time.
func (*Stopwatch) ElapsedMillis ¶ added in v1.6.0
ElapsedMillis return elapsed time by milli-seconds. If not started, always return zero; If started and not stopped, return time interval from begin time to now; If stopped, return elapsed time duration from started time to stopped time.