Documentation
¶
Index ¶
- Constants
- func Date(year int, month time.Month, day int, loc *time.Location) time.Time
- func EpochMills() int64
- 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 OfEpochSeconds(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 MustParseLocal ¶
MustParseLocal parse time string with layout, in local Location. If parse failed, panic
func OfEpochMills ¶
OfEpochMills convert unix epoch mills to time
func OfEpochSeconds ¶
OfEpochSeconds convert unix epoch seconds to time
func ParseLocal ¶
ParseLocal parse time string with layout, in local Location
func ToEpochMills ¶
ToEpochMills convert time to unix epoch millis
func TruncateToDay ¶
TruncateToDay return the beginning time of the day.
func TruncateToHour ¶
TruncateToHour return the beginning time of the hour.
func TruncateToMinute ¶
TruncateToMinute return the beginning time of the minute.
func TruncateToMonth ¶
TruncateToMonth return the beginning time of the month.
func TruncateToWeek ¶
TruncateToWeek return the beginning time of the week(Sunday).
Types ¶
type Stopwatch ¶
type Stopwatch struct {
// contains filtered or unexported fields
}
Stopwatch for measure elapsed time. The zero value is valid, as an un-started stopwatch. This is not thread-safe.
func NewStopwatchStarted ¶
func NewStopwatchStarted() *Stopwatch
NewStopwatchStarted create new Stopwatch, then start it.
func (*Stopwatch) ElapsedMillis ¶
ElapsedMillis return elapsed time by milliseconds.
func (*Stopwatch) ElapsedNanos ¶
ElapsedNanos return elapsed time by nanoseconds.
func (*Stopwatch) Reset ¶
func (w *Stopwatch) Reset()
Reset resets the Stopwatch. The elapsed time will set to zero, the status will set to not running.
func (*Stopwatch) Start ¶
func (w *Stopwatch) Start()
Start the Stopwatch. If StopWatch is already started, panics with an error. A stopped Stopwatch can start again.