Skip to content

fix: correct Russian @DoW array order (Sunday must be index 0)#117

Merged
atoomic merged 1 commit into
cpan-authors:mainfrom
Koan-Bot:koan.atoomic/fix-russian-dow-order
Apr 29, 2026
Merged

fix: correct Russian @DoW array order (Sunday must be index 0)#117
atoomic merged 1 commit into
cpan-authors:mainfrom
Koan-Bot:koan.atoomic/fix-russian-dow-order

Conversation

@Koan-Bot
Copy link
Copy Markdown

What

Fixes the @DoW, @DoWs, and @DoWs2 arrays in Date::Language::Russian to start with Sunday at index 0, matching the localtime() wday convention.

Why

The arrays started at Monday (index 0), causing every Russian day name to be off by one when formatting with %A or %a. Sunday was at index 6 instead of 0. The sister modules Russian_koi8r and Russian_cp1251 already had the correct order.

How

  • Moved Воскресенье/Вс/Вск to index 0 in all three arrays
  • Populated the empty @Dsuf (declared but never assigned) with '.' to match the existing format_o convention
  • Updated lang-data.t expected values and added explicit regression tests for Saturday/Sunday/Monday formatting

Testing

prove -l t/ — all tests pass, including new regression tests verifying correct day names for known weekdays.

🤖 Generated with Claude Code

@atoomic
Copy link
Copy Markdown
Collaborator

atoomic commented Apr 26, 2026

@Koan-Bot rebase

Comment thread lib/Date/Language/Russian.pm Outdated
"\xd0\xd0", # пп
);

@Dsuf = ('.') x 32;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@Koan-Bot why using 32 here and not 31?

Comment thread t/lang-data.t
# Saturday = Суббота (KOI8-R: \xf3\xd5\xc2\xc2\xcf\xd4\xc1)
is($ru->time2str('%A', $sat, 'GMT'),
"\xf3\xd5\xc2\xc2\xcf\xd4\xc1",
"Russian: Saturday formats as Суббота");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this is correct

Copy link
Copy Markdown
Collaborator

@atoomic atoomic left a comment

Choose a reason for hiding this comment

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

@Koan-Bot rebase view question

@atoomic atoomic marked this pull request as ready for review April 26, 2026 13:00
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 26, 2026

Greptile Summary

This PR fixes a long-standing off-by-one bug in Date::Language::Russian where @DoW, @DoWs, and @DoWs2 were Monday-first instead of Sunday-first, causing every formatted Russian day name to be wrong by one weekday when using %A or %a. The fix brings Russian.pm into alignment with the already-correct Russian_koi8r and Russian_cp1251 sister modules, and also initialises the previously-empty @Dsuf array so strptime-based parsing works correctly.

Confidence Score: 5/5

Safe to merge — the fix is correct, consistent with sister modules, and covered by new regression tests against known epoch timestamps.

All three day-name arrays are reordered identically and consistently. The updated table test now expects the correct Tuesday name for the Tuesday-epoch fixture. The regression block pins Saturday/Sunday/Monday against hard-coded epochs, proving the old off-by-one is gone. @Dsuf initialisation is a harmless improvement. No P0 or P1 findings.

No files require special attention.

Important Files Changed

Filename Overview
lib/Date/Language/Russian.pm Reorders @Dow, @dows, @DoWs2 so Sunday is at index 0 (matching localtime wday), and populates the previously-empty @Dsuf for strptime support; logic is consistent with sister modules
t/lang-data.t Updates Russian expected values in the existing table test to reflect Tuesday (now correct), and adds a targeted regression block verifying Saturday/Sunday/Monday against known epoch timestamps

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["time2str('%A', $epoch, 'GMT')"] --> B["localtime($epoch)[6]\n(wday: 0=Sun … 6=Sat)"]
    B --> C{Index into @DoW}
    C -- "OLD (Monday-first)\nwday=2 → @DoW[2] = Среда ❌" --> D["Wrong day name returned"]
    C -- "NEW (Sunday-first)\nwday=2 → @DoW[2] = Вторник ✓" --> E["Correct day name returned"]
    E --> F["Russian_koi8r / Russian_cp1251\nalready used this layout"]
    style D fill:#ffcccc
    style E fill:#ccffcc
Loading

