fix: correct Russian @DoW array order (Sunday must be index 0)#117
Conversation
|
@Koan-Bot rebase |
| "\xd0\xd0", # пп | ||
| ); | ||
|
|
||
| @Dsuf = ('.') x 32; |
| # 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 Суббота"); |
Greptile SummaryThis PR fixes a long-standing off-by-one bug in Confidence Score: 5/5Safe 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.
|
| 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
Reviews (1): Last reviewed commit: "fix: correct Russian @DoW array order (S..." | Re-trigger Greptile
Rebase with requested adjustmentsBranch Changes applied
StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
44bc032 to
fb6cfe1
Compare
|
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.) |
| sudo: false | ||
| global: false | ||
| cpanfile: ".github/cpanfile" | ||
| version: "0.997016" |
There was a problem hiding this comment.
no need to pin the version there
atoomic
left a comment
There was a problem hiding this comment.
let's revert the change to ci.yml then we are good
| sudo: false | ||
| global: false | ||
| cpanfile: ".github/cpanfile" | ||
| version: "0.997016" |
|
@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>
Rebase with requested adjustmentsBranch StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
df94e20 to
81dc349
Compare
What
Fixes the
@DoW,@DoWs, and@DoWs2arrays inDate::Language::Russianto start with Sunday at index 0, matching thelocaltime()wday convention.Why
The arrays started at Monday (index 0), causing every Russian day name to be off by one when formatting with
%Aor%a. Sunday was at index 6 instead of 0. The sister modulesRussian_koi8randRussian_cp1251already had the correct order.How
@Dsuf(declared but never assigned) with'.'to match the existingformat_oconventionlang-data.texpected values and added explicit regression tests for Saturday/Sunday/Monday formattingTesting
prove -l t/— all tests pass, including new regression tests verifying correct day names for known weekdays.🤖 Generated with Claude Code