native: недостающие встроенные функции#1695
Conversation
📝 WalkthroughWalkthroughThis PR adds two complementary date utility functions to the runtime: ChangesWeek boundary calculation helpers
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/OneScript.Native/Runtime/BuiltInFunctions.cs (1)
268-272: Modulo week-boundary formulas match MachineInstance.cs
BegOfWeek (-((int)date.DayOfWeek+6)%7) and EndOfWeek’s modulo-based offset compute the same results as theMachineInstance.csSunday-normalization logic for every weekday and for tested year-boundary dates. The modulo expression is correct but would benefit from a short comment explaining the Sunday handling for readability.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/OneScript.Native/Runtime/BuiltInFunctions.cs` around lines 268 - 272, BegOfWeek's modulo expression correctly normalizes Sunday via -((int)date.DayOfWeek+6)%7 but lacks explanation; add a short inline comment in the BegOfWeek method (and mirror in EndOfWeek if present) explaining that the formula shifts DayOfWeek so Sunday becomes the last day of the week (i.e., maps DayOfWeek 0 to 6) before applying the modulo to compute the offset to Monday, so future readers will understand the Sunday-normalization intent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/OneScript.Native/Runtime/BuiltInFunctions.cs`:
- Around line 268-272: BegOfWeek's modulo expression correctly normalizes Sunday
via -((int)date.DayOfWeek+6)%7 but lacks explanation; add a short inline comment
in the BegOfWeek method (and mirror in EndOfWeek if present) explaining that the
formula shifts DayOfWeek so Sunday becomes the last day of the week (i.e., maps
DayOfWeek 0 to 6) before applying the modulo to compute the offset to Monday, so
future readers will understand the Sunday-normalization intent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ecd99786-08dd-4333-9d1a-a54efb074711
📒 Files selected for processing (1)
src/OneScript.Native/Runtime/BuiltInFunctions.cs
Summary by CodeRabbit
BegOfWeekfunction to retrieve the start date and time of a week based on a given date.EndOfWeekfunction to retrieve the end date and time (23:59:59) of a week based on a given date.