Skip to content

Commit

Permalink
fallback to cron style when parsing dates.
Browse files Browse the repository at this point in the history
The cron output was never updated in ossf#2712. In the interim, support both formats.

Signed-off-by: Spencer Schrock <sschrock@google.com>
  • Loading branch information
spencerschrock committed Oct 16, 2023
1 parent b9bbb82 commit f7a0b3c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package pkg

import (
"encoding/json"
"errors"
"fmt"
"io"
"time"
Expand Down Expand Up @@ -185,7 +186,11 @@ func ExperimentalFromJSON2(r io.Reader) (result ScorecardResult, score float64,
return ScorecardResult{}, 0, fmt.Errorf("decode json: %w", err)
}

var parseErr *time.ParseError
date, err := time.Parse(time.RFC3339, jsr.Date)
if errors.As(err, &parseErr) {
date, err = time.Parse("2006-01-02", jsr.Date)
}
if err != nil {
return ScorecardResult{}, 0, fmt.Errorf("parse scorecard analysis time: %w", err)
}
Expand Down

0 comments on commit f7a0b3c

Please sign in to comment.