Skip to content

Commit

Permalink
⚠️ Update date formats and fields to RFC3339 (#2712)
Browse files Browse the repository at this point in the history
- Update date format in multiple files from `YYYY-MM-DD` to `YYYY-MM-DDTHH:MM:SS-TZ`
- Update date from `2021-08-25` to `2023-03-02T10:30:43-06:00`
- Change date format from `2006-01-02` to `time.RFC3339`
- Add `time` import
- Update ScorecardResult

[pkg/testdata/check2.json]
- Change the date format from `YYYY-MM-DD` to `YYYY-MM-DDTHH:MM:SS-TZ`
[pkg/testdata/check1.json]
- Update date from `2021-08-25` to `2023-03-02T10:30:43-06:00`
[pkg/testdata/check3.json]
- Update the date field in `check3.json` from `2021-08-25` to `2023-03-02T10:30:43-06:00`
[pkg/testdata/check5.json]
- Update date in `check5.json` from 2021-08-25 to 2023-03-02T10:30:43-06:00
[pkg/json_test.go]
- Change date format from `2006-01-02` to `time.RFC3339`
- Update date from `2021-08-25` to `2023-03-02T10:30:43-06:00`
[pkg/testdata/check6.json]
- Change date from "2021-08-25" to "2023-03-02T10:30:43-06:00"
[pkg/json.go]
- Change the date format from "2006-01-02" to RFC3339
- Add "time" import
- Update the ScorecardResult struct to include the CommitSHA field
[pkg/testdata/check4.json]
- Update date from `2021-08-25` to `2023-03-02T10:30:43-06:00`
- Update commit from `68bc59901773ab4c051dfcea0cc4201a1567ab32`

Signed-off-by: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com>
  • Loading branch information
naveensrinivasan authored Mar 2, 2023
1 parent 8add330 commit c4bd0c5
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion pkg/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"encoding/json"
"fmt"
"io"
"time"

"github.com/ossf/scorecard/v4/checker"
docs "github.com/ossf/scorecard/v4/docs/checks"
Expand Down Expand Up @@ -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),
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/testdata/check1.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"date": "2021-08-25",
"date": "2023-03-02T10:30:43-06:00",
"repo": {
"name": "org/name",
"commit": "68bc59901773ab4c051dfcea0cc4201a1567ab32"
Expand Down
2 changes: 1 addition & 1 deletion pkg/testdata/check2.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"date": "2021-08-25",
"date": "2023-03-02T10:30:43-06:00",
"repo": {
"name": "org/name",
"commit": "68bc59901773ab4c051dfcea0cc4201a1567ab32"
Expand Down
2 changes: 1 addition & 1 deletion pkg/testdata/check3.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"date": "2021-08-25",
"date": "2023-03-02T10:30:43-06:00",
"repo": {
"name": "org/name",
"commit": "68bc59901773ab4c051dfcea0cc4201a1567ab32"
Expand Down
2 changes: 1 addition & 1 deletion pkg/testdata/check4.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"date": "2021-08-25",
"date": "2023-03-02T10:30:43-06:00",
"repo": {
"name": "org/name",
"commit": "68bc59901773ab4c051dfcea0cc4201a1567ab32"
Expand Down
2 changes: 1 addition & 1 deletion pkg/testdata/check5.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"date": "2021-08-25",
"date": "2023-03-02T10:30:43-06:00",
"repo": {
"name": "org/name",
"commit": "68bc59901773ab4c051dfcea0cc4201a1567ab32"
Expand Down
2 changes: 1 addition & 1 deletion pkg/testdata/check6.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"date": "2021-08-25",
"date": "2023-03-02T10:30:43-06:00",
"repo": {
"name": "org/name",
"commit": "68bc59901773ab4c051dfcea0cc4201a1567ab32"
Expand Down

0 comments on commit c4bd0c5

Please sign in to comment.