From f60974d1e7a3ceceaa677e2c2faa40bfdbd78bb3 Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Tue, 27 Jul 2021 03:26:10 +0200 Subject: reduce: explicitly name magic numbers --- skate/reduce.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'skate') diff --git a/skate/reduce.go b/skate/reduce.go index 9527974..e03bea1 100644 --- a/skate/reduce.go +++ b/skate/reduce.go @@ -35,8 +35,13 @@ import ( "github.com/segmentio/encoding/json" ) -// timeNow is used for mocking time in tests. -var timeNow = time.Now +var ( + // timeNow is used for mocking time in tests. + timeNow = time.Now + // a few sane dates to accept + minDate = 1500 + maxDate = time.Now().AddDate(5, 0, 0).Year() +) // groupLogf logs a message alongsize a serialized group for debugging. func groupLogf(g *zipkey.Group, s string, vs ...interface{}) { @@ -584,7 +589,7 @@ func matchedRefsExtend(matched []*BiblioRef, refs []*Ref, stats *statsAugment) [ isbn = r.Biblio.Extra.ISBN[0] } // TODO: need to update this "max year" number frequently? - if r.Biblio.Year > 1500 && r.Biblio.Year <= 2025 { + if r.Biblio.Year > minDate && r.Biblio.Year <= maxDate { issued = &CSLDate{Parts: [][]int{{int(r.Biblio.Year)}}} } else { issued = &CSLDate{} -- cgit v1.2.3