From 6f578af5c158fd8d5c12d504316908e34cac996a Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Fri, 24 Feb 2023 16:15:43 +0100 Subject: [PATCH] Metadata: Add date string defaults to be ignored #3229 Signed-off-by: Michael Mayer --- pkg/txt/empty.go | 8 ++++---- pkg/txt/empty_test.go | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/pkg/txt/empty.go b/pkg/txt/empty.go index 86702241b..80d601221 100644 --- a/pkg/txt/empty.go +++ b/pkg/txt/empty.go @@ -41,13 +41,13 @@ func EmptyDateTime(s string) bool { // DateTimeDefault tests if the datetime string is not empty and not a default value. func DateTimeDefault(s string) bool { switch s { - case "1970-01-01", "1970-01-01 00:00:00": + case "1970-01-01", "1970-01-01 00:00:00", "1970:01:01 00:00:00": // Unix epoch. return true - case "1980-01-01", "1980-01-01 00:00:00": - // Common default. + case "1980-01-01", "1980-01-01 00:00:00", "1980:01:01 00:00:00": + // Windows default. return true - case "2002:12:08 12:00:00": + case "2002-12-08 12:00:00", "2002:12:08 12:00:00": // Android Bug: https://issuetracker.google.com/issues/36967504 return true default: diff --git a/pkg/txt/empty_test.go b/pkg/txt/empty_test.go index 9d14bfb35..0b3b5e196 100644 --- a/pkg/txt/empty_test.go +++ b/pkg/txt/empty_test.go @@ -154,9 +154,18 @@ func TestDateTimeDefault(t *testing.T) { t.Run("1970-01-01 00:00:00", func(t *testing.T) { assert.True(t, DateTimeDefault("1970-01-01 00:00:00")) }) + t.Run("1970:01:01 00:00:00", func(t *testing.T) { + assert.True(t, DateTimeDefault("1970:01:01 00:00:00")) + }) t.Run("1980-01-01 00:00:00", func(t *testing.T) { assert.True(t, DateTimeDefault("1980-01-01 00:00:00")) }) + t.Run("1980:01:01 00:00:00", func(t *testing.T) { + assert.True(t, DateTimeDefault("1980:01:01 00:00:00")) + }) + t.Run("2002-12-08 12:00:00", func(t *testing.T) { + assert.True(t, DateTimeDefault("2002-12-08 12:00:00")) + }) t.Run("2002:12:08 12:00:00", func(t *testing.T) { assert.True(t, DateTimeDefault("2002:12:08 12:00:00")) })