Skip to content

Conversation

@BrianHung
Copy link
Owner

Summary

  • add NETWORKDAYS and NETWORKDAYS.INTL implementations
  • document newly implemented functions
  • include tests for NETWORKDAYS functions

Testing

  • cargo test -p ironcalc_base --lib --quiet

https://chatgpt.com/codex/tasks/task_e_68658c30afb08327965806a8efd37bd1

@BrianHung BrianHung changed the title Implement NETWORKDAYS functions networkdays, networkdays.intl Jul 14, 2025
@BrianHung
Copy link
Owner Author

cursor review
make sure there are comprehensive tests for each function, functions are ticked as available, and properly documented with their own page stub

cursor[bot]

This comment was marked as outdated.

@BrianHung
Copy link
Owner Author

cursor review
make sure there are comprehensive tests for each function, functions are ticked as available, and properly documented with their own page stub

@BrianHung
Copy link
Owner Author

bugbot run

cursor review
make sure there are comprehensive tests for each function, functions are ticked as available, and properly documented with their own page stub

cursor[bot]

This comment was marked as outdated.

@BrianHung
Copy link
Owner Author

bugbot run

cursor review
make sure there are comprehensive tests for each function, functions are ticked as available, and properly documented with their own page stub

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ BugBot reviewed your changes and found no bugs!


Was this report helpful? Give feedback by reacting with 👍 or 👎

@BrianHung BrianHung added the ready to merge PRs ready to merge label Jul 21, 2025
BrianHung added a commit that referenced this pull request Jul 28, 2025
Resolved conflicts by keeping our working implementation while
incorporating the test files and documentation from the PR.
BrianHung added a commit that referenced this pull request Jul 28, 2025
Consolidated duplicate helper functions introduced across PRs #35, #36, #41, #33:

✅ **Holiday/Date Array Processing**:
- Merged get_holiday_set() (PR #41) and get_array_of_dates() (PR #33)
- New: process_date_array() - unified date array processing
- New: dates_to_holiday_set() - converter for backward compatibility
- Removed ~100 lines of duplicate code

✅ **Weekend Pattern Processing**:
- Merged weekend_from_arg() (PR #41) and parse_weekend_pattern() (PR #33)
- New: parse_weekend_pattern_unified() - consolidated weekend parsing
- Legacy wrapper: weekend_from_arg() for backward compatibility
- Handles both numeric codes (1-7, 11-17) and string patterns ("0110000")

**Impact**: Reduced code duplication by ~200 lines while maintaining full functionality
**Functions using consolidated helpers**: WORKDAY, WORKDAY.INTL, NETWORKDAYS, NETWORKDAYS.INTL
BrianHung added a commit that referenced this pull request Jul 28, 2025
Found and eliminated the biggest remaining duplication pattern from PRs #35, #36, #41, #33:

✅ **Date Validation Pattern** (29+ occurrences → consolidated):
- Old: Repeated `from_excel_date` + identical error handling in every function
- New: `validate_and_convert_date_serial()` - single source of truth
- New: `get_and_validate_date_serial()` - handles common get_number + validate pattern

**Functions Updated** (examples):
- fn_weekday: 9 lines → 3 lines
- fn_weeknum: 9 lines → 3 lines
- fn_workday: 9 lines → 3 lines

**Potential Impact**:
- 29+ functions with identical 9-line patterns can now use 3-line helpers
- Estimated savings: ~180 lines of duplicate code
- Single location for date validation logic changes
- Consistent error handling across all date functions

**Pattern Eliminated**:
\`\`\`rust
// Before (repeated 29+ times):
let serial = match self.get_number(&args[0], cell) { ... };
let date = match from_excel_date(serial) {
    Ok(d) => d,
    Err(_) => return CalcResult::Error { ... }
};

// After (reusable helper):
let (_serial, date) = match self.get_and_validate_date_serial(&args[0], cell) { ... };
\`\`\`
@BrianHung BrianHung mentioned this pull request Jul 29, 2025
BrianHung added a commit that referenced this pull request Jul 29, 2025
@BrianHung
Copy link
Owner Author

Consolidating into #50.

@BrianHung BrianHung closed this Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex ready to merge PRs ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants