drawDate - respects NoCaption / NoCity indirectly through frame
(loc *domain.Location, l10n localization.L10n)
| 12 | |
| 13 | // drawDate - respects NoCaption / NoCity indirectly through frame |
| 14 | func drawDate(loc *domain.Location, l10n localization.L10n) string { |
| 15 | tz, _ := time.LoadLocation(loc.TimeZone) |
| 16 | |
| 17 | // Match Python: start from UTC and add full days (more consistent across timezones) |
| 18 | now := time.Now().UTC() |
| 19 | tzNow := now.In(tz) |
| 20 | |
| 21 | var b strings.Builder |
| 22 | |
| 23 | // 3 date lines |
| 24 | for i := 0; i < 3; i++ { |
| 25 | d := tzNow.AddDate(0, 0, i) |
| 26 | |
| 27 | dateStr, _ := lctime.StrftimeLoc(string(l10n.Text("LOCALE")), "%a %d %b", d) |
| 28 | |
| 29 | // Center in 24 characters (Python-style padding: extra space on left if odd) |
| 30 | total := 24 |
| 31 | left := (total - displayWidth(dateStr)) / 2 |
| 32 | right := total - displayWidth(dateStr) - left |
| 33 | |
| 34 | // Python does left-heavy when odd length, but difference is tiny |
| 35 | line := strings.Repeat(" ", left) + dateStr + strings.Repeat(" ", right) |
| 36 | b.WriteString(line) |
| 37 | } |
| 38 | b.WriteString("\n") |
| 39 | |
| 40 | // 3 separator lines with ╷ |
| 41 | for i := 0; i < 3; i++ { |
| 42 | tick := "╷" |
| 43 | if i == 2 { |
| 44 | tick = " " |
| 45 | } |
| 46 | b.WriteString(strings.Repeat(" ", 23) + tick) |
| 47 | } |
| 48 | b.WriteString("\n") |
| 49 | |
| 50 | result := b.String() |
| 51 | |
| 52 | return result |
| 53 | } |
no test coverage detected