Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: UIDSearchMailBox and date formats ?



Permlink Replies: 2 - Last Post: May 30, 2017 12:30 PM Last Post By: Asger Joergensen
Asger Joergensen

Posts: 370
Registered: 11/18/08
UIDSearchMailBox and date formats ?
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 30, 2017 11:05 AM
Hi Remy

Following your example I am using this code to retrieve the internal date
of the messages;

String sInternalDate;

if( FIdIMAP4->UIDRetrieveValue( sUID, "INTERNALDATE", sInternalDate ) )

I have tested on both one.com and on gmail.com and the resulting dates
look like this:
gmail:
13-May-2017 11:41:28 +0000
13-May-2017 11:41:28 +0000
one.com:
09-Sep-2012 09:18:38 +0000
20-Nov-2012 16:56:09 +0000

In other words exactly the same, but I have to translate that text into
TDateTime in order to use it with the TIdIMAP4SearchRec and that is not
going to be a problem.

But can I rely on the date-time format being the same on all IMAP mail
servers ?

If not, is there some kind of indy function to convert the different
date format into TDateTime ?

Thanks in advance
Best regards
Asger
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: UIDSearchMailBox and date formats ?
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 30, 2017 12:17 PM   in response to: Asger Joergensen in response to: Asger Joergensen
Asger Joergensen wrote:

Following your example I am using this code to retrieve the internal
date of the messages;

String sInternalDate;

if( FIdIMAP4->UIDRetrieveValue( sUID, "INTERNALDATE", sInternalDate
) )

I have tested on both one.com and on gmail.com and the resulting dates
look like this:

gmail:
13-May-2017 11:41:28 +0000
13-May-2017 11:41:28 +0000

one.com:
09-Sep-2012 09:18:38 +0000
20-Nov-2012 16:56:09 +0000

In other words exactly the same

The string representation of IMAP date/time values is defined in RFC
3501 Section 9:

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

time = 2DIGIT ":" 2DIGIT ":" 2DIGIT
; Hours minutes seconds

zone = ("+" / "-") 4DIGIT
; Signed four-digit value of hhmm representing
; hours and minutes east of Greenwich (that is,
; the amount that the given time differs from
; Universal Time). Subtracting the timezone
; from the given time will give the UT form.
; The Universal Time zone is "+0000".

but I have to translate that text into TDateTime

Try using Indy's StrInternetToDateTime() or GMTToLocalDateTime()
function for that.

But can I rely on the date-time format being the same on all IMAP
mail servers ?

Yes, per the definitions above.

--
Remy Lebeau (TeamB)
Asger Joergensen

Posts: 370
Registered: 11/18/08
Re: UIDSearchMailBox and date formats ?
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 30, 2017 12:30 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Hi Remy

Remy Lebeau (TeamB) wrote:

But can I rely on the date-time format being the same on all IMAP
mail servers ?

Yes, per the definitions above.

Super!
Thank you so much
Best regards
Asger
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02