Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/jabber_util.c

    r2e3a857 r842cd8d  
    667667time_t jabber_get_timestamp( struct xt_node *xt )
    668668{
     669        struct tm tp, utc;
    669670        struct xt_node *c;
     671        time_t res, tres;
    670672        char *s = NULL;
    671         struct tm tp;
    672673       
    673674        for( c = xt->children; ( c = xt_find_node( c, "x" ) ); c = c->next )
     
    687688        tp.tm_year -= 1900;
    688689        tp.tm_mon --;
    689        
    690         return mktime_utc( &tp );
     690        tp.tm_isdst = -1; /* GRRRRRRRRRRR */
     691       
     692        res = mktime( &tp );
     693        /* Problem is, mktime() just gave us the GMT timestamp for the
     694           given local time... While the given time WAS NOT local. So
     695           we should fix this now.
     696       
     697           Now I could choose between messing with environment variables
     698           (kludgy) or using timegm() (not portable)... Or doing the
     699           following, which I actually prefer... */
     700        gmtime_r( &res, &utc );
     701        utc.tm_isdst = -1; /* Once more: GRRRRRRRRRRRRRRRRRR!!! */
     702        if( utc.tm_hour == tp.tm_hour && utc.tm_min == tp.tm_min )
     703                /* Sweet! We're in UTC right now... */
     704                return res;
     705       
     706        tres = mktime( &utc );
     707        res += res - tres;
     708       
     709        /* Yes, this is a hack. And it will go wrong around DST changes.
     710           BUT this is more likely to be threadsafe than messing with
     711           environment variables, and possibly more portable... */
     712       
     713        return res;
    691714}
    692715
Note: See TracChangeset for help on using the changeset viewer.