Mercurial > lbo > hg > goe_bot
changeset 59:cf93059ce684
Fix small problem with displaying reminder time
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Sun, 11 Dec 2016 20:11:08 +0100 |
parents | 0799dfdec7d7 |
children | dd8acc733107 |
files | handler_remind.go |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/handler_remind.go Sun Dec 11 15:55:43 2016 +0100 +++ b/handler_remind.go Sun Dec 11 20:11:08 2016 +0100 @@ -126,6 +126,10 @@ return listReminders(ctx, msg.Chat.ID) } + // saving the time here, before alert time calculation, so "+10m" will be displayed as such, not as "0:09" because + // it technically is 9.999999 minutes. + now := time.Now() + // restStart is the index of the first character of the remaining text alertTime, restStart := parseReminderString(strings.Trim(msg.Text, " ")) @@ -155,9 +159,9 @@ return replyContent{text: "_Ich konnte leider keine Erinnerung setzen._"}, nil } - remaining := alertTime.Sub(time.Now()) + remaining := alertTime.Sub(now) hours := uint64(remaining.Seconds()) / 3600 - minutes := (uint64(remaining.Seconds()) % 3600) / 60 + minutes := (uint64(remaining.Seconds()+1) % 3600) / 60 return replyContent{text: fmt.Sprintf("*✓* Erinnerung #%d in %d:%02d", id, hours, minutes)}, nil }