Esempio n. 1
0
        public static DateTime ToStartOfWeek(this DateTime dateTime)
        {
            var dayOfWeek = julianCalendar.GetDayOfWeek(dateTime);
            var start     = dateTime.Subtract(TimeSpan.FromDays((int)dayOfWeek));

            return(start.ToStartOfDay());
        }
Esempio n. 2
0
        public void DateTimeExt_TestEndOfWeek()
        {
            var current   = DateTime.UtcNow;
            var processed = current.ToEndOfWeek();

            Assert.AreEqual(DayOfWeek.Saturday, julian.GetDayOfWeek(processed));
            Assert.IsTrue(julian.GetDayOfYear(current) <= julian.GetDayOfYear(processed));
        }