{"id":20672458,"url":"https://github.com/zhuliquan/datemath_parser","last_synced_at":"2026-04-12T22:32:55.360Z","repository":{"id":57644225,"uuid":"439642934","full_name":"zhuliquan/datemath_parser","owner":"zhuliquan","description":"This package can parse date match expression, which used by ElasticSearch","archived":false,"fork":false,"pushed_at":"2024-05-24T16:27:13.000Z","size":39,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-31T22:48:41.984Z","etag":null,"topics":["datemath","elasticsearch","golang","parser"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zhuliquan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-18T14:59:39.000Z","updated_at":"2024-05-24T16:24:41.000Z","dependencies_parsed_at":"2025-03-10T17:55:45.966Z","dependency_job_id":"cd3d10e0-6506-47a4-8c7a-16864b0be1f0","html_url":"https://github.com/zhuliquan/datemath_parser","commit_stats":null,"previous_names":["zhuliquan/datemath-parser"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/zhuliquan/datemath_parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhuliquan%2Fdatemath_parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhuliquan%2Fdatemath_parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhuliquan%2Fdatemath_parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhuliquan%2Fdatemath_parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhuliquan","download_url":"https://codeload.github.com/zhuliquan/datemath_parser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhuliquan%2Fdatemath_parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279019298,"owners_count":26086709,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["datemath","elasticsearch","golang","parser"],"created_at":"2024-11-16T20:37:36.107Z","updated_at":"2025-10-14T15:11:17.292Z","avatar_url":"https://github.com/zhuliquan.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# datemath-parser\r\n\r\nthis package is pure go package, this package can parse date match expression, which used by ElasticSearch. \r\n\r\n## Date Math Definition\r\n\r\nyou can click [here](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-date-format.html#date-math)  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:\r\n| time unit symbol |  meaning |\r\n| --- | ---     |\r\n| y   | Years   |\r\n| M   | Months  |\r\n| w   | Weeks   |\r\n| d   | Days    |\r\n| h   | Hours   |\r\n| H   | Hours   |\r\n| m   | Minutes |\r\n| s   | Seconds |\r\n\r\nHere are some samples:\r\n`now+1h`, `now+1h+1m`, `now+1h/d`, `2012-01-01||+1M/d`.\r\n\r\nNote, when doing range type searches, and the upper value is inclusive, the rounding will properly be rounded to the ceiling instead of flooring it.\r\n\r\n## Usage\r\n\r\nReturns a `time.Time` struct object, which store utc time.\r\n```golang\r\npackage main\r\n\r\nimport (\r\n    \"fmt\"\r\n    \"github.com/zhuliquan/datemath_parser\"\r\n)\r\n\r\nfunc main() {\r\n    var parser = datemath_parser.NewDataMathParser()\r\n    if t, err := parser.Parse(\"now+7M/d\"); err != nil {\r\n        fmt.Println(err)\r\n    } else {\r\n        fmt.Println(t)\r\n    } \r\n}\r\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhuliquan%2Fdatemath_parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhuliquan%2Fdatemath_parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhuliquan%2Fdatemath_parser/lists"}