purebred-mua / hs-notmuch

Modern Haskell binding to the Notmuch mail indexer
11 stars 2 forks source link

Headers with dates should return a parsed date type #3

Closed romanofski closed 7 years ago

romanofski commented 7 years ago

In order to display something meaningful, hs-notmuch should parse date headers as date types.

frasertweedale commented 7 years ago

what type do you want?

romanofski commented 7 years ago

Can it be a UTCTime?

frasertweedale commented 7 years ago

notmuch API provides time_t notmuch_message_get_date(notmuch_message_t *message);.

This avoids parsing the message but is a loss of information w.r.t. the mail itself (the Date header usually contains a TZ offset).

Nevertheless the UTCTime is appropriate for sorting and other basic operations we might want to do without parsing the message.

So I think we want both: a function Message -> IO UTCTime, and a function ParsedMessage -> ZonedTime.

I'm still weighing up whether to go with the time library or something else (e.g. thyme).

frasertweedale commented 7 years ago

Oh right, but this an hs-notmuch ticket so we just need Message -> IO UTCTime 👍

frasertweedale commented 7 years ago

notes:

frasertweedale commented 7 years ago

I'm still a bit conflicted about exposing date as a UTCTime given that this is a loss of information from what is in the headers, i.e. we really want to encourage lib users to handle the date header parsed from the message itself, instead.

Anyhow, here it is.

romanofski commented 7 years ago

Thinking about it more, I realise the problem you're describing. Thinking back to my typical use case (can't use anything else atm), the index in mutt only shows a rough date (e.g. 28/Jun) while the specific date is displayed when you view the mail.

Keeping that in mind, perhaps there is no real case for the specific time to be displayed. I don't know if it could lead to problems when querying tho. I guess we'll see and change it if need arises?

frasertweedale commented 7 years ago

On Thu, Jul 27, 2017 at 02:55:39AM +0000, Roman Joost wrote:

I guess we'll see and change it if need arises?

Yep.