Commit 17495ccc authored by Vladimir Barsukov's avatar Vladimir Barsukov
Browse files

zuptime

parent d023bbb5
package zuptime
import "time"
type ZUptime struct {
sTime time.Time
justStart time.Duration
}
func Default() *ZUptime {
return New(time.Minute)
}
func New(js time.Duration) *ZUptime {
return &ZUptime{sTime: time.Now(), justStart: js}
}
func (z ZUptime) JustStart() bool {
return time.Since(z.sTime) < z.justStart
}
func (z ZUptime) Seconds() int64 {
return int64(time.Since(z.sTime).Seconds())
}
func (z ZUptime) Minutes() int64 {
return int64(time.Since(z.sTime).Minutes())
}
func (z ZUptime) Hours() int64 {
return int64(time.Since(z.sTime).Hours())
}
func (z ZUptime) Since() time.Duration {
return time.Since(z.sTime)
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment