Skip to content

Conversation

@BrianHung
Copy link
Owner

Summary

  • implement several date & time functions
  • add tests for new functions
  • document that these functions are now available

Testing

  • cargo test

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

@BrianHung BrianHung changed the title Implement date functions DAYS, DAYS360, WEEKDAY, WEEKNUM, WORKDAY, WORKDAY.INTL, YEARFRAC, ISOWEEKNUM Jul 14, 2025
@BrianHung BrianHung changed the title DAYS, DAYS360, WEEKDAY, WEEKNUM, WORKDAY, WORKDAY.INTL, YEARFRAC, ISOWEEKNUM days, days360, weekday, weeknum, workday, workday.intl, yearfrac, isoweeknum 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

@cursor
Copy link

cursor bot commented Jul 21, 2025

🚨 BugBot couldn't run

Something went wrong. Try again by commenting "bugbot run", or contact support (requestId: serverGenReqId_a72c05db-81f8-430e-bbb0-99157f7aa612).

@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

bugbot run

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
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