Documentation ¶
Overview ¶
Package xtime is a time parser that parses the time without knowning the exact format.
Index ¶
- Constants
- Variables
- func FromPOSIX(format string) ([]string, error)
- func IsTime(t string) bool
- func Parse(t string) (time.Time, error)
- func ParseInLocation(t string, loc *time.Location) (time.Time, error)
- func TimezoneOffset(offset string) (hours int, minutes int, err error)
- func TimezoneOffsetAt(offset string, t time.Time) (hours int, minutes int, err error)
- func WindowsLocationString(l *time.Location) (name string, err error)
- type TimeTree
Examples ¶
Constants ¶
View Source
const (
MaximumPOSIXBranches = 512
)
Variables ¶
View Source
var ( ErrNotImplemented = errors.New("xtime: not implemented") ErrInvalidFormatString = errors.New("xtime: invalid format string") ErrFormatStringTooComplex = errors.New("xtime: format string is too complex to be parsed") ErrInvalidTime = errors.New("xtime: invalid time") )
View Source
var TimeFormats = []string{
"Mon Jan _2 15:04:05 2006",
"Mon Jan 02 15:04:05 -0700 2006",
"Mon Jan 02 15:04:05 -07:00 2006",
"02 Jan 06 15:04 -0700",
"02 Jan 06 15:04 -07:00",
"Monday, 02-Jan-06 15:04:05",
"Monday, 02-Jan-06 15:04:05 -0700",
"Monday, 02-Jan-06 15:04:05 -07:00",
"Mon, 02 Jan 2006 15:04:05",
"Mon, 02 Jan 2006 15:04:05 -0700",
"Mon, 02 Jan 2006 15:04:05 -07:00",
"2006-01-02T15:04:05",
"2006-01-02T15:04:05Z0700",
"2006-01-02T15:04:05Z07:00",
"2006-01-02T15:04:05.999999999Z07:00",
"2006-01-02T15:04:05.999Z07:00",
"Jan _2 15:04:05",
"Jan _2 15:04:05.000",
"Jan _2 15:04:05.000000",
"Jan _2 15:04:05.000000000",
"_2/Jan/2006:15:04:05 -0700",
"_2/Jan/2006:15:04:05 -07:00",
"Jan 2, 2006 3:04:05 PM",
"Jan 2 2006 15:04:05",
"Jan 2 15:04:05 2006",
"Jan 2 15:04:05 -0700",
"2006-01-02 15:04:05,000 -0700",
"2006-01-02 15:04:05,000 -07:00",
"2006-01-02 15:04:05 -0700",
"2006-01-02 15:04:05 -07:00",
"2006-01-02 15:04:05-0700",
"2006-01-02 15:04:05-07:00",
"2006-01-02 15:04:05,000",
"2006-01-02 15:04:05",
"2006/01/02 15:04:05",
"2006/01/02",
"2006-01-02",
"01/02/2006",
"01/02/2006 15:04:05",
"06-01-02 15:04:05,000 -0700",
"06-01-02 15:04:05,000 -07:00",
"06-01-02 15:04:05,000",
"06-01-02 15:04:05",
"06/01/02 15:04:05",
"15:04:05,000",
"1/2/2006 3:04:05 PM",
"1/2/06 3:04:05.000 PM",
"1/2/2006 15:04",
"1/2/2006",
"2006/1/2",
}
TimeFormats is a list of commonly seen time formats from log messages
Functions ¶
func Parse ¶
Example ¶
t1, _ := time.Parse(time.RFC3339, "2006-01-02T15:04:05+07:00") t2, err := Parse("2006-01-02T15:04:05+07:00") if err != nil { fmt.Println(err) } else if t1.UnixNano() != t2.UnixNano() { fmt.Printf("%d != %d\n", t1.UnixNano(), t2.UnixNano()) } else { fmt.Println(t2) }
Output:
func TimezoneOffsetAt ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.