Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
date-clashes
Advanced tools
A simple API for detecting overlapping dates
npm install date-clashes --save
var myDates = [
{ s: /* Date */, e: /* Date */ , id: 1 },
{ s: /* Date */, e: /* Date */ , id: 2 },
...
];
var DateClash = require("date-clashes");
// Supply the constructor with instructions on how to parse your date objects
// The function must return an object that matches the 'Range' interface below
var clash = new DateClash.Clash(date => { return { start: date.s, end: date.e, id: date.id } });
// Detect the clashes
var clashes = clash.flatten(myDates);
// Make the clash 'window'/'extremities' fall on particular days of the week
// 0 = Sunday, 6 = Saturday
var clashes = clash.flatten(myDates, { startDay: 1 /* Monday */, endDay: 0 /* Sunday */ });
// Returns an object of type Clashes that looks like:
{
start: Tue Sep 15 2015 00:00:00 GMT+0800 (W. Australia Standard Time),
end: Thu Sep 24 2015 00:00:00 GMT+0800 (W. Australia Standard Time),
'1': { date: Tue Sep 15 2015 00:00:00 GMT+0800 (W. Australia Standard Time),
clashes: [ ... ] },
...
'10': { date: Tue Sep 24 2015 00:00:00 GMT+0800 (W. Australia Standard Time),
clashes: [ ... ] },
}
interface Clashes {
start: Date; // The floored version of the earliest date in your array
end: Date; // The ceiling version of the latest date in your array
[dayNumber: number]: { date: Date, clashes: Range[] }
}
interface Range {
start: Date;
end: Date;
[key: string]: any;
}
constructor(rangeGetter?: RangeGetter);
A function that takes an object and returns an object that date-clashes
can understand (Range
)
The object must contain a start
and end
property which must be Date
objects.
Example:
function rangeGetter(myObject) {
return {
start: new Date(myObject.startDate),
end: new Date(myObject.endDate),
id: myObject.id,
firstName: myObject.firstName,
lastName: myObject.lastName
};
}
var clash = new DateClash.Clash(rangeGetter);
The function that does all of the work.
Takes an array of objects that your rangeGetter
function can parse.
function flatten(dates: Array<any>, options?: Options) => Clashes;
An optional object that has two optional properties:
startDay
and endDay
These options will determine the day number of outer-extremities of the returned Clashes
object.
{
startDay: number,
endDay: number
}
MIT
FAQs
A simple API for detecting overlapping dates
The npm package date-clashes receives a total of 2 weekly downloads. As such, date-clashes popularity was classified as not popular.
We found that date-clashes 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.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.