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.
date-cruncher
Advanced tools
###date-cruncher
date-cruncher is a string-centric date calculator class.
###installation
npm i --save typescript-collections
npm i --save date-cruncher
###example usage
A live example is available on tonic
import {DateCruncher as dc} from 'date-cruncher';
//
// math expressions
//
// add one day to 10/7/2016 and round up to the nearest business day
// ( a business day is neither a weekend nor a U.S. federal holiday).
// per 5 USC 6103 http://uscode.house.gov/view.xhtml?edition=prelim&req=granuleid%3AUSC-prelim-title5-section6103&f=treesort&fq=true&num=0
let date: Date = dc.evaluate('10/07/2016 + 1 day round up');
// sets date to a date object 10/11/2016
// add one day to 10/7/2016 and round up to the nearest business day
// and print the steps taken along the way.
date = dc.evaluate('10/07/2016 + 1 day round up', (e) => { console.log(e); }); // <-- use this callback function to populate an explanation
// sets date to a date object 10/11/2016
// prints the following:
/*
10/7/2016 + 1 day is 10/8/2016
10/8/2016 is a Saturday
10/9/2016 is a Sunday
10/10/2016 is Columbus Day
the next business day is 10/11/2016
*/
date = dc.evaluate('10/07/2016 + 1 day round up', (e) => { console.log(e); });
// sets date to a date object 4/3/2017
// prints the following:
/*
10/7/2016 + 6 calendar months is 5/1/2017
5/1/2017 - 30 days is 4/1/2017
4/1/2017 is a Saturday
4/2/2017 is a Sunday
the next business day is 4/3/2017
*/
date = dc.evaluate('10/07/2016 + 3 business days');
// sets date to a date object 10/13/2016
//
// ordinal expressions
//
date = dc.evaluate('10/07/2016 third thursday');
// sets date to a date object 10/20/2016, the 3rd thursday in October 2016
date = dc.evaluate('10/07/2016 2nd fri');
// sets date to a date object 10/14/2016, the 2nd friday in October 2016
date = dc.evaluate('10/07/2016 first tue');
// sets date to a date object 10/4/2016, the 1st tuesday in October 2016
date = dc.evaluate('10/07/2016 last thursday');
// sets date to a date object 10/27/2016, the last thursday in October 2016
###fyi
####no locale support
this lib does not support locales. it only supports U.S. dates and holidays.
avoid saying:
import {DateCruncher as dc} from 'date-cruncher';
let d = new Date();
let expression = d.toLocaleDateString() + ' 3rd wednesday';
internet explorer 11 likes to throw in U+200E text-direction marks around the month day and year and date-cruncher doesn't accommodate this behavior.
instead, say:
import {DateCruncher as dc} from 'date-cruncher';
let d = new Date();
let expression = dc.resolveDateString(d) + ' 3rd wednesday';
FAQs
a string-centric date calculator.
The npm package date-cruncher receives a total of 3 weekly downloads. As such, date-cruncher popularity was classified as not popular.
We found that date-cruncher demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.