timetoken

package
v0.0.0-...-60192f8 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package timetoken is a simple utility to convert a text into a time value.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TimeToken

type TimeToken struct {
	Now      bool
	Factor   int
	Value    int
	Unit     string
	Absolute *time.Time
}

TimeToken contains the parsed token information.

func New

func New(s string) (res TimeToken, err error)

New parses a text and returns a TimeToken instance. The text can be: "now", "-<n><unit>", "+<n><unit>" or an absolute time.

func (*TimeToken) RelativeTo

func (t *TimeToken) RelativeTo(ts *time.Time) time.Time

RelativeTo returns the time.Time value relative to the time given in its argument. If the input is nil, it's relative to time.Now().

Jump to

Keyboard shortcuts

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