Documentation
¶
Index ¶
Examples ¶
Constants ¶
View Source
const (
MaximumPOSIXBranches = 512
)
Variables ¶
View Source
var ( ErrNotImplemented = errors.New("not implemented") ErrInvalidFormatString = errors.New("invalid format string") ErrFormatStringTooComplex = errors.New("format string is too complex to be parsed") ErrInvalidTime = errors.New("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 FromPOSIX ¶
FromPOSIX converts a POSIX time format string like %Y-%m-%d and converts it to a list of time formats compatible with this package.
func Parse ¶
Parse is a convenience function that calls Root().Parse().
Example ¶
package main
import (
"fmt"
"time"
"github.com/puppetlabs/leg/timeutil/pkg/parseext"
)
func main() {
t1, _ := time.Parse(time.RFC3339, "2006-01-02T15:04:05+07:00")
t2, err := parseext.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)
}
}
func ParseInLocation ¶
ParseInLocation is a convenience function that calls Root().ParseInLocation().
Types ¶
type TimeTree ¶
type TimeTree struct {
// contains filtered or unexported fields
}
TimeTree is a compiled list of time formats.
func (*TimeTree) IsTime ¶
IsTime returns whether the given input would be considered a valid time value.
Click to show internal directories.
Click to hide internal directories.