Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Countdown to 2000

Posted on 1999-01-09
6
Medium Priority
?
247 Views
Last Modified: 2010-04-06
I'm looking to code a 2000 countdown timer.
Do you have any design advice ?
Have I to use label component and thread ? Or what else ?
I use TDate  component. Then I calculate the days to the 1/1/2000 How can I print the TDate value as dd/mm/yy hh:mm:ss ? I try with DateToStr but it's a value like dd/mm/yy.
0
Comment
Question by:borgo
[X]
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
  • 3
  • 2
6 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1355527
Hmmm. I think it could be a small window with "formStyle:=fsStayOnTop" and either with a toolWindows borderStyle or with no border at all.
You could use a label component. But I would suggest a simple TTimer object to do the work. Normally you don't need a thread for this.
Then you could use the function DateTimeToSystemTime, which converts TDateTime to TSystemTime.
type
  TSystemTime = record
    wYear: Word;
    wMonth: Word;
    wDayOfWeek: Word;
    wDay: Word;
    wHour: Word;
    wMinute: Word;
    wSecond: Word;
    wMilliseconds: Word;
  end;
Then you can format the string yourself.

More questions? Please ask...  :-)

Regards, Madshi.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1355528
hi borgo,

in addition to madshi a year 2000 Countdown

procedure TForm1.Timer1Timer(Sender: TObject);
Var
  R : Real;
begin
  r := StrToDateTime('01/01/2000 00:00:00') - Now;
  Label1.caption := FloatToStr(Int(r)) + ' Days ' +TimeToStr(r);
end;

meikl
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1355529
Hi meikl, looks nice...  :-)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:borgo
ID: 1355530
Thank you Madshi.
But I find that the kretzschmar's answer is easier than yours.


0
 
LVL 20

Expert Comment

by:Madshi
ID: 1355531
No prob...
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 200 total points
ID: 1355532
Hi Borgo,
you can the year2000 also place in a constant

const
  Y2000 = 36526; {the Value of 01/01/2000 00:00:00}

procedure TForm1.Timer1Timer(Sender: TObject);
Var
  R : Real;
begin
  r := Y2000 - Now;
  Label1.caption := FloatToStr(Int(r)) + ' Days ' +TimeToStr(r);
end;

meikl
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

610 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