Show: Object Pascal C++
Display Preferences

gettime, settime

From Appmethod Topics
Jump to: navigation, search

Go Up to dos.h Index

Header File

dos.h

Category

Time and Date Routines

Prototype

void gettime(struct time *timep);

void settime(struct time *timep);

Description

Gets and sets the system time.

  • gettime fills in the time structure pointed to by timep with the system's current time.
  • settime sets the system time to the values in the time structure pointed to by timep.

The time structure is defined as follows:

struct time {
  unsigned char ti_min; /* minutes */
  unsigned char ti_hour; /* hours */
  unsigned char ti_hund; /* hundredths of seconds */
  unsigned char ti_sec; /* seconds */
 };

Return Value

None. When passing an invalid argument, time is not modified and errno is set to EINVAL (Invalid argument).

Example

#include   <stdio.h>
#include   <dos.h>
int main(void)
{
   struct  time t;
   gettime(&t);
   printf("The current time is: %2d:%02d:%02d.%02d\n",
          t.ti_hour, t.ti_min, t.ti_sec, t.ti_hund);
   return 0;
}
Personal tools
In other languages