Jump to content
Excelsior Forums
qnr

Anyone have a clue why I can't use TimeConv?

Recommended Posts

Well, I can use it, but it doesn't do anything useful (just returns zeros).  This is in Linux.

Here is a snippet of code from a test program.  Using the VARs

[tt]

 signOnTime, currentTime, nowTime : SysClock.DateTime;

 tempint : INTEGER;

 signOnTime is set earlier in the program.

[/tt]

 
 (* testing some TimeConv procedures *)
 SysClock.GetClock(nowTime);
 tempint := TimeConv.Compare(signOnTime, nowTime);
 SWholeIO.WriteInt(tempint, 1);
 STextIO.WriteLn;
 STextIO.WriteString("TheDayNumber: ");
 SWholeIO.WriteCard(TimeConv.TheDayNumber(signOnTime), 1);
 STextIO.WriteLn;
 STextIO.WriteString("TheFractionNumber: ");
 SWholeIO.WriteCard(TimeConv.TheFractionNumber(signOnTime), 1);
 STextIO.WriteLn;

 STextIO.WriteString("TheFractionNumber: ");
 tempcard := TimeConv.TheFractionNumber(signOnTime);
 SWholeIO.WriteCard(tempcard, 1);
 STextIO.WriteLn;

returns this:

[tt]

0

TheDayNumber: 0

TheFractionNumber: 0

TheFractionNumber: 0 [/tt] (Just trying the call two different ways for DateTime.fractions )

Share this post


Link to post
Share on other sites

The comments in TimeConv.def module say that all the functions return 0 if their input date/time is invalid (also Compare!)

It seems to be your case.

What exactly value signOnTime is set to?

Have you checked that it is valid?

Are you sure it has been really set on your particular execution path?

Share this post


Link to post
Share on other sites

Thanks Vit.  I do know that it is supposed to return a 0 on an error, but I don't see why there should be any error.

signOnTime is set the same way that nowTime is, with SysClock.GetClock(signOnTime)

I can't see any reason why it would not be valid (I've run it both as a regular user and as root)

The whole test can be found here: http://linux.aliboom.com/time/time.mod

Here is what is saved to the file earlier in the program http://linux.aliboom.com/time/savedTime

and the output of the program (which is just a test, not meant to do anything) is:

terry@antic:~/wrk/time$ ./time

Year: 2005

Month: 7

Day: 1

Zone: 360

0

TheDayNumber: 0

TheFractionNumber: 0

TheFractionNumber: 0

Edit: These times are different than the ones in savedTime, because I ran this after rsyncing the directory to my webserver

Just for info, I've manually set signOnTime.year to 2004, to try to force a difference, and still nothing.

Share this post


Link to post
Share on other sites
The comments in TimeConv.def module say that all the functions return 0 if their input date/time is invalid (also Compare!)

It seems to be your case.

What exactly value signOnTime is set to?

Have you checked that it is valid?

Are you sure it has been really set on your particular execution path?

Hmmm well, running another test,

SysClock.CanGetClock() says I can get the Time and Date and assign them.

However, SysClock.IsValidDateTime says that my DateTime record is invalid after using SysClock.GetClock

Share this post


Link to post
Share on other sites

I've run your program under Linux and it displays meaningful results (y=2005, m=7, d=6, etc..) So you should better trace where your problems start...

> SysClock.CanGetClock() says I can get the Time and Date and assign them.

It actually always returns TRUE  ;)

> However, SysClock.IsValidDateTime says that my DateTime record is invalid after using SysClock.GetClock

Please look at the contents of SysClock.DateTime record that GetClock returns at each phase. Are all fields all right?

IsValidDateTime actually performs the following check of its parameter d:

 IF (d.day<1) OR (d.day>31) THEN RETURN FALSE END;

 IF (d.month<1) OR (d.month>12) THEN RETURN FALSE END;

 IF (d.year<1) THEN RETURN FALSE END;

 IF (ORD(d.month) IN m30days) & (d.day>30) THEN RETURN FALSE END;

 IF (d.month=2) & (d.day>28+ORD(is_leap(d.year))) THEN RETURN FALSE END;

 IF (d.hour>23) OR (d.minute>59) OR (d.second>59) THEN RETURN FALSE END;

 RETURN TRUE

where is_leap(y) =  RETURN (y MOD 4=0) & (y MOD 100#0) OR (y MOD 400=0);

and   CONST m30days = {4,6,9,11};

Share this post


Link to post
Share on other sites

Just so the thread isn't left hanging, I've been unable to find any error in my DateTime records.  I'll post again if I come up with anything new

Share this post


Link to post
Share on other sites

Does this work for anyone?  I still can't get things working.

In summary -- No.

I could not reach your website so I tried the following.

============================================

MODULE test;

  (* Provided "as-is".  Use at own risk. *)

IMPORT SysClock, SWholeIO, STextIO, TimeConv;

IMPORT unistd;

VAR

date1, date2 : SysClock.DateTime;

delta:INTEGER;

junk :CARDINAL;

PROCEDURE printDate( d :SysClock.DateTime);

BEGIN

  WITH d DO

    SWholeIO.WriteCard(year, 4);

    STextIO.WriteString("-");

    SWholeIO.WriteCard(month, 2);

    STextIO.WriteString("-");

    SWholeIO.WriteCard(day, 2);

    STextIO.WriteString(" ");

    SWholeIO.WriteCard(hour, 2);

    STextIO.WriteString(":");

    SWholeIO.WriteCard(minute, 2);

    STextIO.WriteString(":");

    SWholeIO.WriteCard(second, 2);

    STextIO.WriteString(".");

    SWholeIO.WriteCard(fractions, 2);

    STextIO.WriteString(" ");

    SWholeIO.WriteCard(zone, 2);

    STextIO.WriteString(" ");

    IF SummerTimeFlag THEN

      STextIO.WriteString("DST")

    END (*IF*)

  END (*WITH*);

  STextIO.WriteLn

END printDate;

BEGIN

IF ~SysClock.CanGetClock() THEN

    STextIO.WriteString("Unable to read clock!");

    STextIO.WriteLn

END (*IF*);

  SysClock.GetClock(date1);

  STextIO.WriteString("date1 = ");

  printDate(date1);

  STextIO.WriteLn;

  junk := unistd.sleep(2);

  SysClock.GetClock(date2);

  STextIO.WriteString("date2 = ");

  printDate(date2);

  STextIO.WriteLn;

  delta := TimeConv.Compare(date1, date2);

  STextIO.WriteString("TimeConv.Compare() returned ");

  SWholeIO.WriteInt(delta, 4);

  STextIO.WriteLn

END test.

============================================

My output? 

date1 = 2006- 6-27 13:54:36.84 300 DST

date2 = 2006- 6-27 13:54:38.84 300 DST

TimeConv.Compare() returned    0

So TimeConv.Compare() does not seem to work for me.  It certainly would make life so much easier if XDS had proper debugging support for gdb.  :(

john

Share this post


Link to post
Share on other sites

Thanks.  IRT the site, my primary HDD died recently & the backup of the site was corrupted, so those examples, while still available to me, aren't available to the webserver.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×