diff --git a/Menu/GameShell/10_Settings/TimeZone/time_zone_page.go b/Menu/GameShell/10_Settings/TimeZone/time_zone_page.go index 8f30339..7462ee9 100644 --- a/Menu/GameShell/10_Settings/TimeZone/time_zone_page.go +++ b/Menu/GameShell/10_Settings/TimeZone/time_zone_page.go @@ -259,6 +259,10 @@ func (self *TimeZoneListPage) Click() { err := cpCmd.Run() if err != nil{ fmt.Println(err) + }else { + + self.Screen.TitleBar.UpdateTimeLocation() + } fmt.Println("add ",cur_li.Path) } diff --git a/sysgo/UI/title_bar.go b/sysgo/UI/title_bar.go index c6a1b92..52c368c 100644 --- a/sysgo/UI/title_bar.go +++ b/sysgo/UI/title_bar.go @@ -8,6 +8,7 @@ import ( "bufio" "strings" "os/exec" + "io/ioutil" gotime "time" "github.com/veandco/go-sdl2/sdl" @@ -109,6 +110,7 @@ type TitleBar struct { icon_base_path string /// SkinMap("gameshell/titlebar_icons/") + MyTimeLocation *gotime.Location TitleFont *ttf.Font TimeFont *ttf.Font @@ -405,6 +407,9 @@ func (self *TitleBar) Init(main_screen *MainScreen) { } } + + self.UpdateTimeLocation() + } func (self *TitleBar) ClearCanvas() { @@ -421,6 +426,29 @@ func (self *TitleBar) ClearCanvas() { } +func (self *TitleBar) UpdateTimeLocation() { + + d,err := ioutil.ReadFile("/etc/localtime") + if err != nil { + return + } + + self.MyTimeLocation,err = gotime.LoadLocationFromTZData("local", d) + if err != nil { + fmt.Println(err) + self.MyTimeLocation = nil + } +} + +func (self *TitleBar) GetLocalTime() gotime.Time { + if self.MyTimeLocation == nil { + return gotime.Now() + }else { + return gotime.Now().In(self.MyTimeLocation) + } +} + + func (self *TitleBar) Draw(title string) { self.ClearCanvas() self.Title = title