Add to Favorites    Make Home Page 15504 Online  
 Language Categories  
 Our Services  

Home » C Home » Hardware Interaction Through C Home » Date and Time program with calender of any year > 1900


Search Projects & Source Codes:

Title Date and Time program with calender of any year > 1900
Author Tapan Kumar Mishra
Author Email titu_igit [at]
Description It takes the time from bios data area 0x46c,and uses int 22h to find the scan codes of arrow keys for changing the calender
Category C » Hardware Interaction Through C
Hits 12952
Code Select and Copy the Code
Code : /*Coded by Tapan Kumar Mishra Electrical Engg. IGIT Sarang For any querry Date of Submission:5.11.2005 */ #include<stdio.h> #include<dos.h> #include<conio.h> /********************************************** Global Variables ***********************************************/ struct date d; int currentday,currentmon,currentyear; unsigned long far *t=MK_FP(0X40,0X6C); unsigned char far *scr=MK_FP(0XB800,0); /********************************************** Function Prototype Declaration ***********************************************/ void writechar(char c,int row,int col,char attr); long int curtime(void); void showcale(int,int); unsigned char getkey(void); /*********************************************** Function to Scan the Scan code of the arrow keys ************************************************/ unsigned char getkey(void) { char c; if(kbhit()) { asm xor ah,ah; asm int 22; asm mov c,ah; return c; } return 0; } void main() { int year,i,m; char c; getdate(&d); //function which gives the current date year=d.da_year; currentyear=year; m=(int)d.da_mon; currentmon=m; currentday=(int)d.da_day; showcale(year,m); for(;;) {curtime(); i=(int)getkey(); if(i==16) exit(); if(i==72) showcale(++year,m); if(i==80) showcale(--year,m); if(i==75) { if(--m==0) {m=12;year--;} showcale(year,m); } if(i==77) { if(++m==13) {m=1;year++;} showcale(year,m); } } } /********************************************** showcale() Print The calender ***********************************************/ void showcale(int year,int m) { int date[]={31,28,31,30,31,30,31,31,30,31,30,31}; int i,d=0; char *month[]={"January","February", "March","April","May", "June","July","August", "September","October", "November","December"}; if(year%4==0&&year%100!=0||year%400==0) //to check the year leap or not date[1]=29; //to calculate the 1st day of the year for(i=1900;i<year;i++) if(i%4==0&&i%100!=0||i%400==0) d=d+2; else d=d+1; //to calculate the 1st day of the month of the corresponding year for(i=0;i<m-1;i++) d=d+date[i]; //to print the calender of the month; clrscr(); printf(" %s %d ",month[m-1],year); printf("Mon Tue Wed Thu Fri Sat Sun "); for(i=0;i<d%7;i++) printf(" "); for(i=1;i<=date[m-1];i++) { if((i+d)%7==0) printf("%d ",i); else printf("%d ",i); } gotoxy(65,3); printf("Date:%2d/%2d/%4d",currentday,currentmon,currentyear); gotoxy(5,15); printf("Coded by Tapan Kumar Mishra Electrical Engg."); printf(" IGIT Sarang Orissa"); gotoxy(30,23); printf("USE THE ERROW KEYS TO CHANGE THE YEAR AND MONTH"); printf(" PRESS 'Q' TO QUIT"); } /********************************************** the function curtime() prints and return the current time ***********************************************/ long int curtime(void) { unsigned long m,s,h,ph; char status='A'; m=*t/1092; s=(*t-m*1092)/18.2; h=m/60; ph=h; m=m-h*60; if(h>=12) { status='P'; if(h>12) ph-=12; } writechar(48+(char)ph/10,0,69,122); writechar(48+(char)ph%10,0,70,122); writechar(':',0,71,122); writechar(48+(char)m/10,0,72,122); writechar(48+(char)m%10,0,73,122); writechar(':',0,74,122); writechar(48+(char)s/10,0,75,122); writechar(48+(char)s%10,0,76,122); writechar(32,0,77,122); writechar(status,0,78,122); writechar('M',0,79,122); return 0; } /********************************************** The function writechar() writes the character directly to the VDU ***********************************************/ void writechar(char c,int row,int col,char attr) { *(scr+row*160+col*2)=c; *(scr+row*160+col*2+1)=attr; } //End of code

Related Source Codes

Script Name Author
The Game Opposite as seen on Nokia 2300 Mobile Manikanta
Radix Sort ashish
Change your mouse pointer Ashim
The blinking star Shashank
Data Validation Crylittlebaby
To search a file by giving file type like mp3 or mpeg or doc Prashanth SR
Menus Demonstration B.Chidhambaram
Employee Database Project Using C. Reenku Raman Nayak
Creating a Lexical Analyzer in c fahad bader al-buhairi դ ? ??
Calendar Program Omkar & Devendra
Stop double Process for start in C Cedrik Jurak
Stop double Process for start in C Cedrik Jurak
Time Scheduler Atiq Anwar
A timepass game between atmost two players Rahul Roy


Google Groups Subscribe to SourceCodesWorld - Techies Talk

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!

ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page


Google Search


Source Codes is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions
Copyright ©2003-2017, All Rights Reserved.
Page URL:

Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review