Solved

SystemTimeToDateTime

Posted on 2002-05-07
1
675 Views
Last Modified: 2012-06-21
It's 4:20 in the morning, and this is really annoying me.  Calling this function produces a debugger exception notification with the following error message:

"Invalid argument to date encode."

The problem line is the call to SystemTimeToDateTime, though I don't see why.  TZSystem.StandardDate is a _SYSTEMTIME, and SystemTimeToDateTime wants a _SYSTEMTIME, so what's the problem?

procedure ProcedureName;
var
  TZSystem: TTimeZoneInformation;
  DateTime: TDateTime;
begin
  GetTimeZoneInformation(TZSystem);

  DateTime := SystemTimeToDateTime(TZSystem.StandardDate);
end;

Brian
0
Comment
Question by:Traal
1 Comment
 
LVL 8

Accepted Solution

by:
TOndrej earned 50 total points
ID: 6993502
Read the documentation of GetTimeZoneIformation.
StandardDate is not really a valid _SYSTEMTIME. It's purpose is to specify when the transition from daylight saving time to standard time occurs, using a special notation.
First of all, it may not even be specified, in which case wMonth = 0.
If it is specified, then wYear = 0, wDayOfWeek contains the day of week, wDay contains a value in the range 1 - 5 (1 meaning the first wDayOfWeek, 5 meaning the last).
For example:
wYear = 0, wMonth = 4, wDayOfWeek = 0, wDay = 1
would mean "first Sunday in April".

The other members of the structure are IMHO undefined and not used.

HTH
TOndrej
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now