formatDisplayDate converts an ISO timestamp to "Nov 24, 2025" format.
(ts string)
| 12 | |
| 13 | // formatDisplayDate renders a timestamp as "Nov 24, 2025" in the reader's own zone, which |
| 14 | // is the only zone the day is right in: a thread that arrived at 23:30 UTC belongs to the |
| 15 | // next day east of it. |
| 16 | func formatDisplayDate(ts time.Time) string { |
| 17 | if ts.IsZero() { |
| 18 | return "" |
| 19 | } |
| 20 | return ts.Local().Format("Jan 2, 2006") |
| 21 | } |
| 22 | |
| 23 | // formatDisplayDateTime is for a thread's entries, where the day is not enough: a |
| 24 | // back-and-forth answered within the hour is several entries on one date, and which |
| 25 | // came when is the thing the reader is reading down the thread to find out. |
| 26 | func formatDisplayDateTime(ts time.Time) string { |
| 27 | if ts.IsZero() { |
| 28 | return "" |
| 29 | } |
| 30 | return ts.Local().Format("Jan 2, 2006 15:04") |