给定日期转换成周数

 1  DayOfWeek dy  =  (Convert.ToDateTime( string .Format( " {0}-1-1 0:0:0 " , DateTime.Now.Year.ToString()))).DayOfWeek;
 2               int  j = 0 ;
 3               switch (dy)
 4              {
 5                   case  DayOfWeek.Sunday:
 6                      j = 0 ;
 7                       break ;
 8                   case  DayOfWeek.Monday:
 9                      j  =   1 ;
10                       break ;
11                   case  DayOfWeek.Tuesday:
12                      j  =   2 ;
13                       break ;
14                   case  DayOfWeek.Wednesday:
15                      j  =   3 ;
16                       break ;
17                   case  DayOfWeek.Thursday:
18                      j  =   4 ;
19                       break ;
20                   case  DayOfWeek.Friday:
21                      j  =   5 ;
22                       break ;
23                   case  DayOfWeek.Saturday:
24                      j  =   6 ;
25                       break ;
26 
27              }
28               int  i  =  (DateTime.Now.DayOfYear + j) / 7 + 1 ;

你可能感兴趣的:(日期转换)