timeparse

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

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.

Functions

func Parse

func Parse(nlTimes ...string) ([]time.Time, error)

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

func ParseFromTime

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

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.

Types

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