Keep civil-date math in one utils::time module: days_from_civil is written twice and vex::time claims to be the only copy
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 66/100
Rechercherichtung
Read crates/socket-patch-core/src/api/date.rs, formats/cargo/floor.rs, and vex/time.rs, then check how api::date is imported by tests/e2e_hosted_production.rs. Move the listed time functions and tests into src/utils/time.rs, update callers and remove the duplicate implementation and outdated claim. Run the named date and dated-channel tests; done means behavior is unchanged and only one days_from_civil definition remains.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
[agent] Filed by the scheduled architecture audit (audit-core). Register: register.
Kind: refactor. Register ID: A26.
Problem
Calendar arithmetic (Howard Hinnant's civil-date algorithms) lives in three modules at 5ca5623:
api/date.rsL48-L56:days_from_civil(year: i64, month: u32, day: u32), the parser half (parse_timestamp_secs, used byapi::rankingandapi::retry).formats/cargo/floor.rsL25-L33: a seconddays_from_civil(year: i64, month: i64, day: i64), spelled withdiv_euclidinstead of theif y >= 0 { y } else { y - 399 } / 400form. It is used to datenightly-YYYY-MM-DDtoolchains.vex/time.rsL30-L36: the inversecivil_from_days, insideunix_to_ymdhms. Its doc claims "this is the single civil-date implementation in the crate".telemetryalso formats timestamps through it.
Today the two days_from_civil copies compute the same values; api/date.rs's round-trip test pins only its own copy. A time module under vex/ that telemetry and api import, plus a date parser under api/, puts a general utility in two feature modules.
Proposed change
- Add
crates/socket-patch-core/src/utils/time.rsholdingdays_from_civil,unix_to_ymdhms,now_rfc3339andparse_timestamp_secs, with the tests ofapi/date.rsandvex/time.rs. - Delete
formats/cargo/floor.rs's copy and callutils::time::days_from_civil(convert itsi64month and day at the call). - Delete
api/date.rsandvex/time.rs, or reduce them topub uselines if the CLI or tests import them by path (tests/e2e_hosted_production.rsimportsapi::date::parse_timestamp_secs). - Drop the "single civil-date implementation" claim.
Size
4–5 files. The diff is mostly moves; about −25 net lines.
Acceptance criteria
- Behavior is unchanged.
days_from_civil_inverts_unix_to_ymdhms,parsed_order_is_chronological_in_both_formats,unix_to_ymdhms_matches_brute_forceand floor.rs's dated-channel tests pass unchanged. - One
days_from_civilremains in the crate (grep -rn "fn days_from_civil" cratesreturns one hit). - While moving the tests, drop the fake assert
assert!(secs > prev_2822 || secs == 0)inparsed_order_is_chronological_in_both_formats(date.rs L523). It checks the test's own loop counter, not the parser.
- Vorherrschende Sprache
- Rust
- Sterne
- 9
- Forks
- 2
- Ø Merge
- 18 Std. 47 Min.
- Gemergte PRs (30 T.)
- 637
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus SocketDev/socket-patch
-
agent:triaged arch-audit priority:p3 refactor
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 83/100
SocketDev/socket-patch#1860 ·
Maintainer antworten meist innerhalb von 1 Tag
-
agent:triaged arch-audit priority:p3 refactor
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
SocketDev/socket-patch#1838 ·
Maintainer antworten meist innerhalb von 1 Tag
-
arch-audit refactor
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
SocketDev/socket-patch#1987 ·
Maintainer antworten meist innerhalb von 1 Tag
-
agent:triaged arch-audit priority:p3 refactor
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
SocketDev/socket-patch#1983 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
agent:triaged arch-audit bug priority:p3
Schwierigkeit 3/5 Ein halber Tag Anfängerfreundlichkeit 55/100
SocketDev/socket-patch#1982 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in SocketDev/socket-patch
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
test(hydro_std): track_membership join and leave are untestedEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
hydro-project/hydro#3289 ·
Maintainer antworten meist innerhalb von 1 Tag
-
diagram-bug good first issue help wanted
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
enhapu-afk/omaspec#4 ·
-
priority: low ☕️ type: bug 🐛
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug security
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Maintainer antworten meist innerhalb von 4 Tagen