Thanks Tom,

I now understand what the day-in-month format was all about. The MS
documentation does not expand on it's very brief description. Thanks for
your time.

regards,

Phil.
----- Original Message -----
From: "Tom Munro Glass" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Monday, March 19, 2001 2:34 PM
Subject: RE: [DUG]: Daylight savings


> The following code is not fully tested, but hopefully it will give you a
> starting point. Pass in the required year and StandardDate/DaylightDate
from
> TIME_ZONE_INFORMATION - it will hopefully return the correct absolute
date.
>
> function GetAbsoluteDate(ReqdYear: Word; SysTime: TSystemTime): TDate;
> var
>   AbsoluteDay, MaxDays, WeekDayofFirst: Integer;
> const
>   MaxDaysInMonth: array [1..12] of Word =
>     (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
> begin
>   with SysTime do
>   begin
>     WeekdayOfFirst := DayOfWeek(EncodeDate(ReqdYear, wMonth, 1)) - 1;
>     AbsoluteDay := WeekdayOfFirst - wDayOfWeek;
>     if AbsoluteDay < 0 then
>       Inc(AbsoluteDay, 7);
>
>     if wDay = 5 then
>     begin
>       if IsLeapYear(ReqdYear) and (wMonth = 2) then
>         MaxDays := 29
>       else
>         MaxDays := MaxDaysInMonth[wMonth];
>       while AbsoluteDay + 7 < MaxDays do
>         Inc(AbsoluteDay, 7);
>     end
>     else
>       Inc(AbsoluteDay, (wDay - 1) * 7);
>
>     Result := EncodeDate(ReqdYear, wMonth, AbsoluteDay);
>   end;
> end;
>
> HTH,
>
> Tom
>
>
> > Thanks for the reply Tom,
> >
> > For now I only need to get the time zone info for the location of the
> > computer. But, as mentioned, it is always returning the
> > informatino in the
> > TIME_ZONE_INFORMATION structure in day-in-month format
> > whereas I need it in
> > absolute format. Do you know how to get it to return in
> > absolute format?
> >
> > cheers,
> >
> > Phil.
>
> --------------------------------------------------------------------------
-
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
>

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to