Given an arbitrary time offset, how does one go about creating a usable time.Location
object that represents that time offset?
The following code parses a time using an offset, but fmt.Println(t.Location())
subsequently returns no information:
func main() {
offset := "+1100"
t, err := time.Parse("15:04 GMT-0700","15:06 GMT"+offset)
if err != nil {
fmt.Println("fail", err)
}
fmt.Println(t)
fmt.Println(t.UTC())
fmt.Println(t.Location())
}
Playground: https://play.golang.org/p/j_E28qJ8Vgy
Basically I have some time data with time offsets, but without location data, I want to create a time.Location
object to ensure the GMT offset is recorded. And then be able to output the time relative to the end users actual location time offset.