Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
dates-range-parser
Advanced tools
The Date Range Parser is a library that allows parsing and interpreting human-readable date and time expressions and converting them into machine-readable date ranges.
The Date Range Parser can be installed via package managers like npm:
npm install date-range-parser
The Date Range Parser also contains a number parser that follows the same constructs.
DatesRangeParser.UTC = true; // calculate all dates input and outputs in UTC;
DatesRangeParser.parse("yesterday"); // returns {start: Date, end: Date} for the previous day
DatesRangeParser.parse("now -> 7days"); // returns {start: Date, end: Date} for the next 7 days (week) from today
DatesRangeParser.parse()
either returns null, if the string cannot be converted, or an object with start and end attributes.
start and end are either null (meaning no constraint) or the number of seconds since epoch.
Often these values can be passed directly to the db/search service.
DateRangeParser has a property .UTC which is by default false, and all calculations are happening in local timezone. If set to true DatesRangeParser.js wil work entirely in UTC / GMT / Z (+0) timezone. Usually databases will store dates like this.
The date range parser can generate several types of queries relative to now, which is defined as the current time on the user's computer (to the millisecond). This can be overridden by setting DatesRangeParser.now to a new value.
now
today
tomorrow
yesterday
last/this/next week
last/this/next month
last/this/next year
1000secs
5mins
1day
2days
8d
9months
2yrs
5
5:35
5:35:12
2011
2011-03
2011-03-04
2011-03-04 04
2011-03-04 04:15
2011-03-04 04:15:29
2010 -> 2011
2005-11-05 16:13:49 -> 2005-11-06 05:12:11
last week -> next week
2011-05 ->
< now
2000-01-01 -> last week
2000 -> 10y
3mins < now
last year -> 6months
2010-05-13 05:13 <> 10m
now <> 1yr
lastweek <> 1month
Creates a range covering all value dates relative to now.
Entering a range alone creates a date search centered on now and spreading into the past and future by the specified amount. Examples: Given now is 2001-09-09 01:46:40
The following aliases can be used with ranges:
Note: Months are always calculated as 31 days, and years are always calculated as 365 days.
A date format alone will search the range of dates covered by the date.
Dates must be specified in the YYYY-MM-DD format.
Entering a time creates a range in today. Examples:
Times must be entered in the H-MM-SS format, and AM/PM cannot be used.
Entering a date and time part creates a range on the specified interval. Examples:
Entering two dates separated by "->" creates a range between the two dates.
Ranges can be combined to create more complex queries.
Entering a date or range followed by "<>" and a range creates an offset search.
The Date Range Parser is licensed under the MIT License.
FAQs
A simple parser for dates range
The npm package dates-range-parser receives a total of 2,043 weekly downloads. As such, dates-range-parser popularity was classified as popular.
We found that dates-range-parser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.