aboutsummaryrefslogtreecommitdiffstats
path: root/skate
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2021-07-27 03:26:10 +0200
committerMartin Czygan <martin.czygan@gmail.com>2021-07-27 03:26:10 +0200
commitf60974d1e7a3ceceaa677e2c2faa40bfdbd78bb3 (patch)
tree093b18df1fb6c4852d16322a781e04b832dae9a4 /skate
parent2039fb918048de9ea8a1a973d629719a60c3748c (diff)
downloadrefcat-f60974d1e7a3ceceaa677e2c2faa40bfdbd78bb3.tar.gz
refcat-f60974d1e7a3ceceaa677e2c2faa40bfdbd78bb3.zip
reduce: explicitly name magic numbers
Diffstat (limited to 'skate')
-rw-r--r--skate/reduce.go11
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{}