mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
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:
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
// TimeZone returns a time zone for the given UTC offset string.
|
// TimeZone returns a time zone for the given UTC offset string.
|
||||||
func TimeZone(offset string) *time.Location {
|
func TimeZone(offset string) *time.Location {
|
||||||
if offset == "" {
|
if offset == "" || strings.EqualFold(offset, "local") {
|
||||||
// Local time.
|
// Local time.
|
||||||
} else if offset == "UTC" || offset == "Z" {
|
} else if offset == "UTC" || offset == "Z" {
|
||||||
return time.UTC
|
return time.UTC
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ func TestTimeZone(t *testing.T) {
|
|||||||
})
|
})
|
||||||
t.Run("LocalTime", func(t *testing.T) {
|
t.Run("LocalTime", func(t *testing.T) {
|
||||||
assert.Equal(t, "", TimeZone("").String())
|
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("0").String())
|
||||||
assert.Equal(t, "", TimeZone("UTC+0").String())
|
assert.Equal(t, "", TimeZone("UTC+0").String())
|
||||||
assert.Equal(t, "", TimeZone("UTC+00:00").String())
|
assert.Equal(t, "", TimeZone("UTC+00:00").String())
|
||||||
|
|||||||
Reference in New Issue
Block a user