fuzzytime

package
v0.0.0-...-d280c18 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package fuzzytime contains helper functions to parse times in a more fuzzy and natural manner, compared to the built-in time.Parse which only attempts a single format.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownFormat is returned when no time layout format was matched.
	ErrUnknownFormat = errors.New("unknown time format")
)

Functions

func Parse

func Parse(s string, base time.Time) (time.Time, error)

Parse attempts to parse the string literal "now", a delta time, a list of known formats, and lastly via the `when` fuzzy parsing package, and returns the time on the first match it finds.

func ParseDelta

func ParseDelta(s string, base time.Time) (time.Time, bool)

ParseDelta attempts to parse the string as a time.Duration if it is prefixed with a sign ("+" or "-"), and adds that to the current time.

func ParseKnownLayouts

func ParseKnownLayouts(s string) (time.Time, error)

ParseKnownLayouts attempts to parse the string according to the date formats defined in the IETF RFC822, RFC580, RFC1123, or RFC3339.

func ParseWhen

func ParseWhen(s string, base time.Time) (time.Time, error)

ParseWhen performs a fuzzy time parsing via the `when` package.

Types

This section is empty.

Jump to

Keyboard shortcuts

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