Ejemplo n.º 1
0
        /// <summary>
        /// 根据当前学期的第一周和当前的时间,计算出日历的周次
        /// </summary>
        /// <param name="firsWeek"></param>
        /// <param name="todays"></param>
        /// <returns></returns>
        public string getZhouCi(string firsWeek, string lastWeek, string todays)
        {
            string coutw = "";

            try
            {
                //2 获取本学期一周对应的全年的周次
                DateTime firstDt  = Convert.ToDateTime(firsWeek);
                DateTime lastDt   = Convert.ToDateTime(lastWeek);
                DateTime todaysDt = Convert.ToDateTime(todays);

                if (todaysDt > lastDt || todaysDt < firstDt)
                {
                    coutw = "放假";
                }
                else
                {
                    string diff            = commons.DateDiff(firstDt, todaysDt);
                    int    diffint         = int.Parse(diff);
                    int    zhouciben       = diffint / 7;
                    double zhouci          = diffint / 7;
                    double zhoucibendouble = Convert.ToDouble(zhouciben);
                    if (zhouci - zhoucibendouble > 0)
                    {
                        zhouciben = zhouciben + 2;
                    }
                    else
                    {
                        zhouciben = zhouciben + 1;
                    }
                    coutw = zhouciben.ToString();
                }
            }
            catch
            {
                coutw = "放假";
            }
            return(coutw);
        }