simpledatemath

package
v0.0.0-...-a8b8e24 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

README

Simple DateMath

The goal of this library is to support a very small subset of elastic's Date Math expressions in Go. The use case for this library is to keep APIs that allow users to express relative time ranges consistent regardless of the backend technology.

Why elasticsearch DateMath?

We are starting in the situation of having some APIs that pass values directly into an elastic Date Math expression, so maintaining compatibility means that using a subset of elasticsearch Date Math is the easiest option.

Why not time.ParseDuration?

Golang provides a means of parsing a string into a duration via time.ParseDuration, but it doesn't support any units larger than hours. For our use case, days is often the most natural unit and we expose it in our web interface already.

Resources

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(s string) (time.Duration, error)

func Validate

func Validate(s string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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