@happychef/algorithm 1.2.15 → 1.2.17
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.
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# PR 12 - Bridge implementation
|
|
2
|
+
|
|
3
|
+
**Actions:**
|
|
4
|
+
|
|
5
|
+
## Changes Summary
|
|
6
|
+
ADDED:
|
|
7
|
+
- New function `bridge` added to `src/algorithm.rs` which takes a vector of `u32` and returns a `u32`.
|
|
8
|
+
- New import `use std::collections::VecDeque;` added to `src/algorithm.rs`.
|
|
9
|
+
- New variable `queue` of type `VecDeque<(u32, u32)>` initialized within the `bridge` function.
|
|
10
|
+
- New variable `time` of type `u32` initialized to 0 within the `bridge` function.
|
|
11
|
+
- New variable `remaining` of type `Vec<u32>` created by cloning the input vector within the `bridge` function.
|
|
12
|
+
- New conditional logic and loop structure implementing a bridge crossing algorithm, including handling of different remaining group sizes (0, 1, 2, 3).
|
|
13
|
+
|
|
14
|
+
NO_REMOVALS
|
|
15
|
+
|
|
16
|
+
NO_CHANGES
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
**Author:** Fakhar-Rashid
|
|
21
|
+
**Date:** 2026-01-23
|
|
22
|
+
**PR Link:** https://github.com/thibaultvandesompele2/15-happy-algorithm/pull/12
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# PR 13 - Fix timezone issues in date parsing for day-of-week calculations
|
|
2
|
+
|
|
3
|
+
**Actions:**
|
|
4
|
+
|
|
5
|
+
## Changes Summary
|
|
6
|
+
ADDED:
|
|
7
|
+
- New function `parseDateString(dateStr)` added to `openinghours.js` for parsing YYYY-MM-DD date strings using local timezone components.
|
|
8
|
+
- New export of `parseDateString` from `openinghours.js` for use in other modules.
|
|
9
|
+
|
|
10
|
+
NO_REMOVALS
|
|
11
|
+
|
|
12
|
+
CHANGED:
|
|
13
|
+
- Modified `isDateInRange()` function in `exceptions.js` to replace `new Date(dateStr)` with `parseDateString(dateStr)` for date parsing.
|
|
14
|
+
- Modified `getDataByDateAndMealWithExceptions()` function in `exceptions.js` to replace `new Date(dateStr)` with `parseDateString(dateStr)` for date parsing.
|
|
15
|
+
- Modified `getDataByDateAndMeal()` function in `openinghours.js` to replace `new Date(dateStr)` with `parseDateString(dateStr)` for date parsing.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
**Author:** thibaultvandesompele2
|
|
20
|
+
**Date:** 2026-01-26
|
|
21
|
+
**PR Link:** https://github.com/thibaultvandesompele2/15-happy-algorithm/pull/13
|
package/isTimeAvailable.js
CHANGED
|
@@ -10,11 +10,12 @@ const { timeblocksAvailable } = require('./processing/timeblocksAvailable');
|
|
|
10
10
|
* @param {Array} blockedSlots - Optional array of blocked time slots to exclude.
|
|
11
11
|
* @param {string|null} giftcard - Optional giftcard to filter times by meal.
|
|
12
12
|
* @param {boolean} isAdmin - Optional flag to bypass time restrictions for admin users.
|
|
13
|
+
* @param {number|null} duration - Optional duration in minutes (for bowling restaurants). Falls back to settings if not provided.
|
|
13
14
|
* @returns {boolean} - Returns true if the time is available, false otherwise.
|
|
14
15
|
*/
|
|
15
|
-
function isTimeAvailable(data, dateStr, timeStr, reservations, guests, blockedSlots = [], giftcard = null, isAdmin = false) {
|
|
16
|
+
function isTimeAvailable(data, dateStr, timeStr, reservations, guests, blockedSlots = [], giftcard = null, isAdmin = false, duration = null) {
|
|
16
17
|
// Get all available timeblocks for the specified date and guest count
|
|
17
|
-
const availableTimeblocks = timeblocksAvailable(data, dateStr, reservations, guests, blockedSlots, giftcard, isAdmin);
|
|
18
|
+
const availableTimeblocks = timeblocksAvailable(data, dateStr, reservations, guests, blockedSlots, giftcard, isAdmin, duration);
|
|
18
19
|
|
|
19
20
|
// Check if the specific timeStr is one of the available keys
|
|
20
21
|
return Object.prototype.hasOwnProperty.call(availableTimeblocks, timeStr);
|
package/package.json
CHANGED
|
@@ -5,15 +5,16 @@ const {
|
|
|
5
5
|
getDataByDateAndTime,
|
|
6
6
|
getMealTypeByTime,
|
|
7
7
|
parseTime,
|
|
8
|
+
parseDateString,
|
|
8
9
|
shifts,
|
|
9
10
|
daysOfWeekEnglish,
|
|
10
11
|
daysOfWeekDutch,
|
|
11
12
|
} = require('./openinghours');
|
|
12
13
|
|
|
13
14
|
function isDateInRange(dateStr, startDateStr, endDateStr) {
|
|
14
|
-
const date =
|
|
15
|
-
const startDate =
|
|
16
|
-
const endDate =
|
|
15
|
+
const date = parseDateString(dateStr);
|
|
16
|
+
const startDate = parseDateString(startDateStr);
|
|
17
|
+
const endDate = parseDateString(endDateStr);
|
|
17
18
|
if (isNaN(date) || isNaN(startDate) || isNaN(endDate)) {
|
|
18
19
|
return false;
|
|
19
20
|
}
|
|
@@ -86,7 +87,7 @@ function mapExceptionToMealData(exception, data) {
|
|
|
86
87
|
|
|
87
88
|
function getDataByDateAndMealWithExceptions(data, dateStr, mealType) {
|
|
88
89
|
const exceptions = data.exceptions || [];
|
|
89
|
-
const date =
|
|
90
|
+
const date = parseDateString(dateStr);
|
|
90
91
|
if (isNaN(date)) {
|
|
91
92
|
return null;
|
|
92
93
|
}
|
|
@@ -14,6 +14,21 @@ function parseTime(timeStr) {
|
|
|
14
14
|
return hours * 60 + minutes;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Parse a YYYY-MM-DD date string consistently across browsers.
|
|
19
|
+
* Using new Date(dateStr) directly causes browser differences:
|
|
20
|
+
* - Chrome parses "YYYY-MM-DD" as local midnight
|
|
21
|
+
* - Firefox parses "YYYY-MM-DD" as UTC midnight
|
|
22
|
+
* This function ensures consistent local time parsing.
|
|
23
|
+
*/
|
|
24
|
+
function parseDateString(dateStr) {
|
|
25
|
+
if (!dateStr || typeof dateStr !== 'string') {
|
|
26
|
+
return new Date(NaN);
|
|
27
|
+
}
|
|
28
|
+
const [year, month, day] = dateStr.split('-').map(Number);
|
|
29
|
+
return new Date(year, month - 1, day);
|
|
30
|
+
}
|
|
31
|
+
|
|
17
32
|
function getMealTypeByTime(timeStr) {
|
|
18
33
|
const time = parseTime(timeStr);
|
|
19
34
|
for (const [mealType, shift] of Object.entries(shifts)) {
|
|
@@ -73,7 +88,7 @@ function addDuurReservatieToEndTime(mealData, data) {
|
|
|
73
88
|
}
|
|
74
89
|
|
|
75
90
|
function getDataByDateAndMeal(data, dateStr, mealType) {
|
|
76
|
-
const date =
|
|
91
|
+
const date = parseDateString(dateStr);
|
|
77
92
|
if (isNaN(date)) {
|
|
78
93
|
return null;
|
|
79
94
|
}
|
|
@@ -119,5 +134,6 @@ module.exports = {
|
|
|
119
134
|
daysOfWeekDutch,
|
|
120
135
|
getMealTypeByTime,
|
|
121
136
|
parseTime,
|
|
137
|
+
parseDateString,
|
|
122
138
|
shifts,
|
|
123
139
|
};
|