Socket
Socket
Sign inDemoInstall

datemath-parser

Package Overview
Dependencies
1
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    datemath-parser

A date math parser compatible with elastic search format


Version published
Weekly downloads
20K
increased by5.25%
Maintainers
1
Install size
4.04 MB
Created
Weekly downloads
 

Readme

Source

datemath-parser

A date math parser compatible with elastic search format

Build Status Coverage Status Dependency Status

Date Math Definition

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-date-format.html#date-math

The date type supports using date math expression when using it in a query/filter (mainly makes sense in range query/filter).

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 / (rounding).

The units supported are y (year), M (month), w (week), d (day), h (hour), m (minute), and s (second).

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 an integer representing timestamp in milliseconds

var parser = require('datemath-parser');
parser.parse(dateMathExpression, [now], [roundUp], [timeZone]);

Test

npm test

FAQs

Last updated on 05 Jun 2018

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