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 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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