Categorygithub.com/zhuliquan/datemath_parser
modulepackage
0.0.10
Repository: https://github.com/zhuliquan/datemath_parser.git
Documentation: pkg.go.dev

# README

datemath-parser

this package is pure go package, this package can parse date match expression, which used by ElasticSearch.

Date Math Definition

you can click here to see date math definition. The date type supports using date math expression when using it in a range date query. The expression starts with an "anchor" date, which can be either now or a date string (in the applicable format) ending with ||. It can then follow by a math expression, supporting +, - and / (time rounding symbol). The support time units are:

time unit symbolmeaning
yYears
MMonths
wWeeks
dDays
hHours
HHours
mMinutes
sSeconds

Here are some samples: now+1h, now+1h+1m, now+1h/d, 2012-01-01||+1M/d.

Note, when doing range type searches, and the upper value is inclusive, the rounding will properly be rounded to the ceiling instead of flooring it.

Usage

Returns a time.Time struct object, which store utc time.

package main

import (
    "fmt"
    "github.com/zhuliquan/datemath_parser"
)

func main() {
    var parser = datemath_parser.NewDataMathParser()
    if t, err := parser.Parse("now+7M/d"); err != nil {
        fmt.Println(err)
    } else {
        fmt.Println(t)
    } 
}

# Functions

No description provided by the author
No description provided by the author
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

built-in format.
No description provided by the author

# Structs

No description provided by the author

# Type aliases

No description provided by the author