make n flag uint
This commit is contained in:
parent
270bf73b4d
commit
a49301e826
6
main.go
6
main.go
|
@ -34,7 +34,7 @@ func formula(p float64) int64 {
|
|||
return int64(yearsAgo * 31556926)
|
||||
}
|
||||
|
||||
func (db *TimelineDB) closestEvents(t int64, n int, llimit int64, ulimit int64) ([]EventsRow, error) {
|
||||
func (db *TimelineDB) closestEvents(t int64, n uint, llimit int64, ulimit int64) ([]EventsRow, error) {
|
||||
query := `
|
||||
select description, timestamp, yearknown, monthknown, dayknown, hourknown, minuteknown, secondknown
|
||||
from events
|
||||
|
@ -95,15 +95,13 @@ func (event *EventsRow) Output() (int64, string, string, error) {
|
|||
|
||||
func main() {
|
||||
percent := flag.Float64("p", -1, "percentage")
|
||||
nevents := flag.Int("n", 1, "number of events")
|
||||
nevents := flag.Uint("n", 1, "number of events")
|
||||
after := flag.Bool("a", false, "only return events occurring after computed timestamp")
|
||||
before := flag.Bool("b", false, "only return events occurring before computed timestamp")
|
||||
flag.Parse()
|
||||
|
||||
if *percent < 0 || *percent > 1 {
|
||||
log.Fatal("invalid percentage")
|
||||
} else if *nevents < 0 {
|
||||
log.Fatal("number of events must be non-negative")
|
||||
}
|
||||
|
||||
t := time.Now().Unix() - formula(*percent)
|
||||
|
|
Loading…
Reference in New Issue