Code Library
Home Submit Free Hosting Link To Us Contacts

CPP System time handle

CPP System time handle CPP CPP System time handle Download (.zip)



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

extern void message (void);
extern void title   (void);
extern void gramas  (void);

char *systime (int ttype)
{
    unsigned   char hours, mins, secs, hunds;
    int        pm=0;
    static     char buf[17];
    union REGS regs;

    regs.h.ah = 0x2c;                           /* DOS Get System Time */
    int86 (0x21, &regs, &regs);
    hours = regs.h.ch;
    mins  = regs.h.cl;
    secs  = regs.h.dh;
    hunds = regs.h.dl;
    if (hours > 11) pm = 1;

    switch (ttype) {                     /* test requested time type */
            case 0:
                    sprintf(buf," %02u:%02u:%02u.%02u ",hours,mins,secs,hunds);
                    break;
            case 1:
                    sprintf(buf," %02u:%02u:%02u ",hours,mins,secs);
                    break;
            case 20:
                    sprintf(buf,"%02u%02u%02u ",hours,mins,secs);
                    break;
            case 2:
                    if(!hours) hours=12;
                    sprintf(buf," %u:%02u %cM ",(hours>12)?(hours-12):hours,mins,
                    pm?'P':'A');
                    break;
            case 3:
                    if(!hours) hours=12;
                    sprintf(buf," %u:%02u%c ",(hours>12)?(hours-12):hours,mins,
                    pm?'p':'a');
                    break;
            case 4:
                    if(!hours) hours=12;
                    sprintf(buf," %u:%02u ",(hours>12)?(hours-12):hours,mins);
                    break;
            default:
                    sprintf(buf,"%02u:%02u",hours,mins);
    }
    if (ttype == 1) {
        message ();
        gramas  ();
       }

    return(buf);
}


char *sysdate (int a)
{
    static   char buf[22];
             char textyear[5];
    unsigned int  year;
    unsigned char month,day;
    union    REGS regs;

    regs.h.ah = 0x2a;                           /* DOS Get System Date */
    int86 (0x21, &regs, &regs);
    year = regs.x.cx;
    month = regs.h.dh;
    day = regs.h.dl;
    itoa (year, textyear, 10);

   if (a) sprintf(buf," %02u/%02u/%s ",day,month,textyear+2);
          else sprintf(buf,"%s%02u%02u",textyear, month, day);
    return(buf);                        /* return address of buffer */
}





  • CPPSystem time handle


Tatet