#include "stdafx.h"
#include <iostream>
#include <time.h>
#include <string>
using namespace std;
string& TiHuan(string& str,const string& old_date,const string& new_date)
{
for(string::size_type pos(0);pos!=string::npos;pos+=new_date.length())
{
if( (pos=str.find(old_date,pos))!=string::npos )
{
str.replace(pos,old_date.length(),new_date);
}
else
break;
};
return str;
};
int main(void)
{
//Son.ShowTheData(10);
//char i_date[1096]={0};
char *i_date=NULL;
//char DateBuffer[50]={0};
char Month[20]={0};
time_t TheDate;
time(&TheDate);
printf("time is: %s", ctime(&TheDate));
memcpy(i_date,ctime(&TheDate) + 4,20);
//memcpy(Month,ctime(&TheDate) + 4,3);
string Date = "12345";
Date = i_date;
TiHuan(Date,"Jan","01");
TiHuan(Date,"Feb","02");
TiHuan(Date,"Mar","03");
TiHuan(Date,"Apr","04");
TiHuan(Date,"May","05");
TiHuan(Date,"Jun","06");
TiHuan(Date,"Jul","07");
TiHuan(Date,"Aug","08");
TiHuan(Date,"Sep","09");
TiHuan(Date,"Oct","10");
TiHuan(Date,"Nov","11");
TiHuan(Date,"Dec","12");
const char *DateBuffer = Date.c_str();
cout<<"date is:"<<Date<<endl;
//memcpy(DateBuffer,i_date,20);
if(strncmp(DateBuffer,"09 05 14:35:03 2016",20) > 0) //Mon Dec 05 14:35:03 2016
{
cout<<"time is over"<<endl;
}
else
{
cout<<"u can use it"<<endl;
};
system("pause");
return 0;
};