diff options
author | Martin Czygan <martin.czygan@gmail.com> | 2021-07-27 03:26:10 +0200 |
---|---|---|
committer | Martin Czygan <martin.czygan@gmail.com> | 2021-07-27 03:26:10 +0200 |
commit | f60974d1e7a3ceceaa677e2c2faa40bfdbd78bb3 (patch) | |
tree | 093b18df1fb6c4852d16322a781e04b832dae9a4 | |
parent | 2039fb918048de9ea8a1a973d629719a60c3748c (diff) | |
download | refcat-f60974d1e7a3ceceaa677e2c2faa40bfdbd78bb3.tar.gz refcat-f60974d1e7a3ceceaa677e2c2faa40bfdbd78bb3.zip |
reduce: explicitly name magic numbers
-rw-r--r-- | skate/reduce.go | 11 |
1 files changed, 8 insertions, 3 deletions
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{} |