Solved

SystemTimeToDateTime

Posted on 2002-05-07
1
668 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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

771 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

10 Experts available now in Live!

Get 1:1 Help Now