Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

SystemTimeToDateTime

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

861 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