Test improvements to calcDateOffsetStr and other new tests and edge case fix#698
Test improvements to calcDateOffsetStr and other new tests and edge case fix#698
Conversation
dwertheimer
left a comment
There was a problem hiding this comment.
@jgclark I was looking through this PR code and I find it confusing on why/when it was using ISO weeks in some cases when NP weeks would be appropriate. I asked Cursor and it agreed, writing:
There's a significant issue in the logic at lines 1327-1329
The issue: The variable wasISOWeekInput checks if the input matches RE_NP_WEEK_SPEC (the pattern YYYY-Wnn), but ISO weeks and NotePlan weeks use the same format - there's no way to visually distinguish them!
This means:
❌ It will never use formatNPWeek (which respects user preferences) when the base input is a week string
@EduardMe does not use ISO weeks. So I don't think the plugins should either. I am going to suggest a refactor that will remove the ISO weeks and force NP Weeks (and will provide the tests and mocks you asked for). Of course you can reject if you disagree.
Summary of calcOffsetDateStr Refactoring: NotePlan Week SupportChange MadeRemoved all ISO week logic from What Is Enforced
26 New Tests Cover These EdgesWeek Start Day Differences (12 tests)
Year Boundary Crossings (8 tests)
Week 53 Edge Cases (4 tests)
adaptOutputInterval Format Control (6 tests)
Multiple Week Offsets (4 tests)
All tests use exact assertions ( |
|
@jgclark on a related note, this PR is failing because of: |
|
Thanks, David, for looking at this carefully and providing new mocks and tests, which is all most helpful. It's odd to see the way Cursor is so happily dissing its earlier work that it did for me. But if there's now a way to only use NP weeks, not a mix of ISO and NP ones, then that's indeed a good step forward. Much earlier on I was clearly trying to avoid use of NotePlan.Calendar, as it wouldn't be available from HTMLWindows, but having a look now I think we don't in practice have examples of it. I'll have a look to see whether these functions now need to live in NPDateTime.js not dateTIme.js. |
That's odd, as WindowTools on main was and is building for me OK. But I've fixed the issue. |

No description provided.