nltime

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package nltime parses natural-language time expressions into time.Time or time.Duration values.

Supported Expressions

  • Relative: "3 days ago", "in 2 hours", "5 minutes from now"
  • Absolute: "yesterday", "today", "tomorrow", "now"
  • Short: "3d ago", "2h from now", "5m ago", "10s later"
  • Named: "next monday", "last friday", "this weekend"
  • Time of day: "3pm", "10:30", "noon", "midnight"
  • Combined: "tomorrow at 3pm", "next monday 10:00"

Quick start

t, err := nltime.Parse("3 days ago", time.Now())
t, err := nltime.Parse("tomorrow at 3pm", time.Now())
d, err := nltime.ParseDuration("2 hours 30 minutes")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustParse

func MustParse(expr string, now time.Time) time.Time

MustParse is like Parse but panics on error.

func MustParseDuration

func MustParseDuration(expr string) time.Duration

MustParseDuration is like ParseDuration but panics on error.

func Parse

func Parse(expr string, now time.Time) (time.Time, error)

Parse parses a natural-language time expression relative to `now`. Returns the parsed time and an error if the expression is not understood.

func ParseDuration

func ParseDuration(expr string) (time.Duration, error)

ParseDuration parses a natural-language duration string. Supports compound expressions like "2 hours 30 minutes" or "1d 2h 30m". Returns the total duration.

Types

This section is empty.

Jump to

Keyboard shortcuts

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