Re: Converting from GMT

Tech-Archive recommends: Speed Up your PC by fixing your registry



You can call GetTimeZoneInformation(...) to get the difference between local
time and UTC (GMT)

or you can use CTime so you can get the difference

CTime time(CTime::GetCurrentTime());
tm t1 = *(time.GetLocalTm());
tm t2 = *(time.GetGmtTm());

TRACE("Difference between local time and GMT is %d hours.\n",
t1.tm_hour - t2.tm_hour);

AliR.

"Ken" <Ken@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:03CA8376-6033-4CEB-AE68-3639E2574531@xxxxxxxxxxxxxxxx
> I must be missing something as this would seem obvious, but what is the
API
> call to get the current GMT offset?
>
> I have a date that is GMT. I use a COleDateTime object to format the
> date/time for the user in their preferred format. However, COleDateTime is
> ignorant of DST or GMT. However, CTime apparently deals with GMT but has
> lower resolution and is not as nice to work with for formatting.
>
> I think my preferred method would be to add/subtract the GMT offset to the
> COleDateTime object, but I'm not quite sure what API to call to get the
> offset.
>
>


.



Relevant Pages

  • Re: How to get a CTime from a string
    ... Here is a function I use for a very specific date format. ... parsing it manually, but it might give you some ideas. ... // Converts a char string US date to a CTime. ...
    (microsoft.public.vc.mfc)
  • Re: Using a files modification date in the filename
    ... I want the renamed file to be named 20060401-testme.txt ... What I can do is get the modification date using ctime, ... figure out how to format the output. ...
    (comp.lang.perl.misc)
  • Re: passing variable number of arguments to a function
    ... your own with sprintf() and localtime. ... I wrote a wrapper function to print the ctime() without newline. ... I don't like the format of the string ...
    (comp.lang.c)
  • Re: syslog
    ... In the last episode, Eugene Grosbein said: ... ctime returns a date in the format: ... Dan Nelson ...
    (freebsd-hackers)