httime

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StrftimeChar        = "%"
	UnixTimestampFmt    = "%s(%L)?"
	UnixTimestampFmtAlt = "%s(.%L)?"
	UnixTimestampFmtTxt = "unixepoch"
)

Variables

This section is empty.

Functions

func GetTimestamp

func GetTimestamp(m map[string]interface{}, timeFieldName, timeFieldFormat string) time.Time

GetTimestamp looks through the event map for something that looks like a timestamp.

It will guess at the key name or use the specified one if it is not an empty string. If unable to parse the timestamp, it will return the current time. The time field will be deleted from the map if found.

func Now

func Now() time.Time

func Parse

func Parse(format, timespec string) (time.Time, error)

Parse wraps time.ParseInLocation to use httime's Location from parsers

Types

type Nower

type Nower interface {
	Now() time.Time
}
var (
	// DefaultNower returns current time when called with Now() unless overridden
	DefaultNower Nower = &RealNower{}
	// Location defaults to UTC unless overridden
	Location *time.Location = time.UTC
)

type RealNower

type RealNower struct{}

func (*RealNower) Now

func (r *RealNower) Now() time.Time

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL