您当前的位置: 首页 >  c#

衣舞晨风

暂无认证

  • 0浏览

    0关注

    1156博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

C# 根据月份来确定每月的最大天数

衣舞晨风 发布时间:2014-01-08 09:46:48 ,浏览量:0

        #region 根据月份来确定每月的最大天数
	//月份为两位
        private int SetDate(string time)
        {
            int intYear;
            int intMonth;
            int intDay;           
            string year = time.Substring(0,4);
            string month = time.Substring(4,2);
            int.TryParse(year, out intYear);
            int.TryParse(month, out intMonth);
            if (intMonth == 02)
            {
                if (intYear % 400 == 0 || (intYear % 4 == 0 && intYear % 100 != 0))//判断是不是闰年  
                {
                    intDay = 29;
                }
                else
                {
                    intDay = 28;
                }
            }
            switch (intMonth)
            {
                case 04:
                case 06:
                case 09:
                case 11: intDay = 30; break;
                default: intDay = 31; break;
            }
            return intDay;
        }
        #endregion
关注
打赏
1647422595
查看更多评论
立即登录/注册

微信扫码登录

0.0416s