|
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<time.h>
void main()
{
int slt;
struct time t;
struct tm *gm_date;
char day;
start:
clrscr();
textcolor(15);
gotoxy(25,3);
cprintf("===woogi watch===\n");
textcolor(10);
gotoxy(23,4);
cprintf("1.Current time\n");
textcolor(10);
gotoxy(23,5);
cprintf("2.Greenwich Mean Time(GMT)\n");
textcolor(10);
gotoxy(23,6);
cprintf("3.End\n");
textcolor(7);
gotoxy(23,7);
cprintf("Choose 1 or 2 or 3>>");
scanf("%d", &slt);
if(slt==1)
{
while(!kbhit())
{
gettime(&t);
if(t.ti_hour > 12) day = 'P';
else day = 'A';
gotoxy(23,8);
printf("%cM %2d:%02d:%02d", day, t.ti_hour, t.ti_min, t.ti_sec);
delay(100);
}getchar();getchar();
goto start;
}
else if(slt==2)
{
time_t seconds;
time(&seconds);
gm_date=gmtime(&seconds);
gotoxy(23,9);
printf("This is GMT\n");
gotoxy(23,10);
printf("Current date: %d-%d-%d\n", gm_date->tm_mon+1, gm_date->tm_mday, gm_date->tm_year);
gotoxy(23,11);
printf("Current time: %02d:%02d:%02d", gm_date->tm_hour, gm_date->tm_min, gm_date->tm_sec);
getchar();getchar();
goto start;
}
else if(slt==3)
{
gotoxy(28,12);
printf("Program shut down.\n");
getchar();getchar();
}
}
|