summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Frei <freisim93@gmail.com>2021-08-09 09:27:14 +0200
committerGitHub <noreply@github.com>2021-08-09 09:27:14 +0200
commitdb302b15eae3693dab792c811029d237556831af (patch)
treef6aa866ec38fb18e532813b07b906b3791cc1377
parent952f3ffb0c0d334d08c71942e26edd6e97bb5e56 (diff)
lib/syncthing: Set system timezone on android (#7878)v1.18.2-rc.1
-rw-r--r--lib/syncthing/time_android.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/syncthing/time_android.go b/lib/syncthing/time_android.go
new file mode 100644
index 000000000..a5da6b699
--- /dev/null
+++ b/lib/syncthing/time_android.go
@@ -0,0 +1,26 @@
+// Copyright (C) 2021 The Syncthing Authors.
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this file,
+// You can obtain one at https://mozilla.org/MPL/2.0/.
+
+package syncthing
+
+import (
+ "os/exec"
+ "strings"
+ "time"
+)
+
+// https://github.com/golang/go/issues/20455#issuecomment-342287698
+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
+}