implement the WITHIN IMAP extension, rfc 5032

for IMAP "SEARCH" command criteria "YOUNGER" and "OLDER".
This commit is contained in:
Mechiel Lukkien
2025-02-19 21:29:14 +01:00
parent dcaa99a85c
commit 5e4d80d48e
6 changed files with 23 additions and 5 deletions

View File

@ -5,6 +5,7 @@ import (
"log/slog"
"net/textproto"
"strings"
"time"
"github.com/mjl-/bstore"
@ -539,6 +540,13 @@ func (s *search) match0(sk searchKey) bool {
// mailboxes, but we only have this metadata from the time we implemented this
// feature.
return s.m.SaveDate != nil
case "OLDER":
// ../rfc/5032:76
seconds := int64(time.Since(s.m.Received) / time.Second)
return seconds >= sk.number
case "YOUNGER":
seconds := int64(time.Since(s.m.Received) / time.Second)
return seconds <= sk.number
}
if s.p == nil {