OK, sounds great, but please don't CC me directly in list discussions!

Geo, would you this up as a patch against current dbmail_2_0_branch SVN?

Aaron


On Wed, May 11, 2005, Geo Carncross <[EMAIL PROTECTED]>
said:

> Let's fix this right: strptime() isn't POSIX, nor is it especially
> common. Worse: some platforms support strptime incorrectly (as per XPG5-
> notably some versions of OpenVMS)
> 
> Even worse: It isn't needed. Better to rewrite with sscanf().
> 
> Consider:
> 
>       struct tm tm;
> 
>       if (sscanf(sqldate, "%d-%d-%d %d:%d:%d",
>               &tm.tm_year, &tm.tm_mon, &tm.tm_mday,
>               &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) { /*err...*/
> 
> And fixing up:
>       if (tm.tm_year < 60) tm.tm_year += 2000;
>       else if (tm.tm_year < 1000) tm.tm_year += 1900;
>       tm.tm_mon--;
> 
> And finally:
>       char *mon[12] = { "Jan","Feb","Mar",... };
>       sprintf(out, "%02d-%s-%04d +0000", tm.tm_mday, mon[tm.tm_mon],
> tm.tm_year);
> 
> 
> I'd really recommend mandating that the [SQL] server store UTC. Using
> time zones other than +0000 definitely cause problems with many C
> libraries and email clients-- even when they can do conversion into
> local.
> 
> Outlook Express is a big loser here...
> 
> 
> 
> On Wed, 2005-05-11 at 13:20 -0700, Chris Reichow wrote:
>> This is really in reply to Aaron's last email regarding 2.0.5, but I 
>> just joined the list 5 seconds ago, so I don't have a copy. =(
>> 
>> Bug 193:
>> http://www.dbmail.org/mantis/bug_view_advanced_page.php?bug_id=0000193
>> 
>> dbmail will not compile on FreeBSD without editing imaputil.c and 
>> reverting back to a tm_gmtoff type solution. I manually edited this to 
>> compile yesterday, but I am not well-versed in cross platform 
>> development and I have no idea if it would compile in Linux, etc.
>> 
>> Here is my interim solution if anyone is interested. Not the prettiest, 
>> but it gets the job done.
>> 
>> char *date_sql2imap(const char *sqldate)
>> {
>>         time_t temp = time(0);
>>         struct tm *tms = localtime(&temp);
>> 
>>         long gmt_offset=0;
>>         struct tm tm_sql_date;
>>         char *last;
>> 
>>         /* defined by tzset */
>>         //extern long timezone;
>>         //timezone=0;
>>         //tzset();
>> 
>>         last = strptime(sqldate,"%Y-%m-%d %T", &tm_sql_date);
>>         if ( (last == NULL) || (*last != '\0') ) {
>>                 trace(TRACE_DEBUG, "%s,%s, error parsing date [%s]",
>>                       __FILE__, __func__, sqldate);
>>                 strcpy(_imapdate, IMAP_STANDARD_DATE);
>>                 return _imapdate;
>>         }
>> 
>>         gmt_offset = (-tms->tm_gmtoff)/3600;
>>         if (tm_sql_date.tm_isdst)
>>                 gmt_offset++;
>> 
>>         snprintf(_imapdate,IMAP_INTERNALDATE_LEN,"%s %c%02ld00",
>>                         sqldate,
>>                         (gmt_offset >= 0 ? '+': '-'),
>>                         gmt_offset);
>>         return _imapdate;
>> }
>> 
>> 
>> _______________________________________________
>> Dbmail-dev mailing list
>> Dbmail-dev@dbmail.org
>> http://twister.fastxs.net/mailman/listinfo/dbmail-dev
> -- 
> Internet Connection High Quality Web Hosting
> http://www.internetconnection.net/
> 
> _______________________________________________
> Dbmail-dev mailing list
> Dbmail-dev@dbmail.org
> http://twister.fastxs.net/mailman/listinfo/dbmail-dev
> 

-- 



Reply via email to