Skip to content

Instantly share code, notes, and snippets.

@fbiville
Created June 18, 2021 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fbiville/785f6783628ae633f59e60e490f1aa34 to your computer and use it in GitHub Desktop.
Save fbiville/785f6783628ae633f59e60e490f1aa34 to your computer and use it in GitHub Desktop.
Get a time zone offset from a time zone name
// +build testing
package main
import "C"
import "time"
//export time_zone_offset_seconds
func time_zone_offset_seconds(tzName *C.char) C.int {
location, err := time.LoadLocation(C.GoString(tzName))
if err != nil {
panic(err)
}
_, offset := time.Now().In(location).Zone()
return C.int(offset)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment