- Timestamp:
- 2010-04-08T00:27:42Z (15 years ago)
- Branches:
- master
- Children:
- 08579a1
- Parents:
- 91cec2f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/jabber_util.c
r91cec2f r2e3a857 667 667 time_t jabber_get_timestamp( struct xt_node *xt ) 668 668 { 669 struct tm tp, utc;670 669 struct xt_node *c; 671 time_t res, tres;672 670 char *s = NULL; 671 struct tm tp; 673 672 674 673 for( c = xt->children; ( c = xt_find_node( c, "x" ) ); c = c->next ) … … 688 687 tp.tm_year -= 1900; 689 688 tp.tm_mon --; 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; 689 690 return mktime_utc( &tp ); 714 691 } 715 692
Note: See TracChangeset
for help on using the changeset viewer.