-
Notifications
You must be signed in to change notification settings - Fork 71
Open
Description
Is there any way to pass in a time zone location and get back the posix tz string? For example:
Africa/El_Aaiun returns <GMT>0?
I've got Go code that will do this but it requires reflection.
// getFieldString uses to get the unexported value of the extends field
func getFieldString(e *time.Location, field string) string {
r := reflect.ValueOf(e)
f := reflect.Indirect(r).FieldByName(field)
return f.String()
}
// ConvertFormat formats the tz string so it is readable by ESP32 devices
func convertFormat(t *time.Location) string {
r := regexp.MustCompile(`<.*?>`)
var count int
return r.ReplaceAllStringFunc(
getFieldString(t, "extend"),
func(m string) string {
count++
if count == 1 {
return "<GMT>"
}
return "<DST>"
},
)
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels