Skip to content

native: недостающие встроенные функции#1695

Merged
EvilBeaver merged 1 commit into
EvilBeaver:developfrom
Mr-Rm:v2/native/fix-week
Jun 2, 2026
Merged

native: недостающие встроенные функции#1695
EvilBeaver merged 1 commit into
EvilBeaver:developfrom
Mr-Rm:v2/native/fix-week

Conversation

@Mr-Rm

@Mr-Rm Mr-Rm commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Added BegOfWeek function to retrieve the start date and time of a week based on a given date.
    • Added EndOfWeek function to retrieve the end date and time (23:59:59) of a week based on a given date.

@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds two complementary date utility functions to the runtime: BegOfWeek returns the start of the calendar week for a given date, while EndOfWeek returns the end of that week at 23:59:59. Both use day-of-week arithmetic to compute boundaries.

Changes

Week boundary calculation helpers

Layer / File(s) Summary
Week start and end calculation
src/OneScript.Native/Runtime/BuiltInFunctions.cs
BegOfWeek and EndOfWeek built-in functions compute week boundaries using DayOfWeek-based arithmetic, supporting Russian and English naming conventions.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A rabbit hops through dates so fine,
Week starts and ends now align!
From Monday's dawn to Sunday's last breath,
Time boundaries dance—clever and deft.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding missing built-in functions (BegOfWeek and EndOfWeek) to the native runtime.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 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 the MachineInstance.cs Sunday-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

📥 Commits

Reviewing files that changed from the base of the PR and between 109564d and a2a52ef.

📒 Files selected for processing (1)
  • src/OneScript.Native/Runtime/BuiltInFunctions.cs

@EvilBeaver EvilBeaver merged commit 01167fe into EvilBeaver:develop Jun 2, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants