本文整理汇总了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);
}
示例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());
}
示例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;
}
示例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
}));
});
}
}
示例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));
}
示例6: HasJob
public bool HasJob(DateTime forDate)
{
return (CreatedOn >= forDate.StartOfDay()) && (CreatedOn <= forDate.EndOfDay());
}
示例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);
}
}
示例8: TimeRange
public TimeRange(DateTime start, DateTime end)
{
this.start = start;
this.end = end.EndOfDay();
}