Help us shape the future of Go! Take the 2026 Go Developer Survey

timeutil

package
v1.5.30 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Lookback added in v1.5.15

func Lookback(s string) (d time.Duration, ok bool)

Lookback reports the span of a past-relative duration ("24h", "30d") — the form Parse reads as "now minus duration". ok is false for every other form (absolute times, "now", "+" future offsets).

func Parse

func Parse(s string) (int64, error)

Parse converts a time string to a unix timestamp (seconds). Supported formats:

  • Go duration (relative to now): "5m", "1h", "24h", "168h" Interpreted as "now minus duration"
  • Future duration with "+" prefix: "+24h", "+7d" Interpreted as "now plus duration"
  • Day shorthand: "7d", "30d" — converted to hours automatically
  • Date: "2026-04-01" (parsed as local midnight)
  • Datetime: "2026-04-01 10:00:00" or "2026-04-01T10:00:00" (parsed as local time)
  • RFC3339 with timezone: "2026-04-01T10:00:00+08:00" / "...Z" (the format the SDK emits)
  • Unix timestamp in seconds: "1712000000" (passed through)
  • Unix timestamp in milliseconds: "1712000000000" (divided down to seconds; distinguished from seconds by magnitude — see msThreshold below)

Types

This section is empty.

Jump to

Keyboard shortcuts

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