@@ -29,16 +29,16 @@ func TimezoneIANA() (*time.Location, error) {
29
29
return nil , xerrors .Errorf ("lookup timezone from env: %w" , err )
30
30
}
31
31
32
- lp , err := filepath .EvalSymlinks (etcLocaltime )
33
- if err != nil {
34
- return nil , xerrors .Errorf ("read location of %s: %w" , etcLocaltime , err )
32
+ location , err := filepath .EvalSymlinks (etcLocaltime )
33
+ if err == nil {
34
+ location = strings .Replace (location , zoneInfoPath , "" , - 1 )
35
+ location = strings .TrimPrefix (location , string (filepath .Separator ))
36
+ } else {
37
+ location , _ = time .Now ().Zone ()
35
38
}
36
-
37
- stripped := strings .Replace (lp , zoneInfoPath , "" , - 1 )
38
- stripped = strings .TrimPrefix (stripped , string (filepath .Separator ))
39
- loc , err = time .LoadLocation (stripped )
39
+ loc , err = time .LoadLocation (location )
40
40
if err != nil {
41
- return nil , xerrors .Errorf ("invalid location %q guessed from %s: %w" , stripped , lp , err )
41
+ return nil , xerrors .Errorf ("invalid location %q guessed from %s: %w" , location , location , err )
42
42
}
43
43
return loc , nil
44
44
}
0 commit comments