Solved

SystemTimeToDateTime

Posted on 2002-05-07
1
670 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
loading dll from external path 1 209
Delphi application Soap connection 5 94
Delphi IDE crash without error message ... 7 74
Firemonkey android show image from resource ? 1 30
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

930 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