go - TimeZone to Offset? -


i want offset in seconds specified time zone. tz_offset() in perl's time::zone does: "determines offset gmt in seconds of specified timezone".

is there way of doing in go? input string has time zone name and that's it, know go has loadlocation() in time package, string => offset or location => offset should fine.

input: "mst"

output: -25200

here code, calculates current offset between local , specified timezones. agree ainar-g's comment offset makes sense relation specified moment in time:

package main  import (     "fmt"     "time" )  func main() {     loc, err := time.loadlocation("mst")     if err != nil {         fmt.println(err)     }      := time.now()     _, destoffset := now.in(loc).zone()     _, localoffset := now.zone()      fmt.println("offset:", destoffset-localoffset) } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -