From fc6b6a9c6b204c6bb5def8d7a2db8fc0c6960669 Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Tue, 23 Mar 2021 16:10:25 +0000 Subject: [PATCH] Fix time parser for "ZZ" prefix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I think this means UTC-08:00, but this just strips it since time handling is pretty naïve already. --- mail/welcome.txt | 1 + mediabrowser/models.go | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/mail/welcome.txt b/mail/welcome.txt index e7e83c6..52f5f4b 100644 --- a/mail/welcome.txt +++ b/mail/welcome.txt @@ -3,6 +3,7 @@ {{ .youCanLoginWith }}: {{ .jellyfinURLString }}: {{ .jellyfinURL }} + {{ .usernameString }}: {{ .username }} diff --git a/mediabrowser/models.go b/mediabrowser/models.go index 2b7afdd..58dfd0c 100644 --- a/mediabrowser/models.go +++ b/mediabrowser/models.go @@ -20,7 +20,13 @@ func (t *Time) UnmarshalJSON(b []byte) (err error) { str := strings.TrimSuffix(strings.TrimPrefix(string(b), "\""), "\"") // Trim nanoseconds to always have 6 digits, so overall length is always the same. if str[len(str)-1] == 'Z' { - str = str[:26] + "Z" + if str[len(str)-2] == 'Z' { + /* From #69, "ZZ" is sometimes used, meaning UTC-8:00. + TZ doesn't really matter to us, so we'll pretend it's UTC. */ + str = str[:25] + "0Z" + } else { + str = str[:26] + "Z" + } } else { str = str[:26] } @@ -39,7 +45,7 @@ func (t *Time) UnmarshalJSON(b []byte) (err error) { return } fmt.Println("THIRDERR", err) - // magic method + // if all else fails, just do whatever would usually be done. // some stored dates from jellyfin have no timezone at the end, if not we assume UTC if str[len(str)-1] != 'Z' { str += "Z"