Skip to content

Commit

Permalink
Make Windows timezone error more specific
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Ridley <benridley29@gmail.com>
  • Loading branch information
benridley committed Mar 14, 2022
1 parent cbfac73 commit 07ba642
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions timeinterval/timeinterval.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"encoding/json"
"errors"
"fmt"
"os"
"regexp"
"runtime"
"strconv"
Expand Down Expand Up @@ -181,8 +182,11 @@ func (tz *Location) UnmarshalYAML(unmarshal func(interface{}) error) error {

loc, err := time.LoadLocation(str)
if err != nil {
if runtime.GOOS == "windows" && str != "Local" && str != "UTC" {
return fmt.Errorf("unable to load time location. Timezones other than 'Local' and 'UTC' may not be supported on Windows without using a custom timezone file: %w", err)
if runtime.GOOS == "windows" {
if zoneinfo := os.Getenv("ZONEINFO"); zoneinfo != "" {
return fmt.Errorf("%w (ZONEINFO=%q)", err, zoneinfo)
}
return fmt.Errorf("%w (on Windows platforms, you may have to pass the time zone database using the ZONEINFO environment variable, see https://pkg.go.dev/time#LoadLocation for details)", err)
}
return err
}
Expand Down

0 comments on commit 07ba642

Please sign in to comment.