Beispiel #1
0
        /// <summary>
        /// 把日期转换成星期
        /// <para>
        /// 可以采用 默认的方法:0123456 或者采用 1234567
        /// </para>
        /// </summary>
        /// <param name="DT">待处理</param>
        /// <param name="blnDefault"><para>true:默认1234560</para><para>false:1234567</para></param>
        /// <returns>对应的星期整数</returns>
        public static int Exp_ToWeek(this DateTime DT, bool blnDefault)
        {
            DayOfWeek dw = DT.DayOfWeek;

            if (blnDefault)
            {
                return(dw.Exp_To <int>());
            }
            else
            {
                switch (dw)
                {
                case DayOfWeek.Monday:
                    return(1);

                case DayOfWeek.Tuesday:
                    return(2);

                case DayOfWeek.Wednesday:
                    return(3);

                case DayOfWeek.Thursday:
                    return(4);

                case DayOfWeek.Friday:
                    return(5);

                case DayOfWeek.Saturday:
                    return(6);

                default:    // DayOfWeek.Sunday:
                    return(7);
                }
            }
        }