home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
463.lha
/
Date_routines
/
maketime.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-01-04
|
1KB
|
44 lines
/*****
maketime()
This function formats the system time into the string passed to the
function using interrupt 0x21. The function allows for a 12- or 24-hour
clock. If a 12-hour clock is used, the input string must allow for 3
more characters to hold the time.
Argument list: char *buff pointer to a character array for the
time
int sep the character to be used to space the
time fields
int mode 0 if a 12-hour clock is wanted,
nonzero for a 24-hour clock.
Return value: void
*****/
#include <stdio.h>
#include <dos.h>
#include <string.h>
void maketime(char *buff, int sep, int mode)
{
char time[3];
union REGS ireg;
ireg.h.ah = 0x2c;
intdos(&ireg, &ireg);
time[0] = '\0';
if (mode == 0) {
if (ireg.h.ch > 12) {
ireg.h.ch -= 12;
strcpy(time, "PM");
} else {
strcpy(time, "AM");
}
}
sprintf(buff, "%02d%c%02d%c%02d %s", ireg.h.ch, sep, ireg.h.cl,
sep, ireg.h.dh, time);
}