Reviews (1): Last reviewed commit: "fix: correct Russian @DoW array order (S..." | Re-trigger Greptile

@Koan-Bot
Copy link
Copy Markdown
Author

Rebase with requested adjustments

Branch koan.atoomic/fix-russian-dow-order was rebased onto main and review feedback was applied.

Changes applied

  • Changed @Dsuf = ('.') x 32 to @Dsuf = ('.') x 31 per reviewer request — 31 matches the convention used by all other language modules (Finnish, Hungarian, Russian_koi8r, Russian_cp1251, etc.) and covers day-of-month values 1–31.

Stats

2 files changed, 39 insertions(+), 9 deletions(-)
Actions performed
  • Already-solved check: negative (confidence=high, reasoning=None of the recent commits on main address the Russian @Dow array ordering bug; the existing Russian)
  • Resolved merge conflicts (1 round(s))
  • Rebased koan.atoomic/fix-russian-dow-order onto upstream/main
  • Applied review feedback
  • Pre-push CI check: previous run passed
  • Force-pushed koan.atoomic/fix-russian-dow-order to origin
  • CI check enqueued in ## CI (async)

CI status

CI will be checked asynchronously.


Automated by Kōan

@Koan-Bot Koan-Bot force-pushed the koan.atoomic/fix-russian-dow-order branch from 44bc032 to fb6cfe1 Compare April 27, 2026 00:34
Koan-Bot added a commit to Koan-Bot/perl-TimeDate that referenced this pull request Apr 27, 2026
@Koan-Bot
Copy link
Copy Markdown
Author

Re: the `x 32` vs `x 31` question —

My original reasoning was that `format_o` indexes `@Dsuf` by `mday` (1–31), so 32 elements (indices 0–31) would cover day 31. But the established convention across all other language modules (Finnish, Hungarian, Dutch, Russian_koi8r, etc.) is `x 31`, and index 0 is never accessed. Changed to 31 in the rebase to stay consistent.

(Side note: `Portuguese.pm` also uses `x 32` — same reasoning, same inconsistency.)

Comment thread .github/workflows/ci.yml Outdated
sudo: false
global: false
cpanfile: ".github/cpanfile"
version: "0.997016"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

no need to pin the version there

Copy link
Copy Markdown
Collaborator

@atoomic atoomic left a comment

Choose a reason for hiding this comment

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

let's revert the change to ci.yml then we are good

Comment thread .github/workflows/ci.yml Outdated
sudo: false
global: false
cpanfile: ".github/cpanfile"
version: "0.997016"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@Koan-Bot remove that version pin here

@atoomic
Copy link
Copy Markdown
Collaborator

atoomic commented Apr 29, 2026

@Koan-Bot rebase

The @Dow, @dows, and @DoWs2 arrays in Russian.pm started at Monday
(index 0) instead of Sunday, as required by localtime()'s wday
convention (0=Sunday). This caused every day name to be off by one
when formatting with %A or %a.

Also populate the empty @Dsuf array (was declared but never assigned),
using '.' to match the existing format_o convention.

The sister modules Russian_koi8r.pm and Russian_cp1251.pm already had
the correct Sunday-first order.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Koan-Bot
Copy link
Copy Markdown
Author

Rebase with requested adjustments

Branch koan.atoomic/fix-russian-dow-order was rebased onto main and review feedback was applied.

Stats

2 files changed, 37 insertions(+), 9 deletions(-)
Actions performed
  • Already-solved check: negative (confidence=high, reasoning=The Russian.pm @Dow array on main still starts with Monday at index 0 (line 66), not Sunday — the of)
  • Resolved merge conflicts (1 round(s))
  • Rebased koan.atoomic/fix-russian-dow-order onto upstream/main
  • Pre-push CI check: previous run passed
  • Force-pushed koan.atoomic/fix-russian-dow-order to origin
  • CI check enqueued in ## CI (async)

CI status

CI will be checked asynchronously.


Automated by Kōan

@Koan-Bot Koan-Bot force-pushed the koan.atoomic/fix-russian-dow-order branch from df94e20 to 81dc349 Compare April 29, 2026 10:16
@atoomic atoomic merged commit 1d3c435 into cpan-authors:main Apr 29, 2026
22 checks passed
@Koan-Bot Koan-Bot deleted the koan.atoomic/fix-russian-dow-order branch April 29, 2026 12:22
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