Socket
Socket
Sign inDemoInstall

github.com/timberio/go-datemath

Package Overview
Dependencies
0
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/timberio/go-datemath

Package datemath provides an expression language for relative dates based on Elasticsearch's date math. This package is useful for letting end-users describe dates in a simple format similar to Grafana and Kibana and for persisting them as relative dates. The expression starts with an anchor date, which can either be "now", or an ISO8601 date string ending with ||. This anchor date can optionally be followed by one or more date math expressions, for example: The supported time units are: This package aims to be a superset of Elasticsearch's expressions. That is, any datemath expression that is valid for Elasticsearch should evaluate in the same way here. Currently the package does not support expressions outside of those also considered valid by Elasticsearch, but this may change in the future to include additional functionality.


Version published

Readme

Source

go-datemath

GoDoc Circle CI Go Report Card coverage

This library provides support for parsing datemath expressions compatibly with Elasticsearch datemath expressions. These are useful for allowing users to specify, and for encoding, relative dates. Examples:

  • now+15m: 15 minutes from now
  • now-1w+1d: one day after on week ago
  • 2015-05-05T00:00:00||+1M: one month after 2019-05-05

These expressions will seem familiar if you have used Grafana or Kibana.

Example usage:

expr, _ := datemath.Parse("now-15m")
fmt.Println(t.Time(datemath.WithNow(now)))

See package documentation for usage and more examples.

Development / Contributing

See CONTRIBUTING.md.

FAQs

Last updated on 13 Oct 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc