public static DateTimeOffset StartOfWeek(this DateTimeOffset dt, DayOfWeek firstDayOfWeek = DayOfWeek.Monday)
        {
            int diff = (7 + (dt.DayOfWeek - firstDayOfWeek)) % 7;

            return(new DateTimeOffset(dt.AddDays(-1 * diff).Date, dt.Offset));
        }
Beispiel #2
0
        /// <summary>
        /// 요일을 기준으로 해당 주의 첫번째 날짜와 시간을 반환한다.
        /// </summary>
        public static DateTimeOffset BeginOfWeek(this DateTimeOffset self, DayOfWeek startOfWeek)
        {
            int diff = (7 + (self.DayOfWeek - startOfWeek)) % 7;

            return(self.AddDays(-1 * diff));
        }