Hi Kevin,

Thank you for the kind insight. But, what my problem really is, is how to 
extract the timezone setting from the user's local machine and translate it in 
human language. I believe that the MS TimeZoneInfo class can be the answer to 
that but I have been breaking my neck over trying to translate the VB example 
they provide, into Pascal code.

Emmanuel


--- In delphi-en@yahoogroups.com, "jumpsfromplanes" <kgmcco...@...> wrote:
>
> A Delphi TDateTime variable is actually a double precision number, with the 
> whole number part representing the elapsed days since (I think) 31 December 
> 1899, and the fractional part representing the time. The time is a fraction 
> expressed as N/24 where N is in hours. 
> 
> Example:
> 
> If the time is 23:30, then N=23.5; 
> 
> 23.5/24.0 = 0.9791666666666667
> 
> So 1.9791666666666667 = 23:30:00 on 1 Jan 1900.
> 
> So if you want to subtract 8 hours, you actually have to subtract "eight 
> twentyfourths" or
> 
> UTC := PacificTime - (8.0 / 24.0);
> 
> Subtracting 8 from Pacific time would result in the same time, but 8 *days* 
> before!
> 
> You can use the SysUtils.EncodeTime function to do the fractions for you. In 
> the context of UTC conversion, it might be easier to do the fractions 
> yourself, since you usually don't need minutes, and certainly don't need 
> seconds and milliseconds.
> 
> Doing it yourself also allows you to use positive and negative hour offsets. 
> EncodeTime only works on positive hour/min/sec/msec values.
> 
> Positive and negative offsets are used in time conversion.
> 
> HTH,
> 
> Kevin G. McCoy
> 
> --- In delphi-en@yahoogroups.com, "Glenn B. Lawler" <gblawler@> wrote:
> >
> > Emmanuel,
> > 
> > > Does anyone know of a free component that converts the local time to UTC
> > and back to another time zone local time?
> > 
> > I am not sure what your application is for these converted times, or what
> > time structure you are using. If you are talking about TDateTime, changing
> > from one timezone to another is simply a matter of subtracting your UTC
> > offset. For example, US Pacific time is -8, so you subtract -8 from the
> > current time to calculate UTC time. If it is 1 AM minus -8 is 9 AM. To
> > convert from UTC time to another local time, just add the offset. Since
> > TDateTime is a numeric (double) type, you can just calculate the number.
> > 
> > If you are talking about file times, there are Windows API calls available.
> > GetFileTime returns the CreationTime, LastAccessTime, and LastWriteTime for
> > an open file handle. These times are UTC times, if the file system is NTFS.
> > FileTimeToLocalFileTime converts a UTC file time to the local time of the
> > machine.
> > 
> > If you tell me more about what you are trying to do with these times, I can
> > tell you specifically how I would handle the situation. 
> > 
> > Glenn Lawler
> > www.incodesystems.com
> >
>


Reply via email to