ctime

package
v0.0.0-...-5eee607 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LayoutTimeWithZone = "20060102150405Z0700"
	LayoutUTCTime      = "20060102150405"
	LayoutUTCEpoch     = "200601021504Z0700"
	LayoutDBTime       = "2006-01-02 15:04:05"
	LayoutLogTime      = LayoutUTCTime
)

Crawl time layouts

Variables

This section is empty.

Functions

func NormalizeUnixTime

func NormalizeUnixTime(time string) string

NormalizeUnixTime formats a Unix time with DST qualifier into a standard time formatted as 20060102150405[DS]

func ParseLogTime

func ParseLogTime(
	logtime string,
	utcepoch time.Time,
	dstlocations DSTLocation) (time.Time, error)

ParseLogTime parses a Crawl log time to a UTC time. If a UTC epoch is provided that is after the given log time, then the time is parsed in the server's local time zone as specified by dstlocations.

func ParseTZ

func ParseTZ(tz string) (*time.Location, error)

ParseTZ parses a time zone string of the form "-0700" or "-07:00" into a time.Location. "Z" is recognized as UTC.

func ParseTimeWithZone

func ParseTimeWithZone(stime string) (time.Time, error)

ParseTimeWithZone parses a Crawl format time with a timezone into a time object. If the timezone is unspecified, assumes UTC.

func SafeParseTimeWithZone

func SafeParseTimeWithZone(stime string) time.Time

SafeParseTimeWithZone behaves like ParseTimeWithZone, but returns a zero time instead of an error if the parse fails.

func SafeParseUTCEpoch

func SafeParseUTCEpoch(stime string) time.Time

SafeParseUTCEpoch parses a Crawl UTC epoch formatted as 200601021504Z0700 into a UTC time.

func SplitDstQualifier

func SplitDstQualifier(logtime string) (string, bool)

SplitDstQualifier splits a Crawl log time string into a time string and a DST qualifier that is true for Daylight Savings Time and false otherwise.

Types

type DSTLocation

type DSTLocation struct {
	// contains filtered or unexported fields
}

DSTLocation represents the non-UTC standard and DST time locations for a place

func ParseDSTLocation

func ParseDSTLocation(loc string, dst string) (DSTLocation, error)

ParseDSTLocation parses the standard and DST timezones for a place given the timezone strings

func (DSTLocation) IsZero

func (d DSTLocation) IsZero() bool

IsZero returns true for an uninitialized d

func (DSTLocation) Location

func (d DSTLocation) Location(dst bool) *time.Location

Location gets the time location, DST or normal.

func (DSTLocation) String

func (d DSTLocation) String() string

Jump to

Keyboard shortcuts

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