Metadata: Add "local" as an alias for an unknown (local) time zone

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-04-15 15:39:04 +02:00
parent 161b18e5e8
commit 2c47644ea8
2 changed files with 4 additions and 1 deletions

View File

@@ -9,7 +9,7 @@ import (
// TimeZone returns a time zone for the given UTC offset string.
func TimeZone(offset string) *time.Location {
if offset == "" {
if offset == "" || strings.EqualFold(offset, "local") {
// Local time.
} else if offset == "UTC" || offset == "Z" {
return time.UTC

View File

@@ -15,6 +15,9 @@ func TestTimeZone(t *testing.T) {
})
t.Run("LocalTime", func(t *testing.T) {
assert.Equal(t, "", TimeZone("").String())
assert.Equal(t, "", TimeZone("local").String())
assert.Equal(t, "", TimeZone("Local").String())
assert.Equal(t, "", TimeZone("LOCAL").String())
assert.Equal(t, "", TimeZone("0").String())
assert.Equal(t, "", TimeZone("UTC+0").String())
assert.Equal(t, "", TimeZone("UTC+00:00").String())