@happychef/algorithm 1.2.9 → 1.2.11
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/.github/workflows/ci-cd.yml +234 -0
- package/BRANCH_PROTECTION_SETUP.md +167 -0
- package/README.md +144 -0
- package/__tests__/filters.test.js +276 -0
- package/__tests__/isDateAvailable.test.js +175 -0
- package/__tests__/isTimeAvailable.test.js +168 -0
- package/__tests__/restaurantData.test.js +422 -0
- package/__tests__/tableHelpers.test.js +247 -0
- package/assignTables.js +149 -123
- package/changes/2025/December/PR4___.md +16 -0
- package/changes/2025/December/PR5___.md +16 -0
- package/changes/2025/December/PR6__del_.md +18 -0
- package/changes/2025/December/PR7_add__change.md +22 -0
- package/jest.config.js +23 -0
- package/package.json +10 -1
- package/tableHelpers.js +2 -2
- package/test-detailed-filter.js +100 -100
- package/test-lunch-debug.js +110 -110
- package/test-max-arrivals-filter.js +79 -79
- package/test-timezone-debug.js +47 -47
package/test-timezone-debug.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
// Test timezone handling
|
|
2
|
-
const moment = require('moment-timezone');
|
|
3
|
-
|
|
4
|
-
const testDate = "2025-12-08";
|
|
5
|
-
const testTime = "14:15";
|
|
6
|
-
|
|
7
|
-
console.log('=== TIMEZONE DEBUG ===\n');
|
|
8
|
-
|
|
9
|
-
// What the algorithm does
|
|
10
|
-
const now = new Date();
|
|
11
|
-
console.log('System now:', now);
|
|
12
|
-
console.log('System now ISO:', now.toISOString());
|
|
13
|
-
console.log('System now local string:', now.toString());
|
|
14
|
-
|
|
15
|
-
// Parse the time as the algorithm does (line 68-69 in getAvailableTimeblocks.js)
|
|
16
|
-
const [year, month, day] = testDate.split('-').map(Number);
|
|
17
|
-
const targetDateInTimeZone = new Date(year, month - 1, day);
|
|
18
|
-
console.log('\nTarget date:', targetDateInTimeZone);
|
|
19
|
-
console.log('Target date string:', targetDateInTimeZone.toString());
|
|
20
|
-
|
|
21
|
-
const isToday = now.toDateString() === targetDateInTimeZone.toDateString();
|
|
22
|
-
console.log('\nIs today?:', isToday);
|
|
23
|
-
|
|
24
|
-
// With uurOpVoorhand = 0
|
|
25
|
-
const uurOpVoorhand = 0;
|
|
26
|
-
const cutoffTime = new Date(now.getTime());
|
|
27
|
-
cutoffTime.setHours(cutoffTime.getHours() + uurOpVoorhand);
|
|
28
|
-
console.log('\nCutoff time (now + 0 hours):', cutoffTime);
|
|
29
|
-
console.log('Cutoff time string:', cutoffTime.toString());
|
|
30
|
-
|
|
31
|
-
// Parse the test time
|
|
32
|
-
const [hours, minutes] = testTime.split(':').map(Number);
|
|
33
|
-
const timeBlockDateTime = new Date(year, month - 1, day, hours, minutes);
|
|
34
|
-
console.log('\nTime block (14:15):', timeBlockDateTime);
|
|
35
|
-
console.log('Time block string:', timeBlockDateTime.toString());
|
|
36
|
-
|
|
37
|
-
console.log('\nComparison:');
|
|
38
|
-
console.log('timeBlockDateTime < cutoffTime:', timeBlockDateTime < cutoffTime);
|
|
39
|
-
console.log('Should be filtered out?:', timeBlockDateTime < cutoffTime ? 'YES' : 'NO');
|
|
40
|
-
|
|
41
|
-
// Check with Europe/Brussels timezone
|
|
42
|
-
console.log('\n=== Using moment-timezone ===');
|
|
43
|
-
const nowBrussels = moment.tz('Europe/Brussels');
|
|
44
|
-
console.log('Now in Brussels:', nowBrussels.format('YYYY-MM-DD HH:mm:ss Z'));
|
|
45
|
-
const targetTimeBrussels = moment.tz(`${testDate} ${testTime}`, 'YYYY-MM-DD HH:mm', 'Europe/Brussels');
|
|
46
|
-
console.log('Target time in Brussels:', targetTimeBrussels.format('YYYY-MM-DD HH:mm:ss Z'));
|
|
47
|
-
console.log('Is target time in past?:', targetTimeBrussels.isBefore(nowBrussels));
|
|
1
|
+
// Test timezone handling
|
|
2
|
+
const moment = require('moment-timezone');
|
|
3
|
+
|
|
4
|
+
const testDate = "2025-12-08";
|
|
5
|
+
const testTime = "14:15";
|
|
6
|
+
|
|
7
|
+
console.log('=== TIMEZONE DEBUG ===\n');
|
|
8
|
+
|
|
9
|
+
// What the algorithm does
|
|
10
|
+
const now = new Date();
|
|
11
|
+
console.log('System now:', now);
|
|
12
|
+
console.log('System now ISO:', now.toISOString());
|
|
13
|
+
console.log('System now local string:', now.toString());
|
|
14
|
+
|
|
15
|
+
// Parse the time as the algorithm does (line 68-69 in getAvailableTimeblocks.js)
|
|
16
|
+
const [year, month, day] = testDate.split('-').map(Number);
|
|
17
|
+
const targetDateInTimeZone = new Date(year, month - 1, day);
|
|
18
|
+
console.log('\nTarget date:', targetDateInTimeZone);
|
|
19
|
+
console.log('Target date string:', targetDateInTimeZone.toString());
|
|
20
|
+
|
|
21
|
+
const isToday = now.toDateString() === targetDateInTimeZone.toDateString();
|
|
22
|
+
console.log('\nIs today?:', isToday);
|
|
23
|
+
|
|
24
|
+
// With uurOpVoorhand = 0
|
|
25
|
+
const uurOpVoorhand = 0;
|
|
26
|
+
const cutoffTime = new Date(now.getTime());
|
|
27
|
+
cutoffTime.setHours(cutoffTime.getHours() + uurOpVoorhand);
|
|
28
|
+
console.log('\nCutoff time (now + 0 hours):', cutoffTime);
|
|
29
|
+
console.log('Cutoff time string:', cutoffTime.toString());
|
|
30
|
+
|
|
31
|
+
// Parse the test time
|
|
32
|
+
const [hours, minutes] = testTime.split(':').map(Number);
|
|
33
|
+
const timeBlockDateTime = new Date(year, month - 1, day, hours, minutes);
|
|
34
|
+
console.log('\nTime block (14:15):', timeBlockDateTime);
|
|
35
|
+
console.log('Time block string:', timeBlockDateTime.toString());
|
|
36
|
+
|
|
37
|
+
console.log('\nComparison:');
|
|
38
|
+
console.log('timeBlockDateTime < cutoffTime:', timeBlockDateTime < cutoffTime);
|
|
39
|
+
console.log('Should be filtered out?:', timeBlockDateTime < cutoffTime ? 'YES' : 'NO');
|
|
40
|
+
|
|
41
|
+
// Check with Europe/Brussels timezone
|
|
42
|
+
console.log('\n=== Using moment-timezone ===');
|
|
43
|
+
const nowBrussels = moment.tz('Europe/Brussels');
|
|
44
|
+
console.log('Now in Brussels:', nowBrussels.format('YYYY-MM-DD HH:mm:ss Z'));
|
|
45
|
+
const targetTimeBrussels = moment.tz(`${testDate} ${testTime}`, 'YYYY-MM-DD HH:mm', 'Europe/Brussels');
|
|
46
|
+
console.log('Target time in Brussels:', targetTimeBrussels.format('YYYY-MM-DD HH:mm:ss Z'));
|
|
47
|
+
console.log('Is target time in past?:', targetTimeBrussels.isBefore(nowBrussels));
|