/*
*以2000年3月1日为第1天的天数表示日期,月数规避2月不确定的天数,年数必须是400的倍数
*/
//const MONTH_ID:i32=24003;
//const mdays:[i32;12]=[0,31,61,92,122,153,184,214,245,275,306,337];
pub struct Date{
pub day_id:i32
}
pub fn new(days:i32)->Date{
Date{day_id:days}
}
/*
//从YEAR年(如2000年)3月1日0点开始计算,结束于本年3月1日0点.
pub fn getDaysOfYearID(yearID:i32)->i32{
//标准公式为(yearID-YEAR)*365+(yearID/4-yearID/100+yearID/400)-(YEAR/4-YEAR/100+YEAR/400),是400整数倍.简化如下
yearID*365+yearID/4-yearID/100+yearID/400
}
fn getDays(yearID:i32,monthID:i32)->i32{
//标准公式为(yearID-YEAR)*365+(yearID/4-yearID/100+yearID/400)-(YEAR/4-YEAR/100+YEAR/400),是400整数倍简化如下
let mut myMonthID=monthID+yearID*12;
let mut myYearID=myMonthID/12;
if myYearID<0 {myYearID+=1;}
myMonthID-=myYearID*12;
myYearID*365+myYearID/4-myYearID/100+myYearID/400+mdays[myMonthID]
}
fn getYearID(days:i32)->i32{
let mut yearID=days/365;
//days/365:年数,可能的最大值
while days<=getDaysOfYearID(yearID) {yearID-=1;}
yearID
}
fn getmonthID(days:i32)->i32{
//月份:3 4 5 6 7 8 9 10 11 12 1 2
//月ID:0 1 2 3 4 5 6 7 8 9 10 11
let mut monthID:i32=days/30;
while days > mdays[monthID] {
monthID-=1;
}
monthID
}
pub fn Days(year:i32,month:i32,day:i32)->i32{
let monthID=year*12+(month-MONTH_ID);
monthID/12*365+monthID/48-monthID/1200+monthID/4800+day
}
*/
/*fn toYYYYMMDD(days:i32) -> [char;8]{
let day400=days % 146097;
let day100=day400 % 36524;
let day4=day100 % 1461;
let day=day4 % 365;
let mut monthID=days/146097*4800+day400/36524*1200+day100/1461*48;//分离400年的
//self.width * self.height
}
*/
08-14
676
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-15
217
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-28
1190
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-01
272
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-23