Results 1 to 3 of 3

Thread: How to get a vaild mail time GMT?

  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default How to get a vaild mail time GMT?

    How to get a vaild mail time +0200 GMT or so....
    and not local LANG month day letter?

    this return Date: lun, 28 feb 2006 11:06:17 +0200 italian LANG...

    Qt Code:
    1. QString Smtp::TimeStampMail()
    2. {
    3. /* Date: Mon, 08 May 2006 17:57:52 +0200 */
    4. /* Date: Sun, 28 May 2006 06:32:25 -0420 */
    5. QDateTime dt = QDateTime::currentDateTime();
    6. QDate timecute;
    7. QString day_en = timecute.shortDayName(timecute.day());
    8. QString month_en = timecute.shortMonthName (timecute.month());
    9. QString last = dt.toString("yyyy hh:mm:ss");
    10. QString maildate = QString( "Date: %1, %2 %3 %4 +0200" ).arg( day_en , QString::number(timecute.day()), month_en , last );
    11. return maildate;
    12. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get a vaild mail time GMT?

    Please search the forum before you ask a question --- somebody had the same problem not so long ago. AFAIR you must switch locale to C or hardcode the month and day names.

  3. #3
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to get a vaild mail time GMT? rfc788

    OK this work on different mail client ....
    mail rtf Date format! http://www.faqs.org/rfcs/rfc788.html


    insert foof day 0 zero/null

    Qt Code:
    1. QStringList RTFdays = QStringList() << "foof" << "Mon" << "Tue" << "Wed" << "Thu" << "Fri" << "Sat" << "Sun";
    2. QStringList RTFmonth = QStringList() << "foof" << "Feb" << "Mar" << "Apr" << "May" << "Jun" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
    To copy to clipboard, switch view to plain text mode 




    Qt Code:
    1. int dateswap(QString form, uint unixtime )
    2. {
    3. QDateTime fromunix;
    4. fromunix.setTime_t(unixtime);
    5. QString numeric = fromunix.toString((const QString)form);
    6. bool ok;
    7. return (int)numeric.toFloat(&ok);
    8. }
    9.  
    10.  
    11. QString TimeStampMail()
    12. {
    13. /* mail rtf Date format! http://www.faqs.org/rfcs/rfc788.html */
    14. /* bybass qlocale Bug from window XP MUI */
    15. uint unixtime = (uint)time( NULL );
    16. QDateTime fromunix;
    17. fromunix.setTime_t(unixtime);
    18. QStringList RTFdays = QStringList() << "Mon" << "Tue" << "Wed" << "Thu" << "Fri" << "Sat" << "Sun";
    19. QStringList RTFmonth = QStringList() << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
    20. QDate timeroad(dateswap("yyyy",unixtime),dateswap("M",unixtime),dateswap("d",unixtime));
    21. /*qDebug() << "### RTFdays " << RTFdays.at(timeroad.dayOfWeek());
    22.   qDebug() << "### RTFmonth " << RTFmonth.at(dateswap("M",unixtime));
    23.   qDebug() << "### yyyy " << dateswap("yyyy",unixtime);
    24.   qDebug() << "### M " << dateswap("M",unixtime);
    25.   qDebug() << "### d " << dateswap("d",unixtime);*/
    26. QStringList rtfd_line;
    27. rtfd_line.clear();
    28. rtfd_line.append("Date: ");
    29. rtfd_line.append(RTFdays.at(timeroad.dayOfWeek()));
    30. rtfd_line.append(", ");
    31. rtfd_line.append(QString::number(dateswap("d",unixtime)));
    32. rtfd_line.append(" ");
    33. rtfd_line.append(RTFmonth.at(dateswap("M",unixtime)));
    34. rtfd_line.append(" ");
    35. rtfd_line.append(QString::number(dateswap("yyyy",unixtime)));
    36. rtfd_line.append(" ");
    37. rtfd_line.append(fromunix.toString("hh:mm:ss"));
    38. rtfd_line.append(" -0000");
    39. /*qDebug() << "### mail rtf Date format " << rtfd_line.join("");*/
    40. return QString(rtfd_line.join(""));
    41.  
    42. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by patrik08; 31st May 2006 at 21:43.

Similar Threads

  1. Opening the default mail client
    By munna in forum Newbie
    Replies: 5
    Last Post: 3rd April 2006, 13:58
  2. Replies: 6
    Last Post: 17th March 2006, 17:48
  3. Did you people get the unsolicited mail? - "Release of Makedoc"
    By jamadagni in forum General Discussion
    Replies: 5
    Last Post: 14th February 2006, 12:46
  4. Compiling time changes, and how!
    By GreyGeek in forum Qt Programming
    Replies: 2
    Last Post: 2nd February 2006, 13:19
  5. Problem with pointers while using localtime() and time()
    By jamadagni in forum General Programming
    Replies: 7
    Last Post: 11th January 2006, 15:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.