parse

package
v0.0.0-...-0798a42 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AnsiReg = regexp.MustCompile("\x1B\\[[0-?]*[ -/]*[@-~]")

Functions

func DateRange

func DateRange(s string) (start, end time.Time, err error)

ParseDateRange parses a date range into a start and end date. Dates are expected to be in the YYYY-MM-DD format.

Start and end dates are connected by the range operator ".." where end date is not included in the date range.

ParseDateRange can also parse open-ended ranges, i.e. start.. or ..end are allowed.

Relative date terms (such as "1 week 1 day" or "1w 1d") can be used, too.

func HttpLinks(r io.Reader) (io.Reader, []string)

HttpLinks searches a reader for a http link and returns a copy of the reader and a slice with links.

func MatchCache

func MatchCache(s, expr string) bool

Check if a string matches the specified regular expression. The regexp is compiled only once and stored in a cache for future use.

func MsgIDList

func MsgIDList(h *mail.Header, key string) []string

MsgIDList parses a list of message identifiers. It returns message identifiers without angle brackets. If the header field is missing, it returns nil.

This can be used on In-Reply-To and References header fields. If the field does not conform to RFC 5322, fall back to greedily parsing a subsequence of the original field.

func StripAnsi

func StripAnsi(r io.Reader) io.Reader

StripAnsi strips ansi escape codes from the reader

Types

type RelDate

type RelDate struct {
	Year  uint
	Month uint
	Day   uint
}

RelDate is the relative date in the past, e.g. yesterday would be represented as RelDate{0,0,1}.

func RelativeDate

func RelativeDate(s string) (RelDate, error)

ParseRelativeDate parses a string of relative terms into a DateAdd.

Syntax: N (year|month|week|day) ..

The following are valid inputs: 5weeks1day 5w1d

Adapted from the Go stdlib in src/time/format.go

func (RelDate) Apply

func (d RelDate) Apply(t time.Time) time.Time

Jump to

Keyboard shortcuts

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