www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/26/10:28:29

Date: Thu, 26 Dec 1996 17:05:28 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Tudor <tudor AT cam DOT org>
cc: djgpp AT delorie DOT com
Subject: Re: DJGPP Date and Time Functions
In-Reply-To: <32BF3B63.5C7B@cam.org>
Message-ID: <Pine.SUN.3.91.961226165947.7059C-100000@is>
MIME-Version: 1.0

On Mon, 23 Dec 1996, Tudor wrote:

> EX:
> ....
> time start,end;
> ....
> gettime(&start);
> .....
> .....
> gettime(&end);
> 
> at this point start.ti_min equals end.ti_min and the value is totally
> screwed up.

You didn't post any code (the geek code in the signature doesn't count, I 
guess), so I can't tell what's wrong with your program.  However, the 
small test program below works well for me: it prints two times which 
are both reasonable and different from one another.  Of course, if I 
press a key too quickly, the two times are identical, but that's because 
of the inherent 55ms resolution of the PC clock.

Note that the fields of struct time are declared unsigned char.  Maybe 
you used an incorrect format specifier which made the numbers look like 
if they were garbled?

-----------------------------------------------------------------------
#include <stdio.h>
#include <dos.h>
#include <conio.h>

int main(void)
{
  struct time start, end;

  gettime (&start);
  printf ("Start time is %.2u:%.2u:%.2u.%.2u0\n",
          start.ti_hour, start.ti_min, start.ti_sec, start.ti_hund);
  fputs ("Press any key...", stderr);
  while (!kbhit ())
    ;
  gettime (&end);
  printf ("\nEnd time is %.2u:%.2u:%.2u.%.2u0\n",
          end.ti_hour, end.ti_min, end.ti_sec, end.ti_hund);
  return 0;
}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019