timeparse

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatISO

func FormatISO(t time.Time) string

FormatISO formats a time as an RFC3339 / ISO 8601 string in UTC.

func ParseDatetime

func ParseDatetime(s string, loc *time.Location) (time.Time, error)

ParseDatetime parses a natural-language or structured datetime string and returns the result in UTC. The provided location is used when the input has no explicit timezone (e.g. "today", "14:30", "2006-01-02 15:04").

Resolution chain (first match wins):

  1. "" -> error
  2. "now" -> time.Now().UTC()
  3. "today" -> midnight today in loc, converted to UTC
  4. "yesterday" -> midnight yesterday in loc, converted to UTC
  5. "today HH:MM[:SS]" -> today at that time in loc, to UTC
  6. "yesterday HH:MM[:SS]" -> yesterday at that time in loc, to UTC
  7. "HH:MM" -> today at that time in loc, to UTC
  8. RFC3339 -> parsed, to UTC
  9. "2006-01-02T15:04" -> in loc, to UTC

10. "2006-01-02 15:04" -> in loc, to UTC 11. "2006-01-02T15:04:05" -> in loc, to UTC 12. "2006-01-02 15:04:05" -> in loc, to UTC 13. "2006-01-02" -> midnight in loc, to UTC 14. error

Types

This section is empty.

Jump to

Keyboard shortcuts

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