Created
          July 13, 2018 09:44 
        
      - 
      
 - 
        
Save yowcow/3f4f9909565a47d0b72d09d55d875292 to your computer and use it in GitHub Desktop.  
    Broken timezone on Ubuntu 18.04, Golang 1.10.3
  
        
  
    
      This file contains hidden or 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 ( | |
| "fmt" | |
| "os" | |
| "time" | |
| ) | |
| var format = "2006/01/02 15:04:05" | |
| func main() { | |
| dateStr := os.Args[1] | |
| timeStr := os.Args[2] | |
| t, err := time.Parse(format, fmt.Sprintf("%s %s", dateStr, timeStr)) | |
| if err != nil { | |
| panic(err) | |
| } | |
| asiaTokyo, err := time.LoadLocation("Asia/Tokyo") | |
| if err != nil { | |
| panic(err) | |
| } | |
| fmt.Println("default:", t.Format(time.RFC3339Nano)) | |
| fmt.Println("Asia/Tokyo", t.In(asiaTokyo).Format(time.RFC3339Nano)) | |
| } | |
| /** | |
| % go run main.go 1901/12/13 20:45:52 | |
| default: 1901-12-13T20:45:52Z | |
| Asia/Tokyo 1901-12-14T05:45:52+09:00 | |
| % go run main.go 1901/12/13 20:45:51 | |
| default: 1901-12-13T20:45:51Z | |
| Asia/Tokyo 1901-12-14T06:04:50+09:18 | |
| **/ | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment