fix(go/fio): accept 2-digit year format in transparent date parser
All checks were successful
Deploy to K8s / deploy (push) Successful in 9s
All checks were successful
Deploy to K8s / deploy (push) Successful in 9s
Fio's transparent account page now serves dates as DD.MM.YY (e.g. 07.05.26) rather than the previously expected 4-digit-year format. Extends parseCzechDate to try all eight layout variants: padded and non-padded, dot and slash separators, 4-digit and 2-digit years. Go maps 2-digit year 00-68 → 2000-2068, so 26 → 2026. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -97,6 +97,9 @@ func TestParseCzechDate(t *testing.T) {
|
||||
{"10/04/2026", "2026-04-10"},
|
||||
{"7.5.2026", "2026-05-07"}, // non-padded — real Fio transparent page format
|
||||
{"3.12.2025", "2025-12-03"}, // non-padded single-digit day, double-digit month
|
||||
{"07.05.26", "2026-05-07"}, // padded 2-digit year — current Fio transparent page format
|
||||
{"7.5.26", "2026-05-07"}, // non-padded 2-digit year
|
||||
{"07/05/26", "2026-05-07"}, // slash variant
|
||||
{"", ""},
|
||||
{"invalid", ""},
|
||||
}
|
||||
|
||||
@@ -209,7 +209,10 @@ func hasClass(t ghtml.Token, cls string) bool {
|
||||
// Returns "" on parse error.
|
||||
func parseCzechDate(s string) string {
|
||||
s = strings.TrimSpace(s)
|
||||
for _, layout := range []string{"2.1.2006", "02.01.2006", "2/1/2006", "02/01/2006"} {
|
||||
for _, layout := range []string{
|
||||
"2.1.2006", "02.01.2006", "2/1/2006", "02/01/2006",
|
||||
"2.1.06", "02.01.06", "2/1/06", "02/01/06",
|
||||
} {
|
||||
if t, err := time.Parse(layout, s); err == nil {
|
||||
return t.Format("2006-01-02")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user