Skip to content

Commit 8a988be

Browse files
committed
fix for #86: unknown time zone Argentina/Buenos_Aires
1 parent 34322bf commit 8a988be

File tree

4 files changed

+31
-12
lines changed

4 files changed

+31
-12
lines changed

docs/releases.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Release notes
22

3+
## Release 0.8.8
4+
5+
### fix for #86: unknown time zone Argentina/Buenos_Aires
6+
7+
On some systems, the time zone name is not well recognized.
8+
9+
The new command line option set the time zone used by the program.
10+
`-time-zone=time_zone_name`
11+
12+
313
## Release 0.8.7
414

515
### fix for #82: PM files causing server's bad request

helpers/tzone/timezone.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,21 @@ var (
1919
//
2020
// to determine the local even on Windows
2121
// check the env variable TZ
22-
func Local() (*time.Location, error) {
22+
23+
func SetLocal(tz string) (*time.Location, error) {
2324
onceSetLocal.Do(func() {
24-
var tz string
25-
tz, _err = tzlocal.RuntimeTZ()
26-
if _err != nil {
27-
return
25+
if len(tz) == 0 {
26+
tz, _err = tzlocal.RuntimeTZ()
27+
if _err != nil {
28+
return
29+
}
2830
}
29-
3031
_local, _err = time.LoadLocation(strings.TrimSuffix(tz, "\n"))
3132
})
3233
return _local, _err
34+
35+
}
36+
37+
func Local() (*time.Location, error) {
38+
return SetLocal("")
3339
}

main.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ type Application struct {
6464
NoLogColors bool // Disable log colors
6565
LogLevel string // Idicate the log level
6666
Debug bool // Enable the debug mode
67+
TimeZone string // Override default TZ
6768

6869
Immich *immich.ImmichClient // Immich client
6970
Logger *logger.Log // Program's logger
@@ -78,10 +79,6 @@ func Run(ctx context.Context, log *logger.Log) (*logger.Log, error) {
7879
if err != nil {
7980
return log, err
8081
}
81-
_, err = tzone.Local()
82-
if err != nil {
83-
return log, err
84-
}
8582

8683
app := Application{}
8784
flag.StringVar(&app.Server, "server", "", "Immich server address (http://<your-ip>:2283 or https://<your-domain>)")
@@ -93,8 +90,14 @@ func Run(ctx context.Context, log *logger.Log) (*logger.Log, error) {
9390
flag.StringVar(&app.LogFile, "log-file", "", "Write log messages into the file")
9491
flag.BoolVar(&app.ApiTrace, "api-trace", false, "enable api call traces")
9592
flag.BoolVar(&app.Debug, "debug", false, "enable debug messages")
93+
flag.StringVar(&app.TimeZone, "time-zone", "", "Override the system time zone")
9694
flag.Parse()
9795

96+
_, err = tzone.SetLocal(app.TimeZone)
97+
if err != nil {
98+
return log, err
99+
}
100+
98101
if len(app.LogFile) > 0 {
99102
flog, err := os.Create(app.LogFile)
100103
if err != nil {

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ immich-go -server URL -key KEY -general_options COMMAND -command_options... {fil
5151
- `WARNING`: Same as previous one plus non blocking error
5252
- `OK`: Same as previous plus actions
5353
- `INFO`: Same as previous one plus progressions
54-
54+
<br>
5555
`-log-file=file` Write all messages to the file<br>
56-
56+
`-time-zone=time_zone_name` Set the time zone<br>
5757

5858
## Command `upload`
5959

0 commit comments

Comments
 (0)