Skip to content

Commit 587de94

Browse files
committed
Add year range filter: -start_year and -end_year
1 parent aa8ab90 commit 587de94

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

gcmap/main.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
package main
33

44
import (
5+
"flag"
56
"github.com/mrjones/oauth"
67
"github.com/seanrees/tripist/config"
78
"github.com/seanrees/tripist/tripit"
@@ -11,6 +12,11 @@ import (
1112
"strings"
1213
)
1314

15+
var (
16+
startYear = flag.Int("start_year", 0, "Only consider trips after (incusive) of start_year.")
17+
endYear = flag.Int("end_year", 9999, "Only consider trips before (inclusive) of end_year.")
18+
)
19+
1420
type byStartDate []tripit.Segment
1521

1622
func (a byStartDate) Len() int { return len(a) }
@@ -61,6 +67,8 @@ func main() {
6167
const configFilename = "user.json"
6268
const tripistConfigFilename = "tripist.json"
6369

70+
flag.Parse()
71+
6472
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
6573
log.SetOutput(os.Stderr)
6674

@@ -110,6 +118,11 @@ func main() {
110118
}
111119

112120
for _, trip := range tr.Trip {
121+
if sy, ey := trip.ActualStartDate.Year(), trip.ActualEndDate.Year(); sy < *startYear || ey > *endYear {
122+
log.Printf("Ignoring %q because starts/ends in %d/%d, want in [%d-%d]", trip.DisplayName, sy, ey, *startYear, *endYear)
123+
continue
124+
}
125+
113126
var segs []tripit.Segment
114127
for _, ao := range tr.AirObject {
115128
if ao.TripId == trip.Id {

0 commit comments

Comments
 (0)