Archived Forum Post

Index of archived forum posts

Question:

IMAP Date Format for Searching Email?

Jul 27 '12 at 15:30

I'm using Chilkat IMAP to search for messages on an IMAP server and I was wondering if I can assume that all IMAP servers search by US formatted date strings?

I had run into an issue where if my iPhone was set to a Japan locale and date format, that the search strings were getting localized to where the month came out with Japanese characters. I forced the date to be of the "en-US" format and everything worked again. I'm just worried about users with IMAP servers abroad that might be expecting a localized date for IMAP commands?


Answer

The answer is found by examining the RFC for the IMAP protocol, which would be RFC 3501 (http://www.ietf.org/rfc/rfc3501.txt)

In Section 6.4.4. (SEARCH Command), here is a snippet:

  
      SENTBEFORE <date>
         Messages whose [RFC-2822] Date: header (disregarding time and
         timezone) is earlier than the specified date.

SENTON <date>
         Messages whose [RFC-2822] Date: header (disregarding time and
         timezone) is within the specified date.

SENTSINCE <date>
         Messages whose [RFC-2822] Date: header (disregarding time and
         timezone) is within or later than the specified date.

SINCE <date>
         Messages whose internal date (disregarding time and timezone)
         is within or later than the specified date.

You would then look in the syntax specification (section 9) to see this:

date            = date-text / DQUOTE date-text DQUOTE

date-day        = 1*2DIGIT
                    ; Day of month

date-day-fixed  = (SP DIGIT) / 2DIGIT
                    ; Fixed-format version of date-day

date-month      = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" /
                  "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec"

date-text       = date-day "-" date-month "-" date-year

date-year       = 4DIGIT

date-time       = DQUOTE date-day-fixed "-" date-month "-" date-year
                  SP time SP zone DQUOTE

The date-month specifies us-EN names for months, so I would expect that all IMAP servers should only work with the en-US date format.