
Product
Introducing Pull Request Stories to Help Security Teams Track Supply Chain Risks
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
@devtanc/daterange
Advanced tools
A library for generating past date ranges as a simple wrapper around date-fns
npm i -S @devtanc/daterange
// or
yarn add @devtanc/daterange
This function is for generating ranges in the past that conform to calendar units like days, weeks, months, quarters, or years. This library does not currently handle ranges in the future. The return object is in the form of:
{
start: Date,
end: Date
}
import {
getCalendarRange,
getCustomRangeEnding,
getCustomRangeStarting,
} from '@devtanc/daterange'
// Arguments are (unit, shift, date). Only the unit is required (plural or singular are treated the same)
// A positive shift means going BACK in time (like 6 days ago), negative goes forward
// If no date or shift is provided, it is assumed that you want the current "unit" up until the current date/time
// e.g. getCalendarRange('day', 0) Would give you this week up until the current time, as opposed to until the end of the week
getCalendarRange('day')
// {
// start: beginning of today,
// end: now
// }
getCalendarRange('day', 2)
// {
// start: beginning of the day, two days ago,
// end: end of the day, two days ago
// }
getCalendarRange('month', 0, new Date(2017, 2, 12))
// {
// start: beginning of the month of March, 2017,
// end: end of the month of March, 2017
// }
getCalendarRange('month', 1, new Date(2017, 2, 12))
// The difference in the month here is due to the provided shift value
// {
// start: beginning of the month of February, 2017,
// end: end of the month of February, 2017
// }
getCalendarRangeStarting(new Date(2018, 0, 1), 5, 'days')
// A range starting on the given date and extending past it x number of units
// {
// start: new Date(2018, 0, 1),
// end: new Date(2018, 0, 6),
// }
getCustomRangeEnding(new Date(2018, 0, 1), 5, 'days')
// A range starting on the given date and extending past it x number of units
// {
// start: new Date(2017, 11, 27),
// end: new Date(2018, 0, 1),
// }
FAQs
A date range generating library
We found that @devtanc/daterange 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.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.