-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Named timezones are case sensitive #8087
Comments
I can see it being a common mistake that applications specify the wrong case. |
This looks like it will be hard to fix. TiDB depends on Go's time package, which is case sensitive. Earlier bugs suggesting insensitivity have been rejected: golang/go#21512 |
We could try to fix some common mistakes: https://play.golang.org/p/h0AdsIQ3uf_s In the above example Otherwise we could scan the filesystem ( |
if the time zone string contains one or more
Plus the following time zone aliases:
|
I have a suggestion for an alternative solution: Have a list of timezones (the list itself doesn't change that much) and if the TZ is unknown, use |
@morgo like this? package main
import (
"bytes"
"fmt"
"io/fs"
"os"
"path/filepath"
)
func main() {
tzPath := "/usr/share/zoneinfo"
tzMarker := []byte("TZif2")
err := filepath.Walk(tzPath, func(path string, info fs.FileInfo, err error) error {
if info.Mode().IsRegular() {
f, err := os.Open(path)
if err != nil {
panic(err)
}
mark := make([]byte, 5)
f.Read(mark)
if bytes.Compare(mark, tzMarker) == 0 {
fmt.Printf("%s\n", path[len(tzPath)+1:])
}
f.Close()
}
return nil
})
if err != nil {
panic(err)
}
}
Want to do this at build time, runtime or manually? Another way to do this:
|
Yes.
I am fine with manually, but lets see what others say. |
The tzMarker should be |
I think we should close this bug as If we want to invest in fixing this, then I agree with the solution of at server start, listing all time zone files in the four different paths, create a map from lower case version -> original names and use for lookup, with some details below. When it comes to how go looks up time zone files, it depends on the platform, in the zoneSources variable, which is not exported, but we could just iterate these paths:
Also in this case it is good that we do not include the time/tzdata pkg, which would embed a zip-file in the binary with a static set of time zones as of the specific go version used for compiling the tidb-server binary. |
Bug Report
Please answer these questions before submitting your issue. Thanks!
tidb-server -V
or runselect tidb_version();
on TiDB)?The text was updated successfully, but these errors were encountered: