[Issue #2] - Added timezone support with a list of support timezones
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2026-09-11 00:23:24 -04:00
parent cc96fbccc0
commit 8798092cc8
3 changed files with 105 additions and 10 deletions
+11 -10
View File
@@ -128,30 +128,31 @@ func main() {
lastSecond := -1
// Remove static call before the loop, then in the loop:
for {
currentTime := time.Now().Add(timeOffset).UTC()
currentSecond := currentTime.Second()
// Skip display refreshes if the second hasn't changed to save the i2c bus
if currentSecond != lastSecond {
lastSecond = currentSecond
// Alternate colon (:) with space ( ) every second
timeSeperator := ":"
if currentSecond % 2 == 1 {
if currentSecond%2 == 1 {
timeSeperator = " "
}
// Create the awful time string before displaying it
timeStr := fmt.Sprintf("%02d%s%02d%s%02d UTC",
currentTime.Hour(), timeSeperator,
currentTime.Minute(), timeSeperator,
currentTime.Second())
// Dynamically determine DST vs Standard time for this second
loc, zoneName := ResolveTimezone(ActiveTimezone, currentTime)
localTime := currentTime.In(loc)
timeStr := fmt.Sprintf("%02d%s%02d%s%02d %s",
localTime.Hour(), timeSeperator,
localTime.Minute(), timeSeperator,
localTime.Second(),
zoneName)
oled.ClearBuffer()
// Time
tinyfont.WriteLine(oled, defaultFont, 8, 32, timeStr, white)
// IP Address
tinyfont.WriteLine(oled, tinyFont, 0, 60, fmt.Sprintf("IP: %s", ipStr), white)
oled.Display()
}