@casomoltd/nhs-pay 0.16.0 → 0.16.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dates.d.ts CHANGED
@@ -23,10 +23,11 @@
23
23
  * months plus remaining days, on the anniversary convention: a
24
24
  * month completes on the day-clamped monthly anniversary of
25
25
  * `from` (so 31 Jan → 28 Feb is one complete month). Requires
26
- * `from <= to`; the postcondition invariant guards the contract
27
- * a calendar period must satisfy — a naive month-diff-and-borrow
28
- * here once produced negative days for month-end dates, which
29
- * silently defeated the ERF round-up downstream.
26
+ * two valid Dates and `from <= to`; the postcondition invariant
27
+ * guards the contract a calendar period must satisfy — a naive
28
+ * month-diff-and-borrow here once produced negative days for
29
+ * month-end dates, which silently defeated the ERF round-up
30
+ * downstream.
30
31
  */
31
32
  export declare function periodInYearsMonths(from: Date, to: Date): {
32
33
  years: number;
package/dist/dates.js CHANGED
@@ -32,12 +32,24 @@ function addMonthsClamped(date, n) {
32
32
  * months plus remaining days, on the anniversary convention: a
33
33
  * month completes on the day-clamped monthly anniversary of
34
34
  * `from` (so 31 Jan → 28 Feb is one complete month). Requires
35
- * `from <= to`; the postcondition invariant guards the contract
36
- * a calendar period must satisfy — a naive month-diff-and-borrow
37
- * here once produced negative days for month-end dates, which
38
- * silently defeated the ERF round-up downstream.
35
+ * two valid Dates and `from <= to`; the postcondition invariant
36
+ * guards the contract a calendar period must satisfy — a naive
37
+ * month-diff-and-borrow here once produced negative days for
38
+ * month-end dates, which silently defeated the ERF round-up
39
+ * downstream.
39
40
  */
40
41
  export function periodInYearsMonths(from, to) {
42
+ /* Checked before any arithmetic, and neither date is named by
43
+ VALUE. An invalid Date makes every figure below NaN, so the
44
+ closing invariant fires — and its message is built before
45
+ `invariant` judges the condition, interpolating
46
+ `toISOString()`, which throws RangeError on an invalid Date.
47
+ The input that most needs a diagnostic is the one that would
48
+ lose it. Guarding here is also what makes that interpolation
49
+ total: toISOString throws only on a NaN time value, and
50
+ nothing below can mint one. */
51
+ invariant(!Number.isNaN(from.getTime()), 'periodInYearsMonths: invalid from');
52
+ invariant(!Number.isNaN(to.getTime()), 'periodInYearsMonths: invalid to');
41
53
  let totalMonths = (to.getFullYear() - from.getFullYear()) * 12
42
54
  + (to.getMonth() - from.getMonth());
43
55
  if (addMonthsClamped(from, totalMonths) > to) {
package/dist/dates.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"dates.js","sourceRoot":"","sources":["../src/dates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,MAAM,UAAU,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACvC,MAAM,WAAW,GAAG,MAAM,GAAG,UAAU,CAAC;AAExC;6CAC6C;AAC7C,SAAS,gBAAgB,CAAC,IAAU,EAAE,CAAS;IAC7C,MAAM,OAAO,GAAG,IAAI,IAAI,CACtB,IAAI,CAAC,WAAW,EAAE,EAClB,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC,EACvB,CAAC,CACF,CAAC,OAAO,EAAE,CAAC;IACZ,OAAO,IAAI,IAAI,CACb,IAAI,CAAC,WAAW,EAAE,EAClB,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,EACnB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAClC,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAU,EACV,EAAQ;IAER,IAAI,WAAW,GACb,CAAC,EAAE,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,EAAE;UAC1C,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IACtC,IAAI,gBAAgB,CAAC,IAAI,EAA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ACD,MAAM,WAAW,GAAG,gBAAgB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IACxD,8DAA8D;IAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CACrB,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,WAAW,CAAC,OAAO,EAAE,CAAC,GAAG,UAAU,CACpD,CAAC;IACF,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,EAAE,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAG,WAAW,GAAG,EAAE,CAAC;IAEhC,SAAS,CACP,KAAK,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,IAAI,MAAM,GAAG,EAAE;WACnC,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE,EAC5B,iDAAiD;UAC7C,GAAG,KAAK,MAAM,MAAM,MAAM,IAAI,QAAQ;UACtC,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC,WAAW,EAAE,EAAE,CAClD,CAAC;IACF,OAAO,EAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAC,CAAC;AAC/B,CAAC;AAED;;qBAEqB;AACrB,MAAM,UAAU,YAAY,CAAC,IAAU,EAAE,EAAQ;IAC/C,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,WAAW,CAAC;AACvD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,OAAO,CACrB,WAAiB,EACjB,GAAW;IAEX,OAAO,IAAI,IAAI,CACb,WAAW,CAAC,WAAW,EAAE,GAAG,GAAG,EAC/B,WAAW,CAAC,QAAQ,EAAE,EACtB,WAAW,CAAC,OAAO,EAAE,CACtB,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@casomoltd/nhs-pay",
3
- "version": "0.16.0",
3
+ "version": "0.16.2",
4
4
  "description": "NHS Agenda for Change pay scales, pension tiers, regions, and take-home calculator",
5
5
  "homepage": "https://github.com/casomoltd/nhs-pay#readme",
6
6
  "bugs": "https://github.com/casomoltd/nhs-pay/issues",