Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2642533
  • 博文数量: 416
  • 博客积分: 10220
  • 博客等级: 上将
  • 技术积分: 4193
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-15 09:47
文章分类

全部博文(416)

文章存档

2022年(1)

2021年(1)

2020年(1)

2019年(5)

2018年(7)

2017年(6)

2016年(7)

2015年(11)

2014年(1)

2012年(5)

2011年(7)

2010年(35)

2009年(64)

2008年(48)

2007年(177)

2006年(40)

我的朋友

分类: C/C++

2007-10-30 12:55:33

// test.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include
#include
#include
#include
#include

using namespace std;

#define BUFSIZE 1024
#define PLANFILE "planTast.ini";
#define MANUALFILE "manualRun.ini";

CTime   String2Time(CString s)  
{  
 int   iY,iMon,iD,iH,iM,iSS;  
 int   len;  
 len=s.GetLength();  
 if(len==8)  
 {  
  CTime   t1;  
  t1=CTime::GetCurrentTime();  
  iY=t1.GetYear();  
  iMon=t1.GetMonth();  
  iD=t1.GetDay();  
  CString   h,m,ss;  
  h=s.Mid(0,2);  
  iH=atoi(h);  
  m=s.Mid(3,2);  
  iM=atoi(m);  
  ss=s.Mid(6,2);  
  iSS=atoi(ss);  
 }  
 else if(len==19)  
 {  
  CString   y,mon,d,h,m,ss;  
  y=s.Mid(0,4);  
  iY=atoi(y);  
  mon=s.Mid(5,2);  
  iMon=atoi(mon);  
  d=s.Mid(8,2);  
  iD=atoi(d);  
  h=s.Mid(11,2);  
  iH=atoi(h);  
  m=s.Mid(14,2);  
  iM=atoi(m);  
  ss=s.Mid(17,2);  
  iSS=atoi(ss);  
 }  
 else  
 {  
  CTime   t2;  
  t2=CTime::GetCurrentTime();  
  iY=t2.GetYear();  
  iMon=t2.GetMonth();  
  iD=t2.GetDay();  
  iH=t2.GetHour();  
  iM=t2.GetMinute();  
  iSS=t2.GetSecond();  
 }  
 CTime t(iY,iMon,iD,iH,iM,iSS);  
 return  t;  
}  

int main()
{
 /*
 FILE* fd;
 char buffer[BUFSIZE];
 if(_access("1.txt",00) == -1)  return -1;

 if (( fd = fopen("1.txt","rt")) == NULL) return -1;
 
 while(fgets(buffer,BUFSIZE,fd))
 {
  cout < }
 fclose(fd);
 unlink("1.txt");
*/
 //CString strTime("2007-05-23");
 CString strTime("2007-05-23 02:23:12");
 CTime cTime = String2Time(strTime);
 CTime time = CTime::GetCurrentTime();   //获取当前时间  
 CTime time1(time.GetYear(),time.GetMonth()-3,time.GetDay(),time.GetHour(),time.GetMinute(),time.GetSecond());  
 cout < 
 cout < CTimeSpan tmr3 = cTime - time;
 LONGLONG longsum = tmr3.GetTotalSeconds();
 if (longsum < 10 && longsum>-10)
 {
  cout << "OK" << endl;
 }
 return 0;
}     

阅读(3325) | 评论(0) | 转发(0) |
0

上一篇:VS.net 2003快捷键一览表

下一篇:vc经验总结

给主人留下些什么吧!~~