Skip to content

Commit

Permalink
fix timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
whalechoi committed Jul 30, 2023
1 parent 0f95c61 commit 96f1e39
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
14 changes: 14 additions & 0 deletions main/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,25 @@ import (
"XrayHelper/main/serial"
"fmt"
"github.com/fatih/color"
"os/exec"
"strings"
"time"
)

var Verbose *bool

func init() {
out, err := exec.Command("/system/bin/getprop", "persist.sys.timezone").Output()
if err != nil {
return
}
z, err := time.LoadLocation(strings.TrimSpace(string(out)))
if err != nil {
return
}
time.Local = z
}

// HandleError record error log
func HandleError(v interface{}) {
if str := serial.ToString(v); str != "" {
Expand Down
7 changes: 0 additions & 7 deletions main/main.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
package main

import (
"XrayHelper/main/builds"
"fmt"
"os"
)

func main() {
if len(os.Args) == 1 {
fmt.Println(builds.VersionStatement())
fmt.Println(builds.IntroStatement())
return
}
os.Exit(LoadOption())
}
6 changes: 6 additions & 0 deletions main/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"XrayHelper/main/log"
"fmt"
"github.com/jessevdk/go-flags"
"os"
)

var Option struct {
Expand All @@ -20,6 +21,11 @@ var Option struct {

// LoadOption load Option, the program entry
func LoadOption() int {
if len(os.Args) == 1 {
fmt.Println(builds.VersionStatement())
fmt.Println(builds.IntroStatement())
return 0
}
rCode := 0
log.Verbose = &Option.VerboseFlag
builds.ConfigFilePath = &Option.ConfigFilePath
Expand Down

0 comments on commit 96f1e39

Please sign in to comment.