Re: A question for someone with experience of early MFC and CTime

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Paul Smith (paulsmith_at_voiceperfect.co.uk)
Date: 03/08/04


Date: Mon, 8 Mar 2004 17:13:17 +0000 (UTC)

I have a thunking DLL and have managed to get the correct GMT time via a 32
bit DLL.

I have noticed that the function

gmtime

retrieves the Greenwich Mean Time and it is up to you to add/subtract your
region's offset from GMT zero.

Which is what you would expect, however

localtime

is supposed to retrieve your system's local time (as I understand the
documentation). However it is always retrieving GMT - 8 hours (i.e. Pacific
time) regardless of what Time Zone you set Windows to be in. Shouldn't the
localtime function consult the Time Zone setting of windows and retrieve
your "local" time?

Thus, I would have thought that if you are in London then the value for
gmtime should be equal to that of localtime (however this is not the case)?

Any thoughts?

Paul

"Frank Hickman" <fhickman_nosp@m_noblesoft.com> wrote in message
news:8PKdnQ85gvOxMNXdRVn-sw@comcast.com...
> Yeah you could but you would need to write a 16 to 32 bit thunk layer,
allot
> of work for something so...small :)
>
> --
> Frank
>
> "Paul Smith" <paulsmith@voiceperfect.co.uk> wrote in message
> news:c29ovu$sq1$1@sparta.btinternet.com...
> > Thanks for that.
> >
> > There is a lot of code to port is all so I was looking for a quicker
fix.
> >
> > Perhaps I could write a 32 bit DLL which can call GetCurrentTime and
then
> > expose a function to get the time for my 16 bit app?
> >
> >
> > "Frank Hickman" <fhickman_nosp@m_noblesoft.com> wrote in message
> > news:Nt6dnZUo_P7I-dXdRVn-hw@comcast.com...
> > > I think your kinda correct on your assumption but I believe it's the
WOW
> > > executive that is causing this behavior which this app will always
need
> > > since it's a 16-bit app. Any particular reason not to port it?
> > >
> > > --
> > > Frank
> > >
> > > "Paul Smith" <paulsmith@voiceperfect.co.uk> wrote in message
> > > news:c29gc6$rg1$1@titan.btinternet.com...
> > > > The CTime class is a wrapper round the standard C library time
> > functions.
> > > >
> > > > GetCurrentTime actually resutls in a call to time(NULL)
> > > >
> > > > I think the problem must be in how the old C runtime library
> calculates
> > > > time. I think it must initially consult the system clock for the
> start
> > > time
> > > > when the program starts and then simply apply a tick count algorithm
> of
> > > its
> > > > own from that point on.
> > > >
> > > > Short of porting the project to a newer version of the C runtime I'm
> not
> > > > sure what else I can do here.
> > > >
> > > > Anyone have any ideas at all?
> > > >
> > > > Best Regards
> > > >
> > > > Paul
> > > >
> > > > "David Crow [MCSD]" <david.nospam.crow@pbsnow.nospam.com> wrote in
> > message
> > > > news:YQK1c.26549$j52.7089@newssvr24.news.prodigy.com...
> > > > > Can you eliminate MFC from the equation and just use the raw
> > > time-related
> > > > > functions? That might help narrow down a solution.
> > > > >
> > > > > "Paul Smith" <paulsmith@voiceperfect.co.uk> wrote in message
> > > > > news:c27pkv$ifn$1@titan.btinternet.com...
> > > > > > Hi
> > > > > >
> > > > > > I am currently in a situation whereby I am supporting a product
> > > written
> > > > > > using Visual C++ 1.52 and the accompanying MFC classes.
> > > > > >
> > > > > > I am using the CTime class to get the current time each second
and
> > > later
> > > > > > format it into a string for display as a clock (I use
> GetCurrentTime
> > > for
> > > > > > this).
> > > > > >
> > > > > > However I have noticed that when I alter the Windows system
clock
> my
> > > > > > resulting CTime object does not pick up the change unless I
> restart
> > my
> > > > > > program.
> > > > > >
> > > > > > I imagine that my program probably won't handle the situation
when
> > > > windows
> > > > > > auto adjusts for daylight savings changes.
> > > > > >
> > > > > > The version of the MFC libraries I have don't know what
SYSTEMTIME
> > is.
> > > > > >
> > > > > > I am running this on Windows XP SP1.
> > > > > >
> > > > > > When using Visual C++ .Net 2002 the CTime object reacts
> dynamically
> > to
> > > > > > changes in the windows system clock as you would expect.
> > > > > >
> > > > > > I have looked into the class code for CTime in the old MFC code
> and
> > it
> > > > > > appears to just be a wrapper round the time_t structure.
> > > > > >
> > > > > > Can anyone enlighten me as to why the old MFC class doesn't
> > > dynamically
> > > > > > adjust for changes in the system clock?
> > > > > >
> > > > > > Is anyone aware of a workaround for this baring in mind that I
> > cannot
> > > > port
> > > > > > the application to a newer version of MFC.
> > > > > >
> > > > > > Thanks in advance for ANY help anyone can give me on this
matter.
> > > > > >
> > > > > > Paul
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>