• 日期加1程序


    #region 日期day自动加1
            /// <summary>
            /// 将当前日期加1天
            /// </summary>
            /// <param name="str">输入日期,如20120101</param>
            /// <returns></returns>
            public static string dateAdd1(string str)
            {
                //内容分解
                int year = int.Parse(str.Substring(0, 4));
                int month = int.Parse(str.Substring(4, 2));
                int day = int.Parse(str.Substring(6));
                if (month == 12)
                {
                    if (day > 31)
                    {
                        MessageBox.Show("进行日期自加1时,输入的day大于31");
                        return "";
                    }
                    //若为最后一天,则年数加1
                    if (day == 31)
                    {
                        return (year + 1).ToString() + "0101";
                    }
                    else
                        day++;
                }
                else if(month ==1 || month ==3 || month ==5 ||month ==7 || month ==8 || month ==10)
                {
                    if (day > 31)
                    {
                        MessageBox.Show("进行日期自加1时,输入的day大于31");
                        return "";
                    }
                    //月数为31天
                    if (day == 31)
                    {
                        if(month!=10)
                            return year.ToString() + "0"+(month + 1).ToString() + "01";
                        else
                            return year.ToString() + (month + 1).ToString() + "01";
                    }
                    else
                    {
                        day++;
                    }
                }
                else if(month ==2)
                {
                    //2月份
                    int xianzhi = 28;
                    if (year % 4 == 0)
                        xianzhi = 29; //闰年2月份为29天
                    if (day > xianzhi)
                    {
                        MessageBox.Show("2月份进行日期自加1时,输入的day大于"+xianzhi.ToString());
                        return "";
                    }
    
                    if (day == xianzhi)
                    {
                        return year.ToString() + "0" + (month + 1).ToString() + "01";
                    }
                    else
                        day++;
                }
                else
                {
                    //每月30天的情形
                    if (day > 30)
                    {
                        MessageBox.Show("进行日期自加1时,输入的day大于31");
                        return "";
                    }
                    if (day == 30)
                    {
                        if(month>8) //9+1为10,所以,9月份前也不用加0
                            return year.ToString() + (month + 1).ToString() + "01";
                        else
                            return year.ToString()+"0" + (month + 1).ToString() + "01";
                    }
                    else
                        day++;
                }
                string strd=day.ToString();
                string strm=month.ToString();
                if(day<10)
                {
                    strd= "0"+strd;
                }
                if (month < 10)
                {
                    strm = "0" + strm;
                }
                return year.ToString() + strm + strd;
            }
    
  • 相关阅读:
    android 8 wifi wifi 扫描过程
    Android WiFi 日志记录(四次握手)
    Android 8 Wifi 初始化过程
    wifi 通过omnipeek 查看 pmf是否生效
    qualcomm 查看 wifi 配置生效
    Android 8 AudioPolicy 分析
    2. 观点提取和聚类代码详解
    1. pyhanlp介绍和简单应用
    6. EM算法-高斯混合模型GMM+Lasso详细代码实现
    5. EM算法-高斯混合模型GMM+Lasso
  • 原文地址:https://www.cnblogs.com/DayDreamEveryWhere/p/3564184.html
Copyright © 2020-2023  润新知