📕 Document return values in DateTimeExtensions

This commit is contained in:
Oliver Booth 2020-04-19 14:14:59 +01:00
parent 2dab2f30bb
commit 4c30c8228b
No known key found for this signature in database
GPG Key ID: 0D7F2EF1C8D2B9C0
1 changed files with 9 additions and 4 deletions

View File

@ -22,7 +22,8 @@
/// </summary> /// </summary>
/// <param name="date">The date from which to start.</param> /// <param name="date">The date from which to start.</param>
/// <param name="asOf">The date at which to stop counting.</param> /// <param name="asOf">The date at which to stop counting.</param>
/// <returns>Returns the number of years since <paramref name="date"/> as of <paramref name="asOf"/>.</returns> /// <returns>Returns the integer number of years since <paramref name="date"/> as of
/// <paramref name="asOf"/>.</returns>
public static int Age(this DateTime date, DateTime asOf) public static int Age(this DateTime date, DateTime asOf)
{ {
return (int)(((asOf.Date - TimeSpan.FromDays(1) - date.Date).TotalDays + 1) / 365.2425); return (int)(((asOf.Date - TimeSpan.FromDays(1) - date.Date).TotalDays + 1) / 365.2425);
@ -31,9 +32,9 @@
/// <summary> /// <summary>
/// Gets a DateTime representing the first occurence of a specified day in the current month. /// Gets a DateTime representing the first occurence of a specified day in the current month.
/// </summary> /// </summary>
/// <param name="current">The current day</param> /// <param name="current">The current day.</param>
/// <param name="dayOfWeek">The current day of week</param> /// <param name="dayOfWeek">The current day of week.</param>
/// <returns>Returns a date which representing the first occurence of <paramref name="dayOfWeek"/>.</returns> /// <returns>Returns a date representing the first occurence of <paramref name="dayOfWeek"/>.</returns>
public static DateTime First(this DateTime current, DayOfWeek dayOfWeek) public static DateTime First(this DateTime current, DayOfWeek dayOfWeek)
{ {
DateTime first = current.FirstDayOfMonth(); DateTime first = current.FirstDayOfMonth();
@ -50,6 +51,7 @@
/// Gets a <see cref="DateTime"/> representing the first day in the current month. /// Gets a <see cref="DateTime"/> representing the first day in the current month.
/// </summary> /// </summary>
/// <param name="current">The current date.</param> /// <param name="current">The current date.</param>
/// <returns>Returns a date representing the first day of the month>.</returns>
public static DateTime FirstDayOfMonth(this DateTime current) public static DateTime FirstDayOfMonth(this DateTime current)
{ {
return current.AddDays(1 - current.Day); return current.AddDays(1 - current.Day);
@ -59,6 +61,7 @@
/// Gets a <see cref="DateTime"/> representing the last day in the current month. /// Gets a <see cref="DateTime"/> representing the last day in the current month.
/// </summary> /// </summary>
/// <param name="current">The current date.</param> /// <param name="current">The current date.</param>
/// <returns>Returns a date representing the last day of the month>.</returns>
public static DateTime LastDayOfMonth(this DateTime current) public static DateTime LastDayOfMonth(this DateTime current)
{ {
var daysInMonth = DateTime.DaysInMonth(current.Year, current.Month); var daysInMonth = DateTime.DaysInMonth(current.Year, current.Month);
@ -70,6 +73,7 @@
/// </summary> /// </summary>
/// <param name="current">The current date.</param> /// <param name="current">The current date.</param>
/// <param name="dayOfWeek">The current day of week.</param> /// <param name="dayOfWeek">The current day of week.</param>
/// <returns>Returns a date representing the final occurence of <paramref name="dayOfWeek"/>.</returns>
public static DateTime Last(this DateTime current, DayOfWeek dayOfWeek) public static DateTime Last(this DateTime current, DayOfWeek dayOfWeek)
{ {
DateTime last = current.LastDayOfMonth(); DateTime last = current.LastDayOfMonth();
@ -87,6 +91,7 @@
/// </summary> /// </summary>
/// <param name="current">The current date.</param> /// <param name="current">The current date.</param>
/// <param name="dayOfWeek">The day of week for the next date to get.</param> /// <param name="dayOfWeek">The day of week for the next date to get.</param>
/// <returns>Returns a date representing the next occurence of <paramref name="dayOfWeek"/>.</returns>
public static DateTime Next(this DateTime current, DayOfWeek dayOfWeek) public static DateTime Next(this DateTime current, DayOfWeek dayOfWeek)
{ {
var offsetDays = dayOfWeek - current.DayOfWeek; var offsetDays = dayOfWeek - current.DayOfWeek;