不使用任何函数计算日期时间!!
大家好!
如何通过自己计算,
把一个整数转化为日期时间,这个整数相当大,
这个整数是这样计算得来的:
以1601.1.1 零点12:00:00为起始时间点,
一直到现在一个时间点之间所经过的所有1/10毫秒数,
即:所有经过的天数*24*60*60*1000*10+剩余秒数*1000*10
假如这个值是:1A 85 AD 7D 5D 01 25 85(8 bytes)
请问,如何把这个值转换为具体的日期、时间、星期数,
这里没有 <time.h>
不知道大家有没有好办法,
关键是闰年比较麻烦,不知道如何处理,
先谢过大家了,
[解决办法]
闰年还不简单??就多1天。关键是你这种描述好像是错误的!!
一个数字并不和时间一一对应也就是说,有多个数字表示同一个时间。
比如2007.1表示2007年1月1日0时0分0秒,2007.2表示2007年1月2日0时0分0秒
按照你的推算0.1表示24小时可是,10个0.01却是2.4个小时可是0.01却表示1分钟!!
[解决办法]
<time.h> 会没有?
任何标准库都有这个!!
<time.h> :
struct tm *gmtime(long *clock)本函数把clock所指的时间(如由函数time返回的时间)
转换成格林威治时间,并以tm结构形式返回
struct tm *localtime(long *clock)本函数把clock所指的时间(如函数time返回的时间)
转换成当地标准时间,并以tm结构形式返回
[解决办法]
如果从某一天起到今天现在的时间用表示毫秒。
然后在转化成时间,那很简单,搜出1601.1.1 零点12:00:00为到现在中间经历的闰年不久可以了。大约4年就有一个闰年,按356天初步算出大约多少年,在初步算出大约几个闰年。然后在细细算。我有一个万年历,能计算任何一个年份(用的long数据类型,所以就是公元前后21亿年之内)的星期,农历1900-2050年。有机会,楼主看看。
[解决办法]
我晕~~
我说LZ你的闰年还要精确到秒?这无形中不是要加大程序读取的时间么?
你说当一个人用一个万年历的时候会在一年的时候用手指在一年最后一天的23:59:59查看那一天是闰年么?
你是一个程序员,要先考虑用户的使用时间和方式,再去弄那个程序,而不是一味地追求精度
[解决办法]
贴一段代码,能够把自1970-01-01 00:00:00到现在经过的秒数转换为日期时间
功能应该与楼主要求的类似,不过没有转换星期的部分
#define IsLeapYear(Y) (Y)%400==0 || ((Y)%4==0 && (Y)%100!=0)
#define LEAPYEARSECONDS (366*3600*24U)
#define NORMALYEARSECONDS (365*3600*24U)
#define GetYearSeconds(Y) ((IsLeapYear(Y))? LEAPYEARSECONDS : NORMALYEARSECONDS)
#define GetMonthSeconds(Y,M) ((IsLeapYear(Y))? MonthSeconds2[M] : MonthSeconds1[M])
unsigned int MonthSeconds1[12]={3600*24*31,3600*24*28,3600*24*31,3600*24*30,3600*24*31,3600*24*30,3600*24*31,3600*24*31,3600*24*30,3600*24*31,3600*24*30,3600*24*31};
unsigned int MonthSeconds2[12]={3600*24*31,3600*24*29,3600*24*31,3600*24*30,3600*24*31,3600*24*30,3600*24*31,3600*24*31,3600*24*30,3600*24*31,3600*24*30,3600*24*31};
//UTC--> yyyymmddhhnnss
void UTCtoDateTime(unsigned int uiSeconds,unsigned char ucDateTime[15])
{
int year,month,day,hour,min,sec;
//取得年份
for(year=1970;uiSeconds> =GetYearSeconds(year);year++)
{
uiSeconds-=GetYearSeconds(year);
}
//取得月份
for(month=1;uiSeconds> =GetMonthSeconds(year,month);month++)
{
uiSeconds-=GetMonthSeconds(year,month);
}
day=uiSeconds/(3600*24)+1;
uiSeconds%=(3600*24);
hour=uiSeconds/(3600);
uiSeconds%=3600;
min=uiSeconds/60;
uiSeconds%=60;
sec=uiSeconds;
//yyyymmddhhnnss
sprintf(ucDateTime, "%d%02d%02d%02d%02d%02d ",year,month,day,hour,min,sec);
}
[解决办法]
第一个问题是:楼主的数太大,用32位UINT是放不下的.
可以考虑先除以24*60*60*1000*10精确到天数,这一步恐怕要用到大数除法.余数计算当天已过的时分秒.然后在不考虑闰年的情况下计数大约的年数.再在这个大约的年数上计算有多少个闰年,最后修正. 是不是有点苯?
[解决办法]
不知道在说什么
看看mktime 在msdn上的sample
是不是你所需要的
[解决办法]
主,
什么有 <time.h> 你不用,非得自己用字慢慢?
是想明你的想法超前,是想明你的水平超?
你不得你是技倒退?
------解决方案--------------------
木有 time.h 的平台多的是, 自己写也很正常, 连老M的GPS卫星都不考虑闰秒的问题, 这个程序也貌似不用考虑这么多, 如果不考虑历史上历法经常被这改改, 哪动动的问题, 应该还是简单的吧 ...
[解决办法]
我认为最简单的方法是:
手动把2007年1月1日零时零秒的值给算出来定义成宏定义(注意强制宏定义为64位),然后用那个值减07年的值,这样数字就小了,就好计算了.
如果芯片返回给你的时间比07年小,就提示错误不处理.
这样计算速度就快了, 我也是嵌入式软件设计师:)
[解决办法]
赞同 xtvtkd(零零漆)的方法。
类似天平调零的方法。
和计算机抢点活干。。
[解决办法]
xtvtkd(零零漆) 的建议不错,顶一下
今天又长知识了
[解决办法]
用VB做很简单~
Dim x As Long
Randomize Timer
x = Rnd * 2000000000
Print CDate( "1600-8-1 ") + x / 10000
[解决办法]
分别存储 400年,100年,4年,1年的对应值
然后从400开始做取余,直到1年就可以算出年份了
最后的余数从去求日期,就很容易了。。。。
[解决办法]
问题可能就是大数取余,你的说数应该就是微软用filetime结构,他是分了高低两个dword值
大数取余的算法网上也有的。。。
[解决办法]
辛苦了一晚上,搞定了,能根据你说的,根据得到毫秒的10倍时间,然后得出年,月,日,星期就自己算去吧。
这么辛苦,楼主多加点分吧,呵呵,没调用任何库函数,包括了stdio.h是测试时printf函数需要。
这程序使用了大量的宏定义,因为在嵌入式编程中这样可以节省时间,不用芯片计算,只需要比较几次就可以了,月数就是比较得出来的,最多只需要12个循环就OK了。
#include <stdio.h>
#define DATE20070101(unsigned long)11069639884800000000//从1601年1月1日到07年1月1日0时已经经过的毫秒10倍时间
#defineLEAPYEAR(unsigned long)316224000000//闰年一年多少毫秒10倍时间
#defineYEAR(unsigned long)315360000000//非闰年一年多少毫秒10倍时间
#defineDAY(unsigned long)8464000000//一天多少毫秒10倍时间
const unsigned long LeapYear_Month[13]={262384000000 ,507840000000 ,770224000000 ,1024144000000 ,1286528000000 ,1540448000000 ,1802832000000 ,2065216000000 ,2319136000000 ,2581520000000 ,2835440000000 ,3097824000000 ,3360208000000 };//闰年每个月所经过多少毫秒10倍时间
const unsigned long Year_Month[13]={262384000000 ,499376000000 ,761760000000 ,1015680000000 ,1278064000000 ,1531984000000 ,1794368000000 ,2056752000000 ,2310672000000 ,2573056000000 ,2826976000000 ,3089360000000,3351744000000 };//非闰年每个月所经过多少毫秒10倍时间
int GetDate(unsigned long ms,int *Year,int *Month,int *Day);
int is_leap(int year) ;
main()
{
int Year, Month, Day;
unsigned long Ms=11069639885800000000;//2007年7月1日
if(GetDate(Ms,&Year,&Month,&Day)==0)//小于2007年出错
{
printf( "错误,时间小于2007年! ");
}
else
{
printf( "当前时间:%d年%d月%d日 ",Year,Month,Day);
}
}
//返回0表示小于2007年,返回1表示成功
int GetDate(unsigned long Ms,int *Year,int *Month,int *Day)
{
int Cur_Year=2007,Cur_Month=0;
if(Ms <DATE20070101)//小于2007年出错
{
return 0;
}
Ms-=DATE20070101;//减去2007年1月1日的时间
while(1)//求当前年,一直减到小于一年的时间,求出年
{
if(is_leap(Cur_Year)==1)//判断闰年
{
if(Ms <=LEAPYEAR)//闰年
{
Ms-=LEAPYEAR;//Ms减一年的时间
Cur_Year++;//年加1
}
else
{
*Year=Cur_Year;//赋值已经求出的年给变量
break;//跳出while,已经求出年
}
}
else//非闰年
{
if(Ms <=YEAR)
{
Ms-=YEAR;
Cur_Year++;
}
else
{
*Year=Cur_Year;
break;
}
}
}
//求月份
if(is_leap(Cur_Year)==1)//闰年
{
for(Cur_Month=0;Cur_Month <12;Cur_Month++)
{
if(Ms> LeapYear_Month[Cur_Month] && Ms <LeapYear_Month[Cur_Month+1])
{
*Month=Cur_Month+1;//赋值已经求出的月给变量
Ms-=LeapYear_Month[Cur_Month];//减以后就是31天以内的时间了,然后计算天
break;//跳出while,已经求出年
}
}
}
else//非闰年
{
for(Cur_Month=0;Cur_Month <12;Cur_Month++)
{
if(Ms> Year_Month[Cur_Month] && Ms <Year_Month[Cur_Month+1])
{
*Month=Cur_Month+1;//赋值已经求出的月给变量
Ms-=Year_Month[Cur_Month];//减以后就是31天以内的时间了,然后计算天
break;//跳出while,已经求出年
}
}
}
if(Ms%DAY!=0)//求天
{
*Day=Ms/DAY+1;//得到天
}
else
{
*Day=Ms/DAY;//得到天
}
return 1;
}
//返回0非闰年,返回1是闰年
int is_leap(int year) //是否闰年
{
if (year % 4 == 0) {
if (year % 100 != 0 || year % 400 == 0) { //闰年
return 1;
}
}
return 0;
}
[解决办法]
楼主还需要多测试一下这程序,我只是简单的测试了一下,用 VC6.0编译通过并运行了
运行应该比较高效,别看while多,如果时间是07年,最坏情况是执行年1个循环,月12个循环,100M的MCU应该能在1ms左右执行完毕吧。
[解决办法]
xtvtkd(零零漆)的程序我用VC6编译,报告很多警告:
truncation from 'const __int64 ' to 'const unsigned long '
unsigned long应该是4字节长度,程序里面很多数值超出了这个范围
运行结果是2008-7-1
[解决办法]
xtvtkd(零零漆)的程序我用VC6编译,报告很多警告:
truncation from 'const __int64 ' to 'const unsigned long '
unsigned long应该是4字节长度,程序里面很多数值超出了这个范围
运行结果是2008-7-1
============================================================
VC6我基本上不会用,不知道是不是哪里设置有问题
[解决办法]
TO yachong(蚜虫) :
我这个也有一样的警告,但是运行结果正确.
truncation from 'const __int64 ' to 'const unsigned long '
我也不知道怎么回事,说截取了,实际我定义的就是无符号长整型,在PC机上就是64位的整数。
[解决办法]
搞错了,long长整型在我的单片机上是64位,在VC6的C编译器中还是32位,需要定义成double型
程序改成如下了:也还需要仔细测试下,可能还有错误,我也只是简单调试了,现在无错误和警告了。
#include <stdio.h>
#define DATE20070101(double)11069639884800000000//从1601年1月1日到07年1月1日0时已经经过的毫秒10倍时间
#defineLEAPYEAR(double)316224000000//闰年一年多少毫秒10倍时间
#defineYEAR(double)315360000000//非闰年一年多少毫秒10倍时间
#defineDAY(unsigned long)846400//一天多少秒时间
const double LeapYear_Month[13]={0,262384000000 ,507840000000 ,770224000000 ,1024144000000 ,1286528000000 ,1540448000000 ,1802832000000 ,2065216000000 ,2319136000000 ,2581520000000 ,2835440000000 ,3097824000000};//闰年每个月所经过多少毫秒10倍时间
const double Year_Month[13]={0,262384000000 ,499376000000 ,761760000000 ,1015680000000 ,1278064000000 ,1531984000000 ,1794368000000 ,2056752000000 ,2310672000000 ,2573056000000 ,2826976000000 ,3089360000000};//非闰年每个月所经过多少毫秒10倍时间
int GetDate(double Ms,int *Year,int *Month,int *Day);
int is_leap(int year) ;
main()
{
int Year, Month, Day;
double Ms=(double)11069641084800000000;//当前获取的需要计算时间
if(GetDate(Ms,&Year,&Month,&Day)==0)//小于2007年出错
{
printf( "错误,时间小于2007年! ");
}
else
{
printf( "当前时间:%d年%d月%d日 ",Year,Month,Day);
}
}
//返回0表示小于2007年,返回1表示成功
int GetDate(double Ms,int *Year,int *Month,int *Day)
{
int Cur_Year=2007,Cur_Month=0;
if(Ms <DATE20070101)//小于2007年出错
{
return 0;
}
Ms-=DATE20070101;//减去2007年1月1日的时间
while(1)//求当前年,一直减到小于一年的时间,求出年
{
if(is_leap(Cur_Year)==1)//判断闰年
{
if(Ms> =LEAPYEAR)//闰年
{
Ms-=LEAPYEAR;//Ms减一年的时间
Cur_Year++;//年加1
}
else
{
*Year=Cur_Year;//赋值已经求出的年给变量
break;//跳出while,已经求出年
}
}
else//非闰年
{
if(Ms> =YEAR)
{
Ms-=YEAR;
Cur_Year++;
}
else
{
*Year=Cur_Year;
break;
}
}
}
//求月份
if(is_leap(Cur_Year)==1)//闰年
{
for(Cur_Month=0;Cur_Month <12;Cur_Month++)
{
if(Ms> LeapYear_Month[Cur_Month] && Ms <LeapYear_Month[Cur_Month+1])
{
*Month=Cur_Month+1;//赋值已经求出的月给变量
Ms-=LeapYear_Month[Cur_Month];//减以后就是31天以内的时间了,然后计算天
break;//跳出while,已经求出月
}
}
}
else//非闰年
{
for(Cur_Month=0;Cur_Month <12;Cur_Month++)
{
if(Ms> Year_Month[Cur_Month] && Ms <Year_Month[Cur_Month+1])
{
*Month=Cur_Month+1;//赋值已经求出的月给变量
Ms-=Year_Month[Cur_Month];//减以后就是31天以内的时间了,然后计算天
break;//跳出while,已经求出月
}
}
}
Ms/=10000;//缩小1万倍,得出秒
if((unsigned long)Ms%DAY!=0)//求天
{
*Day=(unsigned long)Ms/DAY+1;//得到天
}
else
{
*Day=(unsigned long)Ms/DAY;//得到天
}
return 1;
}
//返回0非闰年,返回1是闰年
int is_leap(int year) //是否闰年
{
if (year % 4 == 0) {
if (year % 100 != 0 || year % 400 == 0) { //闰年
return 1;
}
}
return 0;
}
[解决办法]
我也试着写了一个,算法很笨,但应该可以实现日期时间的转化吧!
/*--------------------------------------------------
如何通过自己计算把一个整数转化为日期时间,这个整数相当大:
这个整数是这样计算得来的:以1601.1.1 零点12:00:00为起始时间点,
一直到现在某个时间点之间所经过的所有1/10毫秒数,
即:所有经过的天数*24*60*60*1000*10+剩余秒数*1000*10
假如这个值是:1A 85 AD 7D 5D 01 25 85(8 bytes)
---------------------------------------------------*/
#include <stdio.h>
#define BASE 10000
typedef struct Time
{ int year,mon,day;
int hour,min,sec;
} Time;
Time SetTime(unsigned long long int old);
int LeapYear(int year);
unsigned long long int YearSeconds(int year);
unsigned long long int MonthSeconds(int mon);
int main()
{ Time new;
unsigned long long int old;
printf( "input the 64BIT data: ");
scanf( "%llu ",&old);
new=SetTime(old);
printf( "%d.%d.%d %d:%d:%d\n ",new.year,new.mon,new.day,new.hour,new.min,new.sec);
return 0;
}
Time SetTime(unsigned long long int old) //转化为标准时间格式
{ Time new;
unsigned long long int cont,tsec,temp;
new.year=1601; //初始化日期时间参数
new.mon=1;
new.day=1;
new.hour=0; //为了方便处理时钟参数设置为0时
new.min=0;
new.sec=0;
tsec=old/BASE; //计算总秒数
cont=0; //cont用于顺向秒数计时器
while(1)
{ temp=YearSeconds(new.year);
if(cont+temp> tsec) break;
cont+=temp;
new.year++;
}
while(1)
{ temp=MonthSeconds(new.mon);
if(LeapYear(new.year) && new.mon==2) temp+=24*3600; //若是闰年二月份则增加1天时间
if(cont+temp> tsec) break;
cont+=temp;
new.mon++;
}
while(1)
{ temp=24*3600;
if(cont+temp> tsec) break;
cont+=temp;
new.day++;
}
while(1)
{ temp=3600;
if(cont+temp> tsec) break;
cont+=temp;
new.hour++;
}
while(1)
{ temp=60;
if(cont+temp> tsec) break;
cont+=temp;
new.min++;
}
new.sec=tsec-cont;
//由于初始化时钟为零时,在此应该增加12小时时间
new.hour+=12;
if(new.hour> =24)
{ new.hour-=12;
new.day++;
temp=MonthSeconds(new.mon)/24*3600;
if(LeapYear(new.year) && new.mon==2) temp++;
if(new.day> temp) new.mon++;
if(new.mon> 12) new.year++;
}
return new;
}
int LeapYear(int year)
{ if((year%4==0 && year!=100) || year%400==0) return 1;
else return 0;
}
unsigned long long int YearSeconds(int year)
{ if(LeapYear(year)) return 366*24*3600;
else return 365*24*3600;
}
unsigned long long int MonthSeconds(int mon)
{ switch(mon)
{ case 1 : return 31*24*3600;
case 2 : return 28*24*3600;
case 3 : return 31*24*3600;
case 4 : return 30*24*3600;
case 5 : return 31*24*3600;
case 6 : return 30*24*3600;
case 7 : return 31*24*3600;
case 8 : return 31*24*3600;
case 9 : return 30*24*3600;
case 10: return 31*24*3600;
case 11: return 30*24*3600;
case 12: return 31*24*3600;
}
}
[解决办法]
写了一个,大数用的int64 呵呵~不知道你的mcu是不是64位~
直接用FILETIME转换后测试了几个算法正确
基本上就是我在上面回答的,分别存储 400年,100年,4年,1年的对应值
然后从400开始做取余,直到1年就可以算出年份了
算出年最多用25-6减就可以~如果还想少就在增加几个年的长量。。。
后面的日期之接用的,可以每个月做常量,计算量会大大减小。。
这个是100ns 。。。。不是秒数*1000*10 是秒数*1000*10*1000 ..为了和filetime结构统一,去掉就可以。。。
#define DATE1 864000000000//(24*60*60*10000000)
#define HH 36000000000
#define MM 600000000
#define SS 10000000
#define YEAR400 126227808000000000 //((400*365+100-3)*DATE1)
#define YEAR100 31556736000000000 //((100*365+24)*DATE1)
#define YEAR4 1262304000000000//((4*365+1)*DATE1)
#define YEAR1 315360000000000//365*DATE1)
typedef unsigned __int64 mytime;
mytime divide(mytime aNum,mytime bNum,mytime* y)
{
mytime tmpS=0;
while(1)
{
if (aNum <bNum)
{
*y=aNum;
return tmpS;
}
aNum-=bNum;
tmpS+=1;
}
}
int main(int argc, char* argv[])
{
int dateAdd[13]={0,31,59,90,120,151,181,212,243,273,304,334,365};
mytime my_time=128183044680000000;
mytime ly_time=0;
mytime year=1601,date=0;
bool rn=false; //润年
int month,day,hh,mm,ss,weekday;
year+=divide(my_time,YEAR400,&ly_time)*400;
year+=divide(ly_time,YEAR100,&ly_time)*100;
year+=divide(ly_time,YEAR4,&ly_time)*4;
year+=divide(ly_time,YEAR1,&ly_time);
date=divide(ly_time,DATE1,&ly_time);
//date+=((int)(ly_time))/DATE1;
if(year%4==0 && year%100!=0 || year%400==0)
rn=true;
for (int n=0;n <12;n++)
{
if (rn && n> 0)
dateAdd[n+1]++;
if (date> =dateAdd[n] && date <dateAdd[n+1])
break;
}
month=n+1;
day=date-dateAdd[n]+1;
hh=ly_time/HH;
ly_time%=HH;
mm=ly_time/MM;
ly_time%=MM;
ss=ly_time/SS;
ly_time%=SS;
if(month <3) month+=12;
weekday=(day+2*month+3*(month+1)/5+year+year/4-year/100+year/400)%7; //0为星期一 6为星期日
printf( "%I64d-%02d-%02d %02d:%02d:%02d %I64d*100nS %d\n ",year,month,day,hh,mm,ss,ly_time,weekday);
return 0;
}
------解决方案--------------------
昨天看到这个题目,今天自己编了个:大家看看:
贴主比较变态,给的时间估计到地球爆炸的时候,也还没完!!!
但是星期是得不到的,贴主如果告诉我1601年是 星期几的话,那么就可以知道了!!!
#include "iostream.h "
#include <BASETSD.H>
#define YRAR_TIME (365*24*60*60*1000*10)
#define DAY_TIME (24*60*60*1000*10)
#define HOUR_TIME (60*60*1000*10)
void main(void)
{
UINT64 set_time=0x1A85AD7D5D012585;// 0x1A85AD7D5D012585;
long get_first_year=0,get_first_day=0,get_year_pos=0,get_first_time=0;
long get_true_year=0, get_true_day=0;
long Month=0,Day=0,Hour=0,Second=0,year=0,m_second=0,m_m_second=0,m_min;
get_first_year=set_time/YRAR_TIME;
get_first_day=(set_time%YRAR_TIME)/DAY_TIME;
get_first_time=set_time%DAY_TIME;
Hour=get_first_time/HOUR_TIME;
Second=((get_first_time%HOUR_TIME)/10000)%60;
m_min=get_first_time%HOUR_TIME/600000;
m_second=(set_time%10000)/10;
m_m_second=set_time%10;
get_year_pos=(get_first_year+1601)/4-1601/4;//润年的个数
get_true_year=1601+get_first_year;
for (int i=0;i <get_year_pos;i++)
{
get_first_day--;
if (get_first_day==0)
{
get_true_year--;
get_first_day+=365;
if (get_true_year%4==0)
{
i++;
}
}
get_true_day=get_first_day;
}
if (get_true_year%4)
{
if (get_true_day <=31)
{
Month=1;
Day=get_true_day;
}
if (get_true_day <=(31+28))
{
Month=2;
Day=get_true_day-31;
}
if (get_true_day <=(31+28+31))
{
Month=3;
Day=get_true_day-31-28;
}
if (get_true_day <=(31+28+31+30))
{
Month=4;
Day=get_true_day-31-28-31;
}
if (get_true_day <=(31+28+31+30+31))
{
Month=5;
Day=get_true_day-31-28-31-30;
}
if (get_true_day <=(31+28+31+30+31+30))
{
Month=6;
Day=get_true_day-31-28-31-30-31;
}
if (get_true_day <=(31+28+31+30+31+30+31))
{
Month=7;
Day=get_true_day-31-28-31-30-31-30;
}
if (get_true_day <=(31+28+31+30+31+30+31+31))
{
Month=8;
Day=get_true_day-31-28-31-30-31-30-31;
}
if (get_true_day <=(31+28+31+30+31+30+31+31+30))
{
Month=9;
Day=get_true_day-31-28-31-30-31-30-31-31;
}
if (get_true_day <=(31+28+31+30+31+30+31+31+30+31))
{
Month=10;
Day=get_true_day-31-28-31-30-31-30-31-31-30;
}
if (get_true_day <=(31+28+31+30+31+30+31+31+30+31+30))
{
Month=11;
Day=get_true_day-31-28-31-30-31-30-31-31-30-31;
}
if (get_true_day <=(31+28+31+30+31+30+31+31+30+31+30+31))
{
Month=12;
Day=get_true_day-31-28-31-30-31-30-31-31-30-31-30;
}
}
else
{
if (get_true_day <=31)
{
Month=1;
Day=get_true_day;
}
if (get_true_day <=(31+29))
{
Month=2;
Day=get_true_day-31;
}
if (get_true_day <=(31+29+31))
{
Month=3;
Day=get_true_day-31-29;
}
if (get_true_day <=(31+29+31+30))
{
Month=4;
Day=get_true_day-31-29-31;
}
if (get_true_day <=(31+29+31+30+31))
{
Month=5;
Day=get_true_day-31-29-31-30;
}
if (get_true_day <=(31+29+31+30+31+30))
{
Month=6;
Day=get_true_day-31-29-31-30-31;
}
if (get_true_day <=(31+29+31+30+31+30+31))
{
Month=7;
Day=get_true_day-31-29-31-30-31-30;
}
if (get_true_day <=(31+29+31+30+31+30+31+31))
{
Month=8;
Day=get_true_day-31-29-31-30-31-30-31;
}
if (get_true_day <=(31+29+31+30+31+30+31+31+30))
{
Month=9;
Day=get_true_day-31-29-31-30-31-30-31-31;
}
if (get_true_day <=(31+29+31+30+31+30+31+31+30+31))
{
Month=10;
Day=get_true_day-31-29-31-30-31-30-31-31-30;
}
if (get_true_day <=(31+28+31+30+31+30+31+31+30+31+30))
{
Month=11;
Day=get_true_day-31-29-31-30-31-30-31-31-30-31;
}
if (get_true_day <=(31+29+31+30+31+30+31+31+30+31+30+31))
{
Month=12;
Day=get_true_day-31-29-31-30-31-30-31-31-30-31-30;
}
}
year=get_true_year;
cout < < "时间为: " < <year < < '- ' < <Month < < '- ' < <Day < < '- ' < <Hour < < '- ' < <m_min < < '- ' < <Second < < '- ' < <m_second < < '- ' < <m_m_second < < '\n ';
}