@almaiura/legal-deadline-calculator
v0.1.0
Published
Italian legal deadline calculator with civil procedural rules, holidays and ferial/covid suspensions.
Maintainers
Readme
@almaiura/legal-deadline-calculator
TypeScript calculator for Italian civil procedural deadlines.
Handles:
- day and week terms, with the dies a quo excluded;
- free day terms, with both the dies a quo and the dies ad quem excluded;
- month and year terms ex nominatione dierum;
- historical summer judicial suspension: until 2014
01/08–15/09, from 201501/08–31/08; - extraordinary Covid-19 civil suspension
09/03/2020–11/05/2020; - Italian national holidays and Easter Monday;
- optional local holidays;
- forward roll pursuant to art. 155 Italian Code of Civil Procedure;
- prudential backward calculation, moving back to the previous business day when the date falls on a Saturday, Sunday, or holiday.
Note: this package implements general rules and must be validated against the specific use case. The summer suspension does not apply to all proceedings.
Installation
npm install @almaiura/legal-deadline-calculatorBasic usage
import { calculateDeadline } from "@almaiura/legal-deadline-calculator";
const result = calculateDeadline({
startDate: "2026-07-20",
amount: 30,
unit: "days",
direction: "forward",
suspensions: true,
roll: "procedural",
});
console.log(result.dueDate);
console.log(result.adjustments);Examples
Saturday roll under art. 155 c.p.c.
calculateDeadline({
startDate: "2016-12-04",
amount: 20,
unit: "days",
direction: "forward",
}).dueDate;
// => "2016-12-27"Holiday Friday: Saturday allowed if not itself a holiday
calculateDeadline({
startDate: "2013-10-02",
amount: 30,
unit: "days",
direction: "forward",
}).dueDate;
// => "2013-11-02"Prudential backward deadline
calculateDeadline({
startDate: "2013-11-13",
amount: 10,
unit: "days",
direction: "backward",
}).dueDate;
// => "2013-10-31"Summer suspension before 2015
calculateDeadline({
startDate: "2013-07-12",
amount: 20,
unit: "days",
suspensions: true,
includeCovid2020: false,
}).dueDate;
// => "2013-09-16"Local holiday
calculateDeadline({
startDate: "2026-06-28",
amount: 1,
unit: "days",
extraHolidays: [{ date: "2026-06-29", name: "Saints Peter and Paul - Rome" }],
}).dueDate;API
type DeadlineUnit = "days" | "weeks" | "months" | "years";
type DeadlineDirection = "forward" | "backward";
type DeadlineRoll = "procedural" | "generic" | "none";
interface CalculateDeadlineInput {
startDate: string; // YYYY-MM-DD
amount: number;
unit?: DeadlineUnit;
direction?: DeadlineDirection;
freeTerm?: boolean;
suspensions?: boolean;
includeCovid2020?: boolean;
extraSuspensionIntervals?: { start: string; end: string; reason?: string }[];
extraHolidays?: { date: string; name: string }[];
roll?: DeadlineRoll;
}roll: "procedural" replicates the prudential behaviour best suited for civil procedural deadlines:
- forward: Sundays and national/local holidays roll to the next non-holiday day;
- forward: if the calculated date falls exactly on a Saturday, it rolls to the next non-holiday day;
- forward: if the calculated date falls on a holiday Friday, the following Saturday may be valid if it is not itself a holiday;
- backward: Saturdays, Sundays, and holidays move back to the previous business day.
Build and test
npm install
npm testnpm publishing
npm version patch
npm publish --access publicFor a private scoped package, use your organisation's npm configuration.
