@autobusal/common 1.27.2 → 1.27.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.27.3
4
+
5
+ ### Fixed
6
+
7
+ - **The birth-date picker offered today, which the API refuses.** obtapi
8
+ validates with `before:today`, so the calendar was letting you choose an
9
+ answer and then calling it wrong. It now stops at yesterday.
10
+
11
+ The year steps back too when yesterday fell in the previous one: the
12
+ maximum is built from `today.getFullYear() + limits.max.year`, so on 1
13
+ January a month/day of 31 December would otherwise have resolved to the
14
+ coming 31 December rather than the one just gone. Checked against 1
15
+ January, 1 March and a leap year.
16
+
3
17
  ## 1.27.2
4
18
 
5
19
  ### Fixed
@@ -82,8 +82,23 @@ export const getLimits = (type: ('picker' | 'dob' | 'date')): CalendarLimit => {
82
82
  if (type === 'dob') {
83
83
  limits.min.year = 100;
84
84
 
85
- limits.max.month = today.getMonth();
86
- limits.max.day = today.getDate();
85
+ // Edited: Ferjolt Ozuni - Date: 2026-08-06
86
+ // Up to YESTERDAY, not today. obtapi validates a birth date with
87
+ // `before:today`, and somebody filling in this form was not born this
88
+ // morning - offering a day the API will refuse is a calendar that lets
89
+ // you choose an answer and then calls it wrong.
90
+ //
91
+ // The year is stepped back too when yesterday fell in the previous one,
92
+ // because max.time below is built from `today.getFullYear() +
93
+ // limits.max.year`: on 1 January, month 11 / day 31 without this would
94
+ // resolve to the coming 31 December rather than the one just gone.
95
+ const yesterday = new Date(today.getTime());
96
+
97
+ yesterday.setDate(yesterday.getDate() - 1);
98
+
99
+ limits.max.year = yesterday.getFullYear() - today.getFullYear();
100
+ limits.max.month = yesterday.getMonth();
101
+ limits.max.day = yesterday.getDate();
87
102
  }
88
103
 
89
104
  if (type === 'picker') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/common",
3
- "version": "1.27.2",
3
+ "version": "1.27.3",
4
4
  "author": "Ferjolt Ozuni",
5
5
  "type": "module",
6
6
  "main": "index.ts"