github.com/grantbow/fit@v0.7.1-0.20220916164603-1f7c88ac81e6/fitapp/Version.go (about) 1 package fitapp 2 3 import ( 4 "fmt" 5 "os" 6 "runtime" 7 "time" 8 ) 9 10 // ProgramVersion returns the base version string 11 func ProgramVersion() string { 12 return "0.7" 13 } 14 15 // PrintVersion describes fit and golang. 16 func PrintVersion() { 17 ex, _ := os.Executable() 18 fi, _ := os.Stat(ex) 19 fmt.Printf("%s version %s built using %s GOOS %v\n", 20 os.Args[0], 21 ProgramVersion(), 22 runtime.Version(), 23 runtime.GOOS) 24 25 var loc *time.Location 26 var errl error 27 if runtime.GOOS == "android" { 28 // workaround for https://golang.org/src/time/zoneinfo_android.go line 25 hard coded UTC 29 tz := os.Getenv("TZ") 30 if os.Getenv("TZ") == "" { 31 fmt.Println("WARN: TZ is empty or not set") 32 } 33 loc, errl = time.LoadLocation(tz) 34 if errl != nil { 35 panic(errl) 36 } 37 } else { 38 loc = time.Local 39 } 40 41 fmt.Printf("executable: %v %v %s %s\n", 42 fi.Mode(), 43 fi.Size(), 44 fi.ModTime().In(loc).Format(time.UnixDate), 45 ex) 46 //name, offset := time.Now().Local().Zone() 47 //fmt.Printf("z: %+v %+v\n", name, offset) 48 //fmt.Printf("tz: %+v\n", os.Getenv("TZ")) 49 //fmt.Printf("aha: %+v\n", fi.ModTime().In(loc).Format(time.UnixDate)) 50 51 //x := fi.ModTime() 52 //x.loc = Local 53 //fmt.Printf("tz: %+v\n", os.Setenv("TZ", "America/Los_Angeles")) 54 //time.LoadLocation(time.Local) 55 //time.LoadLocation("America/Los_Angeles") 56 57 }