一個簡單日曆

基本點:ide

    (1)每月的日期blog

        const long dayarr[12] = {31,28/29,31,30,31,30,31,31,30,31,30,31};get

 

    (2)肯定閏年it

       isleapyear --> (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))io

    

    (3)肯定最大天數class

        ((month-- == 2 && isleapyear(year)) ? dayarr[month] + 1 : dayarr[month])date

 

    (4)日期對應的周下標(0~6)im

            long getweekindex(long date)
            {        
                long year  = GETYEAR(date);
                long month  = GETMONTH(date);
                if(month == 1 || month == 2)
                {
                    month += 12;
                    --year;
                }
                return ((date%            100) + 2 * month + 3 * (month + 1)/5 +year + year/4 - year/100 + year/400 + 1)%7;
            } img

        

    (5)其餘細節、顯示效果等di

            wKiom1MJo4bhWoOmAAHvV8X_2Lc213.jpg

相關文章
相關標籤/搜索