feat: add support for cyclical dates in special events to avoid yearly updates #45

Merged
tobiichi3227 merged 11 commits from feat/cyclical-special-event into main 2024-12-12 14:48:21 +00:00
6 changed files with 1081 additions and 210 deletions

View File

@@ -34,16 +34,57 @@
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
4. Maintain a positive and encouraging tone.
### Special Events
#### Date Structure
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
1. With year, month and date
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
```json
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
"triggerDate": {
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
"year": "Year",
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
"month": "Month",
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
"date": "Date"
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
}
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
```
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
We should place events of this type in the `fortune_generator/json/custom_special.json`.
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
For one-time or irregular events, or events with complex date calculations (like the Moon Festival in the lunar calendar).
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
**NOTE: Any special event that does not fit into either**
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
- Static events (fixed date every year)
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
- Cyclical events (recurring on a pattern like "fourth Thursday")
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
2. With only month and day
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
```json
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
"triggerDate": {
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
"month": "Month",
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
"date": "Date"
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
}
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
```
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
We should place events of this type in the `fortune_generator/json/static_special.json`.
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
For events with fixed dates.
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
3. With only month, week, weekday (like Mother's Day)
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
```json
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
"triggerDate": {
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
"month": "Month",
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
"week": "Week",
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
"weekday": "Weekday"
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
}
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
```
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
We should place events of this type in the `fortune_generator/json/cyclical_special.json`.
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
For recurring events (e.g., holidays like Thanksgiving and Mother's Day).
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
#### Event Structure
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
Special events require a more detailed structure.
1. Structure:
```json
{
"event": "Event Name",
"year": "Year",
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
"month": "Month",
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
"date": "Date",
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
"triggerDate": {}, // Please refer to explaination above
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
"status_index": "Status Index",
"goodFortunes": {
"l_1_event": "Good Fortune 1",
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.
lifeadventurer commented 2024-12-12 14:18:56 +00:00 (Migrated from github.com)
Review

The markdown headers didn't align with the filename.

The markdown headers didn't align with the filename.

View File

@@ -35,11 +35,17 @@ async function fetch_data() {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
badFortunes = data.badFortunes;
});
await fetch("./json/special.json")
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
.then((response) => response.json())
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
.then((data) => {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
special_events = data.special_events;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
});
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
async function fetch_events(path) {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
await fetch(path)
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
.then((response) => response.json())
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
.then((data) => {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
special_events.push(...data.special_events);
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
});
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
}
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
await fetch_events("./json/custom_special.json");
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
await fetch_events("./json/static_special.json");
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
await fetch_events("./json/cyclical_special.json");
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
}
const textColorClass = [
@@ -92,13 +98,91 @@ const day = d.getDay();
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
const month = d.getMonth() + 1;
const year = d.getFullYear();
function validateNumber(value, min, max, fieldName, event) {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
value = parseInt(value);
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
if (isNaN(value) || value < min || value > max) {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
return null;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
}
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
return value;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
}
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
function isLeapYear(year) {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
if (year % 400 === 0) return true;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
if (year % 100 === 0) return false;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
if (year % 4 === 0) return true;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
return false;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
}
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
const daysPerMonth = [
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
];
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
const maxDate = new Date(8640000000000000);
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
function daysDiff(eventIndex) {
// define the date right now and the special event date
const event = special_events[eventIndex];
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
const startDate = new Date(year, month - 1, date);
let eventYear = -1, eventMonth = -1, eventDate = -1;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
if (!('triggerDate' in event)) {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
console.warn('illegal event: missing `triggerDate` field', event);
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
return -1;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
} else if (Object.prototype.toString.call(event.triggerDate) !== "[object Object]") {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
console.warn('illegal event: `triggerDate` field should be a json object', event);
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
return -1;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
}
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
const triggerDate = event.triggerDate;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
eventYear = year;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
if ('year' in triggerDate) {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
eventYear = validateNumber(triggerDate.year, 1, maxDate.getFullYear(), 'triggerDate.year', event);
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
if (eventYear === null) {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
return -1;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
}
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
}
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
if (!('month' in triggerDate)) {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
console.warn('illegal event: `triggerDate` missing `month` field', event);
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
return -1;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
}
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
eventMonth = validateNumber(triggerDate.month, 1, 12, 'triggerDate.Month', event);
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
if (eventMonth === null) {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
return -1;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
}
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
if (!('date' in triggerDate) && (!('week' in triggerDate) || !('weekday' in triggerDate))) {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
console.warn('illegal event: `triggerDate` require (`week` and `weekday`) or `date` field', event);
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
return -1;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
}
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
if ('date' in triggerDate) {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
let days = daysPerMonth[eventMonth];
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
if (isLeapYear(eventYear) && eventMonth == 2) days += 1;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
eventDate = validateNumber(triggerDate.date, 1, days, 'triggerDate.date', event);
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
if (eventDate === null) {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
return -1;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
}
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
} else {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
triggerDate.week = validateNumber(triggerDate.week, 1, 5, 'triggerDate.week', event);
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
triggerDate.weekday = validateNumber(triggerDate.weekday, 1, 7, 'triggerDate.weekday', event);
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
if (triggerDate.week === null || triggerDate.weekday === null) {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
return -1;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
}
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
const firstDayOfMonth = new Date(eventYear, eventMonth - 1, 1);
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
const firstDayWeekday = firstDayOfMonth.getDay();
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
// Sunday -> 7
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
const adjustedFirstDayWeekday = firstDayWeekday === 0 ? 7 : firstDayWeekday;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
const firstTargetDay = 1 + (triggerDate.weekday - adjustedFirstDayWeekday + 7) % 7;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
eventDate = firstTargetDay + (triggerDate.week - 1) * 7;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
}
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
const endDate = new Date(
special_events[eventIndex].year,
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
special_events[eventIndex].month - 1,
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
special_events[eventIndex].date,
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
eventYear,
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
eventMonth - 1,
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
eventDate,
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
);
// calculate the difference in milliseconds and convert it to days
@@ -146,18 +230,23 @@ async function init_page() {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
$("#weekday").html(showDay);
const showSpecialEventCount = 2;
let eventIndexPtr = 0, eventIndexList = Array(showSpecialEventCount).fill(-1);
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
let eventIndexList = Array(showSpecialEventCount).fill(-1);
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
let eventDiffDaysIndexList = Array(showSpecialEventCount).fill(Number.MAX_SAFE_INTEGER);
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
// check if there is special event today
for (let i = 0; i < special_events.length; i++) {
if (daysDiff(i) > 0) {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
if (
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
eventIndexPtr < showSpecialEventCount &&
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
eventIndexList[eventIndexPtr] == -1
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
) {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
eventIndexList[eventIndexPtr] = i;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
eventIndexPtr++;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
let diffCount = daysDiff(i);
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
if (diffCount > 0) {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
let j = 0;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
for (; j < showSpecialEventCount; j++) {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
if (diffCount < eventDiffDaysIndexList[j]) {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
break;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
}
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
}
} else if (daysDiff(i) == 0) {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
eventDiffDaysIndexList[j] = diffCount;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
eventIndexList[j] = i;
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
} else if (diffCount === 0) {
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
special = true;
special_events_index = i;
}
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.
lifeadventurer commented 2024-12-03 15:46:27 +00:00 (Migrated from github.com)
Review
  1. Code Duplication: Repeated checks (e.g., isNaN, range validation) could be extracted into helper functions for cleaner code.
    function validateNumber(value, min, max, fieldName, event) {
        value = parseInt(value);
        if (isNaN(value) || value < min || value > max) {
            console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event);
            return null;
        }
        return value;
    }
    
  2. Readability: The nested else and validation blocks make the code harder to read. Refactor to flatten the structure where possible.
  3. Default Behavior: If both week/weekday and date are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning -1.
  4. Edge Cases: Ensure that edge cases like invalid months (eventMonth - 1 for zero-based indexing) or dates exceeding month limits (e.g., 31 in February) are handled properly.
1. **Code Duplication**: Repeated checks (e.g., `isNaN`, range validation) could be extracted into helper functions for cleaner code. ```js function validateNumber(value, min, max, fieldName, event) { value = parseInt(value); if (isNaN(value) || value < min || value > max) { console.warn(`illegal event: ${fieldName} should be between ${min} and ${max}`, event); return null; } return value; } ``` 2. **Readability**: The nested `else` and validation blocks make the code harder to read. Refactor to flatten the structure where possible. 3. **Default Behavior**: If both `week`/`weekday` and `date` are missing, consider whether a more graceful fallback (or an error throw) is appropriate rather than just logging and returning `-1`. 4. **Edge Cases**: Ensure that edge cases like invalid months (`eventMonth - 1` for zero-based indexing) or dates exceeding month limits (e.g., `31` in February) are handled properly.

View File

@@ -0,0 +1,3 @@
{
"special_events": []
}

View File

@@ -0,0 +1,726 @@
{
"special_events": [
{
"event": "元旦",
"triggerDate": {
"month": "1",
"date": "1"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "早起",
"l_1_desc": "心情愉悅迎接新年",
"l_2_event": "大掃除",
"l_2_desc": "新年新氣象"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "國際資料隱私日",
"triggerDate": {
"month": "1",
"date": "28"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "整理資料",
"l_1_desc": "注意在線資料安全",
"l_2_event": "注意隱私",
"l_2_desc": "謹慎上網"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "植樹節",
"triggerDate": {
"month": "3",
"date": "12"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "植樹造林",
"l_1_desc": "保護生態、美化環境",
"l_2_event": "節能減碳",
"l_2_desc": "延長資源壽命"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "白色情人節",
"triggerDate": {
"month": "3",
"date": "14"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "送禮物",
"l_1_desc": "表達愛意和感激之情",
"l_2_event": "觀星",
"l_2_desc": "仰望星空,共描明月"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "世界森林日",
"triggerDate": {
"month": "3",
"date": "21"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "環境教育",
"l_1_desc": "提升對自然的敬重",
"l_2_event": "節約用水",
"l_2_desc": "保護生態系統穩定"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "愚人節",
"triggerDate": {
"month": "4",
"date": "1"
},
"status_index": "3",
"goodFortunes": {
"l_1_event": "喜笑顏開",
"l_1_desc": "與親朋好友分享快樂",
"l_2_event": "開派對",
"l_2_desc": "組織有趣的活動和遊戲"
},
"badFortunes": {
"r_1_event": "冒犯他人",
"r_1_desc": "避免製造觸怒人的笑話",
"r_2_event": "惡作劇",
"r_2_desc": "注意避免不必要的麻煩"
}
},
{
"event": "兒童節",
"triggerDate": {
"month": "4",
"date": "4"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "喜笑顏開",
"l_1_desc": "與親朋好友分享快樂",
"l_2_event": "開派對",
"l_2_desc": "組織有趣的活動和遊戲"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "世界健康日",
"triggerDate": {
"month": "4",
"date": "7"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "健康飲食",
"l_1_desc": "多攝取水果、蔬菜和全穀食品",
"l_2_event": "運動鍛煉",
"l_2_desc": "保持身體健康和活力"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "世界地球日",
"triggerDate": {
"month": "4",
"date": "22"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "環保行動",
"l_1_desc": "參與植樹造林或垃圾回收等環保行動",
"l_2_event": "節能減排",
"l_2_desc": "選擇環保型交通工具"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "世界閱讀日",
"triggerDate": {
"month": "4",
"date": "23"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "推廣閱讀",
"l_1_desc": "激發對知識的渴望",
"l_2_event": "書籍分享",
"l_2_desc": "與他人分享你的書單"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "世界智慧財產權日",
"triggerDate": {
"month": "4",
"date": "26"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "保護創意",
"l_1_desc": "尊重他人的創意和智慧財產權,共同維護創作人的權益",
"l_2_event": "",
"l_2_desc": ""
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "星際大戰日",
"triggerDate": {
"month": "5",
"date": "04"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "電影馬拉松",
"l_1_desc": "播放所有星際大戰電影",
"l_2_event": "感受原力",
"l_2_desc": "May the force be with you, always."
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "世界微笑日",
"triggerDate": {
"month": "5",
"date": "08"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "微笑",
"l_1_desc": "用微笑向世界問好",
"l_2_event": "放慢腳步",
"l_2_desc": "觀察四周的美好事物"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "母親節",
"triggerDate": {
"month": "5",
"week": "2",
"weekday": "7"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "家庭聚餐",
"l_1_desc": "表達對媽媽的感恩之心",
"l_2_event": "",
"l_2_desc": ""
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "世界環境日",
"triggerDate": {
"month": "6",
"date": "05"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "少用塑膠",
"l_1_desc": "選擇可重複使用的替代品",
"l_2_event": "",
"l_2_desc": ""
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "世界獻血者日",
"triggerDate": {
"month": "6",
"date": "14"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "捐血",
"l_1_desc": "捐出血液和血漿,分享生命要時常",
"l_2_event": "",
"l_2_desc": ""
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "巧克力日",
"triggerDate": {
"month": "7",
"date": "07"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "送巧克力",
"l_1_desc": "共享巧克力盛宴",
"l_2_event": "",
"l_2_desc": ""
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "宅宅日",
"triggerDate": {
"month": "7",
"date": "13"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "觀影",
"l_1_desc": "看心愛的電影或影集",
"l_2_event": "閱讀",
"l_2_desc": "享受片刻的寧靜"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "國際冷笑話日",
"triggerDate": {
"month": "7",
"date": "24"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "講冷笑話",
"l_1_desc": "一起嘻嘻哈哈",
"l_2_event": "",
"l_2_desc": ""
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "國際友誼日",
"triggerDate": {
"month": "7",
"date": "30"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "與朋友聯絡",
"l_1_desc": "回憶美好時光",
"l_2_event": "一起出遊",
"l_2_desc": "增進彼此的感情"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "國際左撇子日",
"triggerDate": {
"month": "8",
"date": "13"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "挑戰新事物",
"l_1_desc": "嘗試用左手完成任務",
"l_2_event": "",
"l_2_desc": ""
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "世界攝影日",
"triggerDate": {
"month": "8",
"date": "19"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "拍攝照片",
"l_1_desc": "捕捉生活中的美好瞬間",
"l_2_event": "分享作品",
"l_2_desc": "展示您的攝影技巧"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "國際狗狗日",
"triggerDate": {
"month": "8",
"date": "26"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "陪伴狗狗",
"l_1_desc": "帶狗狗散步或遊玩",
"l_2_event": "分享作品",
"l_2_desc": "展示您的攝影技巧"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "國際慈善日",
"triggerDate": {
"month": "9",
"date": "5"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "捐贈物資",
"l_1_desc": "捐贈物資或金錢,幫助有需要的人",
"l_2_event": "參與志願活動",
"l_2_desc": "參加社區慈善活動,提升社會貢獻"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "國際和平日",
"triggerDate": {
"month": "9",
"date": "21"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "分享愛心",
"l_1_desc": "與他人分享關懷與愛心,促進和平",
"l_2_event": "",
"l_2_desc": ""
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "教師節",
"triggerDate": {
"month": "9",
"date": "28"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "感謝老師",
"l_1_desc": "向老師表達感謝,增進師生情誼",
"l_2_event": "",
"l_2_desc": ""
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "世界糧食日",
"triggerDate": {
"month": "10",
"date": "16"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "節約糧食",
"l_1_desc": "支持可持續的食物系統",
"l_2_event": "捐贈食品",
"l_2_desc": "捐贈食物給有需要的人,傳遞愛心"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "聯合國日",
"triggerDate": {
"month": "10",
"date": "24"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "支持和平",
"l_1_desc": "參與促進世界和平的活動",
"l_2_event": "了解國際事務",
"l_2_desc": "增強全球視野"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "萬聖節",
"triggerDate": {
"month": "10",
"date": "31"
},
"status_index": "4",
"goodFortunes": {
"l_1_event": "扮演角色",
"l_1_desc": "穿上喜愛的角色服裝,享受萬聖節的氛圍",
"l_2_event": "",
"l_2_desc": ""
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "忽略安全",
"r_2_desc": "活動時忽視安全措施可能帶來風險"
}
},
{
"event": "世界善心日",
"triggerDate": {
"month": "11",
"date": "13"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "善待他人",
"l_1_desc": "在生活中多一些善意與寬容",
"l_2_event": "",
"l_2_desc": ""
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "感恩節",
"triggerDate": {
"month": "11",
"week": "4",
"weekday": "4"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "家人團聚",
"l_1_desc": "分享寶貴時光",
"l_2_event": "吃火雞大餐",
"l_2_desc": "Happy Thanksgiving!"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "棉花糖日",
"triggerDate": {
"month": "12",
"date": "07"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "吃棉花糖",
"l_1_desc": "慶祝棉花糖日",
"l_2_event": "",
"l_2_desc": ""
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "貓奴日",
"triggerDate": {
"month": "12",
"date": "15"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "嚕貓",
"l_1_desc": "撫平傷心的心情",
"l_2_event": "喝咖啡",
"l_2_desc": "到貓咪咖啡店去喝咖啡"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "冬至",
"triggerDate": {
"month": "12",
"date": "22"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "吃湯圓",
"l_1_desc": "團團圓圓",
"l_2_event": "保暖",
"l_2_desc": "冬至到了"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "平安夜",
"triggerDate": {
"month": "12",
"date": "24"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "除舊佈新",
"l_1_desc": "平安祥和",
"l_2_event": "交換禮物",
"l_2_desc": "獲得真心的祝福"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "聖誕節",
"triggerDate": {
"month": "12",
"date": "25"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "家庭聚會",
"l_1_desc": "一起團圓吃火雞大餐",
"l_2_event": "注意保暖",
"l_2_desc": "冬至到了"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
}
]
}

View File

@@ -2,9 +2,11 @@
"special_events": [
{
"event": "感恩節",
"year": "2023",
"month": "11",
"date": "23",
"triggerDate": {
"month": "11",
"week": "4",
"weekday": "4"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "家人團聚",
lifeadventurer commented 2024-12-03 15:39:27 +00:00 (Migrated from github.com)
Review

感恩節 is celebrated on the fourth Thursday of November.

感恩節 is celebrated on the fourth Thursday of November.
@@ -21,9 +23,10 @@
},
{
"event": "棉花糖日",
"year": "2023",
"month": "12",
"date": "07",
"triggerDate": {
"month": "12",
"date": "07"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "吃棉花糖",
@@ -40,9 +43,10 @@
},
{
"event": "貓奴日",
"year": "2023",
"month": "12",
"date": "15",
"triggerDate": {
"month": "12",
"date": "15"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "嚕貓",
@@ -59,9 +63,10 @@
},
{
"event": "冬至",
"year": "2023",
"month": "12",
"date": "22",
"triggerDate": {
"month": "12",
"date": "22"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "吃湯圓",
@@ -78,9 +83,10 @@
},
{
"event": "平安夜",
"year": "2023",
"month": "12",
"date": "24",
"triggerDate": {
"month": "12",
"date": "24"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "除舊佈新",
@@ -97,9 +103,10 @@
},
{
"event": "聖誕節",
"year": "2023",
"month": "12",
"date": "25",
"triggerDate": {
"month": "12",
"date": "25"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "家庭聚會",
@@ -116,9 +123,10 @@
},
{
"event": "元旦",
"year": "2024",
"month": "1",
"date": "1",
"triggerDate": {
"month": "1",
"date": "1"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "早起",
@@ -133,68 +141,12 @@
"r_2_desc": ""
}
lifeadventurer commented 2024-12-03 15:30:01 +00:00 (Migrated from github.com)
Review

Please remove the following three events.

Please remove the following three events.
},
{
"event": "學測 Day 1",
"year": "2024",
"month": "1",
"date": "20",
"status_index": "0",
"goodFortunes": {
"l_1_event": "考試",
"l_1_desc": "如願以償,金榜題名",
"l_2_event": "祈禱",
"l_2_desc": "獲得平安、信心"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "學測 Day 2",
"year": "2024",
"month": "1",
"date": "21",
"status_index": "0",
"goodFortunes": {
"l_1_event": "參加測驗",
"l_1_desc": "天道酬勤",
"l_2_event": "安心",
"l_2_desc": "事事順利、心想事成"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "學測 Day 3",
"year": "2024",
"month": "1",
"date": "22",
"status_index": "0",
"goodFortunes": {
"l_1_event": "決戰巔峰",
"l_1_desc": "縱橫考場斬關將",
"l_2_event": "成功",
"l_2_desc": "勢在必得"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "國際資料隱私日",
"year": "2024",
"month": "1",
"date": "28",
"triggerDate": {
"month": "1",
"date": "28"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "整理資料",
@@ -211,9 +163,10 @@
},
{
"event": "植樹節",
"year": "2024",
"month": "3",
"date": "12",
"triggerDate": {
"month": "3",
"date": "12"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "植樹造林",
@@ -230,9 +183,10 @@
},
{
"event": "白色情人節",
"year": "2024",
"month": "3",
"date": "14",
"triggerDate": {
"month": "3",
"date": "14"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "送禮物",
@@ -249,9 +203,10 @@
},
{
"event": "世界森林日",
"year": "2024",
"month": "3",
"date": "21",
"triggerDate": {
"month": "3",
"date": "21"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "環境教育",
@@ -268,9 +223,10 @@
},
{
"event": "愚人節",
"year": "2024",
"month": "4",
"date": "1",
"triggerDate": {
"month": "4",
"date": "1"
},
"status_index": "3",
"goodFortunes": {
"l_1_event": "喜笑顏開",
@@ -287,9 +243,10 @@
},
{
"event": "兒童節",
"year": "2024",
"month": "4",
"date": "4",
"triggerDate": {
"month": "4",
"date": "4"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "喜笑顏開",
@@ -306,9 +263,10 @@
},
{
"event": "世界健康日",
"year": "2024",
"month": "4",
"date": "7",
"triggerDate": {
"month": "4",
"date": "7"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "健康飲食",
@@ -325,9 +283,10 @@
},
{
"event": "世界地球日",
"year": "2024",
"month": "4",
"date": "22",
"triggerDate": {
"month": "4",
"date": "22"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "環保行動",
@@ -344,9 +303,10 @@
},
{
"event": "世界閱讀日",
"year": "2024",
"month": "4",
"date": "23",
"triggerDate": {
"month": "4",
"date": "23"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "推廣閱讀",
@@ -363,9 +323,10 @@
},
{
"event": "世界智慧財產權日",
"year": "2024",
"month": "4",
"date": "26",
"triggerDate": {
"month": "4",
"date": "26"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "保護創意",
@@ -382,9 +343,10 @@
},
{
"event": "星際大戰日",
"year": "2024",
"month": "5",
"date": "04",
"triggerDate": {
"month": "5",
"date": "04"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "電影馬拉松",
@@ -401,9 +363,10 @@
},
{
"event": "世界微笑日",
"year": "2024",
"month": "5",
"date": "08",
"triggerDate": {
"month": "5",
"date": "08"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "微笑",
@@ -420,9 +383,11 @@
},
{
"event": "母親節",
"year": "2024",
"month": "5",
"date": "12",
"triggerDate": {
"month": "5",
"week": "2",
"weekday": "7"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "家庭聚餐",
@@ -439,9 +404,10 @@
},
{
"event": "世界環境日",
"year": "2024",
"month": "6",
"date": "05",
"triggerDate": {
"month": "6",
"date": "05"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "少用塑膠",
@@ -458,9 +424,10 @@
},
{
"event": "世界獻血者日",
"year": "2024",
"month": "6",
"date": "14",
"triggerDate": {
"month": "6",
"date": "14"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "捐血",
@@ -477,9 +444,11 @@
},
{
"event": "夏至",
"year": "2024",
"month": "6",
"date": "20",
"triggerDate": {
"year": "2024",
"month": "6",
"date": "20"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "觀賞日出和日落",
@@ -496,9 +465,10 @@
},
{
"event": "巧克力日",
"year": "2024",
"month": "7",
"date": "07",
"triggerDate": {
"month": "7",
"date": "07"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "送巧克力",
@@ -515,9 +485,10 @@
},
{
"event": "宅宅日",
"year": "2024",
"month": "7",
"date": "13",
"triggerDate": {
"month": "7",
"date": "13"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "觀影",
@@ -534,9 +505,10 @@
},
{
"event": "國際冷笑話日",
"year": "2024",
"month": "7",
"date": "24",
"triggerDate": {
"month": "7",
"date": "24"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "講冷笑話",
@@ -553,9 +525,10 @@
},
{
"event": "國際友誼日",
"year": "2024",
"month": "7",
"date": "30",
"triggerDate": {
"month": "7",
"date": "30"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "與朋友聯絡",
@@ -572,9 +545,10 @@
},
{
"event": "國際左撇子日",
"year": "2024",
"month": "8",
"date": "13",
"triggerDate": {
"month": "8",
"date": "13"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "挑戰新事物",
@@ -591,9 +565,10 @@
},
{
"event": "世界攝影日",
"year": "2024",
"month": "8",
"date": "19",
"triggerDate": {
"month": "8",
"date": "19"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "拍攝照片",
@@ -610,9 +585,10 @@
},
{
"event": "國際狗狗日",
"year": "2024",
"month": "8",
"date": "26",
"triggerDate": {
"month": "8",
"date": "26"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "陪伴狗狗",
@@ -629,9 +605,10 @@
},
{
"event": "國際慈善日",
"year": "2024",
"month": "9",
"date": "5",
"triggerDate": {
"month": "9",
"date": "5"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "捐贈物資",
@@ -648,9 +625,11 @@
},
{
"event": "中秋節",
"year": "2024",
"month": "9",
"date": "17",
"triggerDate": {
"year": "2024",
"month": "9",
"date": "17"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "賞月",
@@ -667,9 +646,10 @@
},
{
"event": "國際和平日",
"year": "2024",
"month": "9",
"date": "21",
"triggerDate": {
"month": "9",
"date": "21"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "分享愛心",
@@ -686,9 +666,10 @@
},
{
"event": "教師節",
"year": "2024",
"month": "9",
"date": "28",
"triggerDate": {
"month": "9",
"date": "28"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "感謝老師",
@@ -705,9 +686,10 @@
},
{
"event": "世界糧食日",
"year": "2024",
"month": "10",
"date": "16",
"triggerDate": {
"month": "10",
"date": "16"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "節約糧食",
@@ -724,9 +706,10 @@
},
{
"event": "聯合國日",
"year": "2024",
"month": "10",
"date": "24",
"triggerDate": {
"month": "10",
"date": "24"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "支持和平",
@@ -743,9 +726,10 @@
},
{
"event": "萬聖節",
"year": "2024",
"month": "10",
"date": "31",
"triggerDate": {
"month": "10",
"date": "31"
},
"status_index": "4",
"goodFortunes": {
"l_1_event": "扮演角色",
@@ -762,9 +746,10 @@
},
{
"event": "世界善心日",
"year": "2024",
"month": "11",
"date": "13",
"triggerDate": {
"month": "11",
"date": "13"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "善待他人",
@@ -778,25 +763,6 @@
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "感恩節",
"year": "2024",
"month": "11",
"date": "28",
"status_index": "0",
"goodFortunes": {
"l_1_event": "家人團聚",
"l_1_desc": "共享寶貴時光",
"l_2_event": "",
"l_2_desc": ""
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
}
]
}

View File

@@ -0,0 +1,46 @@
{
"special_events": [
{
"event": "夏至",
"triggerDate": {
"year": "2025",
"month": "6",
"date": "21"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "觀賞日出和日落",
"l_1_desc": "享受一年最長的白天",
"l_2_event": "",
"l_2_desc": ""
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
},
{
"event": "中秋節",
"triggerDate": {
"year": "2025",
"month": "10",
"date": "6"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "賞月",
"l_1_desc": "與家人一同賞月,增進感情",
"l_2_event": "吃月餅",
"l_2_desc": "與家人朋友分享月餅的美味"
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
}
]
}