Skip to content

Commit f947221

Browse files
authored
fix: include tzdata for golang timezone (#626)
* fix: include tzdata for timezone * fix: fallback to UTC if failed to parse user timezone * fix: set loc tz to UTC
1 parent 8e9caf2 commit f947221

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

microsoft365/outlook/calendar/main.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"strconv"
88
"strings"
99
"time"
10+
_ "time/tzdata"
1011

1112
"github.com/obot-platform/tools/microsoft365/outlook/calendar/pkg/commands"
1213
"github.com/obot-platform/tools/microsoft365/outlook/calendar/pkg/graph"
@@ -33,8 +34,9 @@ func main() {
3334
}
3435
loc, err := time.LoadLocation(timezone)
3536
if err != nil {
36-
fmt.Println("Error loading location: %s. Error: %s", timezone, err)
37-
os.Exit(1)
37+
fmt.Printf("Error loading user timezone: %s. Error: %v. Falling back to UTC.\n", timezone, err)
38+
timezone = "UTC"
39+
loc = time.UTC // Use UTC location after error
3840
}
3941
now := time.Now().In(loc)
4042
start := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, loc)

microsoft365/outlook/calendar/pkg/printers/events.go

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"os"
1212
"strings"
1313
"time"
14+
_ "time/tzdata"
1415
)
1516

1617
func EventToString(ctx context.Context, client *msgraphsdkgo.GraphServiceClient, calendar graph.CalendarInfo, event models.Eventable) string {

0 commit comments

Comments
 (0)