#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <ctime>
#include <string>
usingnamespace std;
string GetCurrTime(void);
string IntToStr(int);
int main(void)
{
cout << "The current time is " << GetCurrTime() << ".\n\n";
system("Pause");
}
string GetCurrTime(void)
{
/*
** The following gets the number of seconds since January 1, 1970,
** and then converts it into a sturcture that holds the current time
** in a more readable format.
*/
time_t RawTime;
struct tm* FTime;
time(&RawTime);
FTime = localtime(&RawTime);
/*
** The Following takes the integer values and converts them to "string" for
** easier storge.
*/
string hour = IntToStr(FTime->tm_hour);
string min = IntToStr(FTime->tm_min);
string sec = IntToStr(FTime->tm_sec);
/*
** The Following stores and prints out the time.
*/
string CT = hour + ":" + min + ":" + sec;
return CT;
}
string IntToStr(int X)
{
char Temp[3];
itoa(X, Temp, 10);
if(X < 10)
{
Temp[2] = 0;
Temp[1] = Temp[0];
Temp[0] = '0';
}
string Str = Temp;
return Str;
}
Basically is going to be a clock with that shows the month, day, year, time, am or pm, and have the option for 12 or 24 time.