date

package
v0.0.0-...-62531ef Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2022 License: GPL-3.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StdParser   = NewStdParser()
	Logger      = log.StandardLogger()
	DebugLogger = func() (l *log.Logger) {
		l = log.StandardLogger()
		l.SetLevel(log.DebugLevel)
		return
	}()

	DefaultFormatParser = StdParser

	/* TODO: add parser for gamma format.*/
	DebugParser = NewLogger(
		defaultFormats.Ref(debugParser),
		Logger,
	)

	DefaultParser = NewLogger(
		defaultFormats.Ref(StdParser),
		Logger,
	)
)

Functions

This section is empty.

Types

type Checker

type Checker interface {
	In(time.Time) bool
}

type Checkers

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

func NewCheckers

func NewCheckers() (c Checkers)

func NewCheckersWithCap

func NewCheckersWithCap(capacity int) (c Checkers)

func (*Checkers) Append

func (c *Checkers) Append(ch Checker)

func (Checkers) In

func (c Checkers) In(t time.Time) (b bool)

type Date

type Date struct {
	time.Time
}

func New

func New(t time.Time) (d Date)

func (Date) SetParser

func (Date) SetParser(dateParser Parser)

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(b []byte) (err error)

type Format

type Format string

func (Format) Ref

func (f Format) Ref(parser FormatParser) (fr FormatRef)

type FormatParser

type FormatParser interface {
	ParseWithFormat(Format, string) (time.Time, error)
}

type FormatRef

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

func (FormatRef) ParseDate

func (f FormatRef) ParseDate(s string) (t time.Time, err error)

type FormatRefs

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

func (FormatRefs) ParseDate

func (f FormatRefs) ParseDate(s string) (t time.Time, err error)

type Formats

type Formats []Format

func FormatsFromStrings

func FormatsFromStrings(strings ...string) (f Formats)

func (Formats) Ref

func (f Formats) Ref(parser FormatParser) (fr FormatRefs)

type Limit

type Limit struct {
	time.Time
	// contains filtered or unexported fields
}

func (Limit) In

func (l Limit) In(t time.Time) (b bool)

type LogFormatParser

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

func NewLogFormatParser

func NewLogFormatParser(parser FormatParser, logger *log.Logger) (l LogFormatParser)

func (LogFormatParser) ParseWithFormat

func (l LogFormatParser) ParseWithFormat(fmt Format, s string) (t time.Time, err error)

type LogParser

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

func NewLogger

func NewLogger(parser Parser, logger *log.Logger) (l LogParser)

func (LogParser) ParseDate

func (l LogParser) ParseDate(s string) (t time.Time, err error)

type LongTime

type LongTime struct {
	OptionalTime
}

func (*LongTime) UnmarshalJSON

func (lt *LongTime) UnmarshalJSON(b []byte) (err error)

type MinOrMax

type MinOrMax int
const (
	Min MinOrMax = iota
	Max
)

func (MinOrMax) New

func (m MinOrMax) New(t time.Time) (l Limit)

type MultiParseError

type MultiParseError struct {
	Input     string
	LastError error
}

func (MultiParseError) Error

func (m MultiParseError) Error() (s string)

func (MultiParseError) Unwrap

func (m MultiParseError) Unwrap() (err error)

type MultiParser

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

func (MultiParser) ParseDate

func (m MultiParser) ParseDate(s string) (t time.Time, err error)

type NoChecker

type NoChecker struct{}

func NoCheck

func NoCheck() (n NoChecker)

func (NoChecker) Add

func (_ NoChecker) Add(ch Checker) (c Checkers)

func (NoChecker) Extend

func (_ NoChecker) Extend(ch ...Checker) (c Checkers)

func (NoChecker) In

func (_ NoChecker) In(_ time.Time) (b bool)

type OptionalTime

type OptionalTime struct {
	time.Time
	// contains filtered or unexported fields
}

func (OptionalTime) IsSet

func (ot OptionalTime) IsSet() (b bool)

func (*OptionalTime) Parse

func (ot *OptionalTime) Parse(b []byte, p ParseFmt) (err error)

type ParseError

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

func (ParseError) Error

func (p ParseError) Error() string

func (ParseError) Unwrap

func (p ParseError) Unwrap() error

type ParseFmt

type ParseFmt string
const (
	Short ParseFmt = "20060102"
	Long  ParseFmt = "20060102T150405"
)

func (ParseFmt) Format

func (df ParseFmt) Format(t time.Time) (s string)

func (ParseFmt) ID

func (df ParseFmt) ID(one, two time.Time) string

func (ParseFmt) NewRange

func (df ParseFmt) NewRange(start, stop string) (d Range, err error)

func (ParseFmt) Parse

func (df ParseFmt) Parse(str string) (t time.Time, err error)

type Parser

type Parser interface {
	ParseDate(string) (time.Time, error)
}

type Range

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

func NewRange

func NewRange(start, stop time.Time) (r Range)

func (Range) Center

func (d Range) Center() time.Time

func (Range) In

func (d Range) In(t time.Time) (b bool)

func (Range) Start

func (d Range) Start() time.Time

func (Range) Stop

func (d Range) Stop() time.Time

type ShortTime

type ShortTime struct {
	OptionalTime
}

func (*ShortTime) UnmarshalJSON

func (st *ShortTime) UnmarshalJSON(b []byte) (err error)

type StdFormatParser

type StdFormatParser struct{}

func NewStdParser

func NewStdParser() (s *StdFormatParser)

func (StdFormatParser) ParseWithFormat

func (StdFormatParser) ParseWithFormat(fmt Format, s string) (t time.Time, err error)

type ToTime

type ToTime interface {
	AsTime() time.Time
}

Jump to

Keyboard shortcuts

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