v0.2.0 Latest Latest

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

Go to latest
Published: Jul 1, 2016 License: MIT Imports: 5 Imported by: 0



Package timeparse parses times in strings in a wide variety of formats to corresponding time.Times.



This section is empty.


View Source
var ErrInvalidTimeFormat = errors.New("invalid time format")

ErrInvalidTimeFormat is returned when time.Parse could not parse the time across all known valid time formats. For a list of valid time formats, see the unexported variables timeFormatsNoDay and timeFormatsWithDay in shared/helpers/timeparse.


func Parse

func Parse(nlTime string) []time.Time

Parse a natural language string to determine most likely times based on the current system time.

func ParseFromTime

func ParseFromTime(t time.Time, nlTime string) []time.Time

ParseFromTime parses a natural language string to determine most likely times based on a set time "context." The time context changes the meaning of words like "this Tuesday," "next Tuesday," etc.


type TimeContext

type TimeContext struct {
	// contains filtered or unexported fields

TimeContext is a type used to extrapolate a single piece of info, like AMPM or the month across multiple times. If any item in TimeContext is nil, the information returned in the []time.Time slice corresponding to that was arrived at on a best-guess basis. You can (and should) add a logic layer to your own application which selects the most appropriate time based on your known context beyond the text provided to timeparse.

Jump to

Keyboard shortcuts

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