timetext

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package timetext reads dates and times as the date and time matchers write them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CutOffset

func CutOffset(text string) (base string, n int, unit string, ok bool)

CutOffset cuts the offset off the end of text, such as "now +3 days": base is what comes before it, n the signed number and unit the word after it. ok is false when text doesn't end in an offset.

func Format

func Format(t time.Time, zoned bool) string

Format writes a date and time as Parse reads it: in RFC 3339 when zoned, or else in ISO 8601 without a zone.

func HasZone

func HasZone(layout string) bool

HasZone reports whether a Go time layout writes a zone: an abbreviation, MST, or an offset, such as Z07:00 or -0700.

func Parse

func Parse(text string) (t time.Time, zoned bool, err error)

Parse reads a date and time in one of the formats read by default: RFC 3339, with or without a fraction of a second; the three formats of HTTP dates, as http.ParseTime reads them; or ISO 8601 without a zone, with or without the time. zoned reports whether text gives a zone; HTTP dates are in GMT. A local date and time is read as UTC.

func ParseLayout

func ParseLayout(text, layout string) (t time.Time, zoned bool, err error)

ParseLayout reads text in layout, a Go time layout. zoned reports whether the layout writes a zone; when it doesn't, the date and time is read as UTC.

Types

This section is empty.

Jump to

Keyboard shortcuts

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