diff --git a/pkg/json.go b/pkg/json.go index 43e8d850723..608f969f169 100644 --- a/pkg/json.go +++ b/pkg/json.go @@ -18,6 +18,7 @@ import ( "encoding/json" "fmt" "io" + "time" "github.com/ossf/scorecard/v4/checker" docs "github.com/ossf/scorecard/v4/docs/checks" @@ -163,7 +164,7 @@ func (r *ScorecardResult) AsJSON2(showDetails bool, Version: r.Scorecard.Version, Commit: r.Scorecard.CommitSHA, }, - Date: r.Date.Format("2006-01-02"), + Date: r.Date.Format(time.RFC3339), Metadata: r.Metadata, AggregateScore: jsonFloatScore(score), } diff --git a/pkg/json_test.go b/pkg/json_test.go index 382c4d6efcc..b9836bb8323 100644 --- a/pkg/json_test.go +++ b/pkg/json_test.go @@ -73,7 +73,8 @@ func TestJSONOutput(t *testing.T) { scorecardCommit := "ccbc59901773ab4c051dfcea0cc4201a1567abdd" scorecardVersion := "1.2.3" repoName := "org/name" - date, e := time.Parse("2006-01-02", "2021-08-25") + date, e := time.Parse(time.RFC3339, "2023-03-02T10:30:43-06:00") + t.Logf("date: %v", date) if e != nil { panic(fmt.Errorf("time.Parse: %w", e)) } diff --git a/pkg/testdata/check1.json b/pkg/testdata/check1.json index d70f31d6779..6da954ce870 100644 --- a/pkg/testdata/check1.json +++ b/pkg/testdata/check1.json @@ -1,5 +1,5 @@ { - "date": "2021-08-25", + "date": "2023-03-02T10:30:43-06:00", "repo": { "name": "org/name", "commit": "68bc59901773ab4c051dfcea0cc4201a1567ab32" diff --git a/pkg/testdata/check2.json b/pkg/testdata/check2.json index fca375d0fbb..9b2dea7f461 100644 --- a/pkg/testdata/check2.json +++ b/pkg/testdata/check2.json @@ -1,5 +1,5 @@ { - "date": "2021-08-25", + "date": "2023-03-02T10:30:43-06:00", "repo": { "name": "org/name", "commit": "68bc59901773ab4c051dfcea0cc4201a1567ab32" diff --git a/pkg/testdata/check3.json b/pkg/testdata/check3.json index f23650f3f15..a8f632f6bad 100644 --- a/pkg/testdata/check3.json +++ b/pkg/testdata/check3.json @@ -1,5 +1,5 @@ { - "date": "2021-08-25", + "date": "2023-03-02T10:30:43-06:00", "repo": { "name": "org/name", "commit": "68bc59901773ab4c051dfcea0cc4201a1567ab32" diff --git a/pkg/testdata/check4.json b/pkg/testdata/check4.json index e7f060f00bb..5f8ede97980 100644 --- a/pkg/testdata/check4.json +++ b/pkg/testdata/check4.json @@ -1,5 +1,5 @@ { - "date": "2021-08-25", + "date": "2023-03-02T10:30:43-06:00", "repo": { "name": "org/name", "commit": "68bc59901773ab4c051dfcea0cc4201a1567ab32" diff --git a/pkg/testdata/check5.json b/pkg/testdata/check5.json index dde021ec99d..247387414cd 100644 --- a/pkg/testdata/check5.json +++ b/pkg/testdata/check5.json @@ -1,5 +1,5 @@ { - "date": "2021-08-25", + "date": "2023-03-02T10:30:43-06:00", "repo": { "name": "org/name", "commit": "68bc59901773ab4c051dfcea0cc4201a1567ab32" diff --git a/pkg/testdata/check6.json b/pkg/testdata/check6.json index 45abe90e451..4fb521450bc 100644 --- a/pkg/testdata/check6.json +++ b/pkg/testdata/check6.json @@ -1,5 +1,5 @@ { - "date": "2021-08-25", + "date": "2023-03-02T10:30:43-06:00", "repo": { "name": "org/name", "commit": "68bc59901773ab4c051dfcea0cc4201a1567ab32"