Documentation ¶
Overview ¶
Package now is a time toolkit for golang.
More details README here: https://github.com/jinzhu/now
import "github.com/jinzhu/now" now.BeginningOfMinute() // 2013-11-18 17:51:00 Mon now.BeginningOfDay() // 2013-11-18 00:00:00 Mon now.EndOfDay() // 2013-11-18 23:59:59.999999999 Mon
Example ¶
time.Now() // 2013-11-18 17:51:49.123456789 Mon BeginningOfMinute() // 2013-11-18 17:51:00 Mon BeginningOfHour() // 2013-11-18 17:00:00 Mon BeginningOfDay() // 2013-11-18 00:00:00 Mon BeginningOfWeek() // 2013-11-17 00:00:00 Sun WeekStartDay = time.Monday // Set Monday as first day BeginningOfWeek() // 2013-11-18 00:00:00 Mon BeginningOfMonth() // 2013-11-01 00:00:00 Fri BeginningOfQuarter() // 2013-10-01 00:00:00 Tue BeginningOfYear() // 2013-01-01 00:00:00 Tue EndOfMinute() // 2013-11-18 17:51:59.999999999 Mon EndOfHour() // 2013-11-18 17:59:59.999999999 Mon EndOfDay() // 2013-11-18 23:59:59.999999999 Mon EndOfWeek() // 2013-11-23 23:59:59.999999999 Sat WeekStartDay = time.Monday // Set Monday as first day EndOfWeek() // 2013-11-24 23:59:59.999999999 Sun EndOfMonth() // 2013-11-30 23:59:59.999999999 Sat EndOfQuarter() // 2013-12-31 23:59:59.999999999 Tue EndOfYear() // 2013-12-31 23:59:59.999999999 Tue // Use another time t := time.Date(2013, 02, 18, 17, 51, 49, 123456789, time.UTC) New(t).EndOfMonth() // 2013-02-28 23:59:59.999999999 Thu Monday() // 2013-11-18 00:00:00 Mon Sunday() // 2013-11-24 00:00:00 Sun EndOfSunday() // 2013-11-24 23:59:59.999999999 Sun
Output:
Index ¶
- Variables
- func BeginningOfDay() time.Time
- func BeginningOfHour() time.Time
- func BeginningOfMinute() time.Time
- func BeginningOfMonth() time.Time
- func BeginningOfQuarter() time.Time
- func BeginningOfWeek() time.Time
- func BeginningOfYear() time.Time
- func Between(time1, time2 string) bool
- func EndOfDay() time.Time
- func EndOfHour() time.Time
- func EndOfMinute() time.Time
- func EndOfMonth() time.Time
- func EndOfQuarter() time.Time
- func EndOfSunday() time.Time
- func EndOfWeek() time.Time
- func EndOfYear() time.Time
- func Monday() time.Time
- func MustParse(strs ...string) time.Time
- func MustParseInLocation(loc *time.Location, strs ...string) time.Time
- func Parse(strs ...string) (time.Time, error)
- func ParseInLocation(loc *time.Location, strs ...string) (time.Time, error)
- func Sunday() time.Time
- type Now
- func (now *Now) BeginningOfDay() time.Time
- func (now *Now) BeginningOfHour() time.Time
- func (now *Now) BeginningOfMinute() time.Time
- func (now *Now) BeginningOfMonth() time.Time
- func (now *Now) BeginningOfQuarter() time.Time
- func (now *Now) BeginningOfWeek() time.Time
- func (now *Now) BeginningOfYear() time.Time
- func (now *Now) Between(begin, end string) bool
- func (now *Now) EndOfDay() time.Time
- func (now *Now) EndOfHour() time.Time
- func (now *Now) EndOfMinute() time.Time
- func (now *Now) EndOfMonth() time.Time
- func (now *Now) EndOfQuarter() time.Time
- func (now *Now) EndOfSunday() time.Time
- func (now *Now) EndOfWeek() time.Time
- func (now *Now) EndOfYear() time.Time
- func (now *Now) Monday() time.Time
- func (now *Now) MustParse(strs ...string) (t time.Time)
- func (now *Now) Parse(strs ...string) (t time.Time, err error)
- func (now *Now) Sunday() time.Time
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var TimeFormats = []string{"1/2/2006", "1/2/2006 15:4:5", "2006", "2006-1", "2006-1-2", "2006-1-2 15", "2006-1-2 15:4", "2006-1-2 15:4:5", "1-2", "15:4:5", "15:4", "15", "15:4:5 Jan 2, 2006 MST", "2006-01-02 15:04:05.999999999 -0700 MST"}
TimeFormats default time formats will be parsed as
View Source
var WeekStartDay = time.Sunday
WeekStartDay set week start day, default is sunday
Functions ¶
func BeginningOfQuarter ¶
BeginningOfQuarter beginning of quarter
func MustParseInLocation ¶
MustParseInLocation must parse string to time in location or will panic
func ParseInLocation ¶
ParseInLocation parse string to time in location
Types ¶
type Now ¶
Now now struct
func (*Now) BeginningOfDay ¶
BeginningOfDay beginning of day
func (*Now) BeginningOfHour ¶
BeginningOfHour beginning of hour
func (*Now) BeginningOfMinute ¶
BeginningOfMinute beginning of minute
func (*Now) BeginningOfMonth ¶
BeginningOfMonth beginning of month
func (*Now) BeginningOfQuarter ¶
BeginningOfQuarter beginning of quarter
func (*Now) BeginningOfWeek ¶
BeginningOfWeek beginning of week
func (*Now) BeginningOfYear ¶
BeginningOfYear BeginningOfYear beginning of year
Click to show internal directories.
Click to hide internal directories.