From: Art on 24 Jul 2008 10:51 Hi, I need help in time conversion from one time zone to another programmatically. For e.g With Local Time zone as (GMT -5:00) US Eastern time I want to convert time 29 Mar 2008 00:00:00 on TimeZone(GMT+1:00) into UTC. I tried first converting the time into time_t using mktime, but time_t uses local timezone and I could not find any API wherein I can specify time as well as timezone. Thanks in advance, Art
From: Igor Tandetnik on 24 Jul 2008 11:04 Art <artami2006(a)gmail.com> wrote: > I need help in time conversion from one time zone to another > programmatically. > For e.g With Local Time zone as (GMT -5:00) US Eastern time I want to > convert time 29 Mar 2008 00:00:00 on TimeZone(GMT+1:00) into UTC. If you know it's GMT+1:00, can't you just subtract one hour? Then call mktime - it will normalize out-of-range values. Ignore the time_t return value, you are calling mktime only for the side effect. -- With best wishes, Igor Tandetnik With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
From: Art on 24 Jul 2008 11:17 During DST transitions, I guess just substracting one hour may not work. Is there any way to get the info from OS. On Jul 24, 8:04 pm, "Igor Tandetnik" <itandet...(a)mvps.org> wrote: > Art <artami2...(a)gmail.com> wrote: > > I need help in time conversion from one time zone to another > > programmatically. > > For e.g With Local Time zone as (GMT -5:00) US Eastern time I want to > > convert time 29 Mar 2008 00:00:00 on TimeZone(GMT+1:00) into UTC. > > If you know it's GMT+1:00, can't you just subtract one hour? Then call > mktime - it will normalize out-of-range values. Ignore the time_t return > value, you are calling mktime only for the side effect. > -- > With best wishes, > Igor Tandetnik > > With sufficient thrust, pigs fly just fine. However, this is not > necessarily a good idea. It is hard to be sure where they are going to > land, and it could be dangerous sitting under them as they fly > overhead. -- RFC 1925
From: Doug Harrison [MVP] on 24 Jul 2008 11:19 On Thu, 24 Jul 2008 07:51:09 -0700 (PDT), Art <artami2006(a)gmail.com> wrote: >Hi, > >I need help in time conversion from one time zone to another >programmatically. >For e.g With Local Time zone as (GMT -5:00) US Eastern time I want to >convert time 29 Mar 2008 00:00:00 on TimeZone(GMT+1:00) into UTC. > >I tried first converting the time into time_t using mktime, but >time_t uses local timezone and I could not find any API wherein I can >specify time as well as timezone. You might be able to use _tzset for this. Also, you might consider using the Windows FILETIME/SYSTEMTIME instead of time_t/struct tm. The Windows API provides functions like TzSpecificLocalTimeToSystemTime, which allow you to specify the time zone for the local time. -- Doug Harrison Visual C++ MVP
From: Igor Tandetnik on 24 Jul 2008 11:29 Art <artami2006(a)gmail.com> wrote: > During DST transitions, I guess just substracting one hour may not > work. GMT+1:00 is, by definition, one hour ahead of UTC regardless of DST. It is possible that some jurisdiction is in GMT+1:00 in winter and in GMT+2:00 in summer. Is that what you mean? Then you need to specify timezone in some geographical way, not by a GMT offset. > Is there any way to get the info from OS. You mean, the information on the DST rules of a particular jurisdiction? Not with a public API, as far as I can tell. This information is stored in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones in an undocumented format (which, reportedly, has changed between XP and Vista). -- With best wishes, Igor Tandetnik With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
|
Pages: 1 Prev: WinHttpOpen while using using a Proxy Next: how to use typedef'd functions |