Solved

Using KOL library

Posted on 2001-08-22
9
176 Views
Last Modified: 2010-04-06
Can anyone help me with date n time function using KOL library.

Basicly I want to print the current datetime as a string and secondly would like to return the minutes past the hour as a integer.

Hope you guys can help.

KOL homepage http://xcl.cjb.net
0
Comment
Question by:campid
[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
  • 3
  • 2
  • +1
9 Comments
 
LVL 5

Expert Comment

by:Gwena
ID: 6415191
I know that 'now' returns the current date/time as a double .. maybe you can derive the data you need from this value..

function Now: TDateTime;
Returns local date and time on running PC.


type TDateTime = Double;
Basic date and time type. Integer part represents year and day (as is, i.e. 1-Jan-2000 is representing by value 730141, which is a number of days from 1-Jan-0001 to 1-Jan-2000 inclusively). Fractional part is representing hours, minutes, seconds and milliseconds of a day proportionally (like in VCL TDateTime type).

running this line
showmessage(Double2Str(now));
returns 730719.599368055826

There must be an easier way to do this...but you should be able to write some code to get the data you need  :-)

-->KOL suffers greatly from a lack of example code... :-/
0
 

Author Comment

by:campid
ID: 6415713
Don't I know it. They need someone to write a helpfile with a list of all functions and how to use um.

Its a great piece of kit though

I already knew about the now function returning a double but am having trouble breaking it down.

cheers
0
 
LVL 5

Expert Comment

by:Gwena
ID: 6415876
Yup..
Vladimir is a brilliant programmer...but his documentation is rather poor :-) I'd like to see the source of any KOL programs you write... I have written a few..mostly very simple utils that run about 14.5kb to 25kb ... I just love the small exe files...
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!

 
LVL 6

Expert Comment

by:edey
ID: 6416287
Are you not using the sysutils unit?  If not then I'd think you'd have to encode the date/time yourself.  The time's the easy part, like so:

var
   time : extended;
   hours,mins,secs : integer;
begin
     time := now;
     time := (time-trunc(time)*24;
     hours := trunc(time);
     time := (time-trunc(time))*60;
     mins := trunc(time);
     time := (time-trunc(time))*60;
     secs := trunc(time);

The date, between leap years (remeber not all centuries are leap years) and variable length months, is a little more difficult to calculate.  Well, not so much hard as rather inelegant.

Much better would be to use the win32 api's getDateFormat & getTimeFormat.  They're declared in window.pas, I believe, so it's a good chance they're still available to you.

GL
Mike
0
 
LVL 5

Expert Comment

by:Gwena
ID: 6416329
Hi edey :-)
  Using your code

editbox1.text := (int2str(hours)+' '+int2str(mins)+' '+int2str(secs));



Gives this result      '-16806536 -2 -11'
:-)
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 6416347
>time - trunc(time)

frac(time)

=)
0
 

Author Comment

by:campid
ID: 6426092
Guys,

Im not sure whats going on here. I just need to return the current minutes past the hour as an integer.

i.e 1 > 60

Cheers
0
 
LVL 6

Accepted Solution

by:
edey earned 30 total points
ID: 6426654
try this:

time := now;
time := time*24*60;
time := frac(time);

then trunc(time*60) should be the number of min's.

GL
Mike
0
 

Author Comment

by:campid
ID: 6426989
Almost,
cheers guy. Here is how its done.

var
  curtime : extended;
begin
  curtime := now;
  curtime := curtime*24;
  curtime := frac(curtime);
  showmessage(int2str(trunc(curtime*60)));
end;
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Strange behavior when a form is closed 6 80
Run video youtube webbrowse 10 86
Working with hours 3 89
How to make Sign in, using Clientdataset? 1 43
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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

751 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