I didn\'t find a trivial way to get the time offset in minutes between the local time and the UTC time.
At first I intended to use tzset()
but it doesn\'t p
I would like to submit yet another answer to this question, one that AFAICS also deals with the IDL.
This solution depends on timegm
and mktime
. On Windows timegm
is available as _mkgmtime
from the CRT, in other words define a conditional macro.
#if _WIN32
# define timegm _mkgmtime
#endif
int local_utc_offset_minutes ( ) {
time_t t = time ( NULL );
struct tm * locg = localtime ( &t );
struct tm locl;
memcpy ( &locl, locg, sizeof ( struct tm ) );
return (int)( timegm ( locg ) - mktime ( &locl ) ) / 60;
}