make n flag uint

This commit is contained in:
filifa 2024-03-19 20:31:32 -05:00
parent 270bf73b4d
commit a49301e826
1 changed files with 2 additions and 4 deletions

View File

@ -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)