當前位置: 首頁>>代碼示例>>C#>>正文


C# DateTime.EndOfDay方法代碼示例

本文整理匯總了C#中System.DateTime.EndOfDay方法的典型用法代碼示例。如果您正苦於以下問題:C# DateTime.EndOfDay方法的具體用法?C# DateTime.EndOfDay怎麽用?C# DateTime.EndOfDay使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.DateTime的用法示例。


在下文中一共展示了DateTime.EndOfDay方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: EndOfDayHasCorrectResult

 public void EndOfDayHasCorrectResult()
 {
     DateTime dateTime = new DateTime(1970, 11, 5, 12, 30, 20);
     var actual = dateTime.EndOfDay();
     Assert.AreEqual(dateTime.Date, actual.Date);
     Assert.AreEqual(dateTime.Day + 1, actual.AddSeconds(1).Day);
 }
開發者ID:peteraritchie,項目名稱:ProductivityExtensions,代碼行數:7,代碼來源:TemporableTests.cs

示例2: EndOfDay

            public void EndOfDay()
            {
                var anyDate = new DateTime(2014, 1, 3, 3, 24, 50);
                var expectedResult = DateTime.Parse(
                    string.Format(
                        "{0}-{1}-{2} {3}",
                        anyDate.Year,
                        anyDate.Month,
                        anyDate.Day,
                        "23:59:59.9999999"));

                Assert.Equal(expectedResult, anyDate.EndOfDay());
            }
開發者ID:BilliamBrown,項目名稱:Chronos,代碼行數:13,代碼來源:DateTimeTests.cs

示例3: Parse

        public DateTimeRange Parse(string content, DateTime now) {
            var m = _parser.Match(content);
            if (!m.Success)
                return null;

            string value = m.Groups["name"].Value.ToLower();
            if (value == "today")
                return new DateTimeRange(now.Date, now.EndOfDay());
            if (value == "yesterday")
                return new DateTimeRange(now.Date.SubtractDays(1), now.Date.SubtractDays(1).EndOfDay());
            if (value == "tomorrow")
                return new DateTimeRange(now.Date.AddDays(1), now.Date.AddDays(1).EndOfDay());

            return null;
        }
開發者ID:GorelH,項目名稱:Exceptionless.DateTimeExtensions,代碼行數:15,代碼來源:NamedDayFormatParser.cs

示例4: GetDetailedWorkExtract

        public IEnumerable<CardWorkedDTO> GetDetailedWorkExtract(DateTime startDate, DateTime endDate, IEnumerable<string> boardIds, IEnumerable<string> workers)
        {
            using (MiniProfiler.Current.Step("Getting Detailed Work Extract"))
            {
                var start = startDate.StartOfDay();
                var end = endDate.EndOfDay();

                return boardIds.SelectMany(boardId =>
                {
                    Policy.Handle<Exception>()
                        .WaitAndRetry(5, attempt => TimeSpan.FromSeconds(attempt))
                        .Execute(() =>
                        {
                            _cardWorkExtractorManateeService.Comments =
                                TrelloServiceManateeUtils.GetComments(boardId)
                                    .Where(c => workers.Contains(c.Creator.Id))
                                    .Select(cc => new CardWorkComment
                                    {
                                        CardId = cc.Data.Card.Id,
                                        CardName = cc.Data.Card.Name,
                                        CardLink = cc.Data.Card.ShortUrl,
                                        Who = cc.Creator.FullName,
                                        When = cc.CreationDate,
                                        RawComment = cc.Data.Text
                                    }).ToList();
                        });

                    return TrelloServiceManateeUtils.GetCardsFromBoard(boardId)
                        .SelectMany(card =>
                            _cardWorkExtractorManateeService.GetConsolidatedCardWorkExtract(card.Id)
                                .Where(c => (start <= c.StartedAt && c.StartedAt <= end) ||
                                            (start <= c.StoppedAt && c.StoppedAt <= end))
                                .Select(w => new CardWorkedDTO
                                {
                                    CardName = card.Name,
                                    CardUrl = card.ShortUrl,
                                    Worked = w
                                }));
                });
            }
        }
開發者ID:geanjunior,項目名稱:CoreProject,代碼行數:41,代碼來源:WorkExtractorManateeService.cs

示例5: TestCurrentDate

        public void TestCurrentDate()
        {
            var date = new DateTime(2015, 1, 30, 10, 30, 5);
            var date1 = new DateTime(2015, 1, 30);
            var date2 = new DateTime(2015, 1, 30, 23, 59, 59);
            var date3 = new DateTime(2015, 1, 31);
            var date4 = new DateTime(2015, 1, 29);
            var date5 = new DateTime(2015, 1, 1);
            var date6 = new DateTime(2015, 1, 31);
            var date7 = new DateTime(2015, 1, 26);
            var date8 = new DateTime(2015, 2, 1);
            var date9 = new DateTime(2015, 1, 29);

            Assert.AreEqual(date1, date.StartOfDay());
            Assert.AreEqual(date2, date.EndOfDay());
            Assert.AreEqual(date3, date.NextDay());
            Assert.AreEqual(date4, date.Yesterday());
            Assert.AreEqual(date5, date.GetFirstDayOfMonth());
            Assert.AreEqual(date6, date.GetLastDayOfMonth());
            Assert.AreEqual(date7, date.GetFirstDayOfWeek());
            Assert.AreEqual(date8, date.GetLastDayOfWeek());
            Assert.AreEqual(date9, date.GetWeekday(DayOfWeek.Thursday));
        }
開發者ID:thornfieldhe,項目名稱:TAF,代碼行數:23,代碼來源:DateTimeExtensionTest.cs

示例6: HasJob

 public bool HasJob(DateTime forDate)
 {
     return (CreatedOn >= forDate.StartOfDay()) && (CreatedOn <= forDate.EndOfDay());
 }
開發者ID:c0d3m0nky,項目名稱:mty,代碼行數:4,代碼來源:AwpWord.cs

示例7: TimeZoneTests

 public void TimeZoneTests()
 {
     /* story:
      * 1. a web client submits a request to the server for "today",
      * 2. a developer uses :BeginningOfDay and :EndOfDay to perform clamping server-side.
      * 
      * expected:
      * 3. user expects a timezone-correct utc responses from the server, 
      * 
      * actual:
      * 4. user receives a utc response that is too early (:BeginningOfDay), or
      * 5. user receives a utc response that is too late (:EndOfDay)
      */
     for (var i = -11; i <= 12; i++)
     {
         var beginningOfDayUtc = new DateTime(2015, 1, 1, 0, 0, 0, DateTimeKind.Utc);
         var actualDayStart = beginningOfDayUtc.BeginningOfDay(i);
         var actualDayEnd = beginningOfDayUtc.EndOfDay(i);
         var expectedDayStart = beginningOfDayUtc
             .AddHours(i);
         var expectedDayEnd = beginningOfDayUtc
             .SetHour(23).SetMinute(59).SetSecond(59).SetMillisecond(999)
             .AddHours(i);
         DateAssert.AreEqual(expectedDayStart, actualDayStart);
         DateAssert.AreEqual(expectedDayEnd, actualDayEnd);
     }
 }
開發者ID:jin29neci,項目名稱:FluentDateTime,代碼行數:27,代碼來源:DateTimeTests.cs

示例8: TimeRange

 public TimeRange(DateTime start, DateTime end)
 {
     this.start = start;
     this.end = end.EndOfDay();
 }
開發者ID:usbr,項目名稱:Pisces,代碼行數:5,代碼來源:TimeRange.cs


注:本文中的System.DateTime.EndOfDay方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。