antony--异域空间
性格左右命运,气度影响格局!
//当天与该周星期一相差的天数
  private int getModdayNum(System.DayOfWeek dw)
  {
   int weeknow = Convert.ToInt32(dw);
   int moddayNum = (-1) * weeknow+1;
   return moddayNum;
  }

  //当天与该周星期日相差的天数
  private int getSundayNum(System.DayOfWeek dw)
  {
   int weeknow = Convert.ToInt32(dw);
   int sundayNum = 7-weeknow;
   return sundayNum;
  }

  //该周星期一的日期
  private string getWeekMonday(System.DayOfWeek dw,string timeFormateStr)
  {
   int weeknow = Convert.ToInt32(dw);
   int moddayNum = (-1) * weeknow+1;
   string weekMonday = System.DateTime.Now.AddDays(moddayNum).Date.ToString(timeFormateStr);
   return weekMonday;
  }

  //该周星期日的日期
  private string getWeekSunday(System.DayOfWeek dw,string timeFormateStr)
  {
   int weeknow = Convert.ToInt32(dw);
   int sundayNum = 7-weeknow;
   string weekSunday = System.DateTime.Now.AddDays(sundayNum).Date.ToString(timeFormateStr);
   return weekSunday;
  }

  //本周是本年第几周
  private int weekNum(System.DayOfWeek dw)
  {
   int weeknow = Convert.ToInt32(dw);//今天星期几
   int daydiff = (-1) * (weeknow+1);//今日与上周末的天数差
   int days = System.DateTime.Now.AddDays(daydiff).DayOfYear;//上周末是本年第几天
   int weeks = days/7;
   if(days%7 != 0)
   {
    weeks++;
   }
   return (weeks+2);
  }

   //调用方法
   string datetime = getWeekMonday(System.DateTime.Now.DayOfWeek,"yyyy-MM-dd");

一个计算周次和本周时间范围的代码(c#)     CSDN Blog推出文章指数概念,文章指数是对Blog文章综合评分后推算出的,综合评分项分别是该文章的点击量,回复次数,被网摘收录数量,文章长度和文章类型;满分100,每月更新一次。
posted on 2008-02-17 22:36  antony.net  阅读(738)  评论(0编辑  收藏  举报