Created
October 11, 2019 23:16
-
-
Save isomorphisms/83229a9fdf6832f66ad07945175bbbf4 to your computer and use it in GitHub Desktop.
how to print out time zones for various places in golang.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"time" | |
"fmt" | |
) | |
func check(e error) { if( e!= nil) { panic(e) } } | |
func main() { | |
pr := fmt.Println | |
t := time.Now() | |
ny,err := time.LoadLocation("America/New_York") | |
check(err) | |
posey,err := time.LoadLocation("America/Indiana/Indianapolis") | |
check(err) | |
laporte,err := time.LoadLocation("America/Chicago") | |
check(err) | |
tell_city,err := time.LoadLocation("America/Indiana/Tell_City") | |
check(err) | |
pr("Location: ", t.Location(), "\t", "Time: ", t ) | |
pr("Location: ", ny, "\t", "Time: ", time.Now().In(ny) ) | |
pr("Location: ", posey, "\t", "Time: ", time.Now().In(posey) ) | |
pr("Location: ", laporte, "\t", "Time: ", time.Now().In(laporte) ) | |
pr("Location: ", tell_city, "\t", "Time: ", time.Now().In(tell_city) ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment