Class DateTimeOffsetExtensions
Extension methods for
Inheritance
Namespace: X10D.Time
Assembly: X10D.dll
Syntax
public static class DateTimeOffsetExtensions : object
Methods
| Improve this Doc View SourceAge(DateTimeOffset)
Returns the rounded-down integer number of years since a given date as of today.
Declaration
public static int Age(this DateTimeOffset value)
Parameters
Type | Name | Description |
---|---|---|
DateTimeOffset | value | The date from which to calculate. |
Returns
Type | Description |
---|---|
System.Int32 | The rounded-down integer number of years since |
Age(DateTimeOffset, DateTimeOffset)
Returns the rounded-down integer number of years since a given date as of another specified date.
Declaration
public static int Age(this DateTimeOffset value, DateTimeOffset referenceDate)
Parameters
Type | Name | Description |
---|---|---|
DateTimeOffset | value | The date from which to calculate. |
DateTimeOffset | referenceDate | The date to use as the calculation reference. |
Returns
Type | Description |
---|---|
System.Int32 | The rounded-down integer number of years since |
First(DateTimeOffset, DayOfWeek)
Gets a date representing the first occurence of a specified day of the week in the current month.
Declaration
public static DateTimeOffset First(this DateTimeOffset value, DayOfWeek dayOfWeek)
Parameters
Type | Name | Description |
---|---|---|
DateTimeOffset | value | The current date. |
DayOfWeek | dayOfWeek | The day of the week. |
Returns
Type | Description |
---|---|
DateTimeOffset | A |
FirstDayOfMonth(DateTimeOffset)
Gets a date representing the first day of the current month.
Declaration
public static DateTimeOffset FirstDayOfMonth(this DateTimeOffset value)
Parameters
Type | Name | Description |
---|---|---|
DateTimeOffset | value | The current date. |
Returns
Type | Description |
---|---|
DateTimeOffset | A |
GetIso8601WeekOfYear(DateTimeOffset)
Gets the ISO-8601 week number of the year for the current date.
Declaration
public static int GetIso8601WeekOfYear(this DateTimeOffset value)
Parameters
Type | Name | Description |
---|---|---|
DateTimeOffset | value | The date whose week number to return. |
Returns
Type | Description |
---|---|
System.Int32 | The ISO-8601 week number of the year. |
Remarks
This implementation is directly inspired from a blog post . about this subject.
IsLeapYear(DateTimeOffset)
Returns a value indicating whether the year represented by the current
Declaration
public static bool IsLeapYear(this DateTimeOffset value)
Parameters
Type | Name | Description |
---|---|---|
DateTimeOffset | value | The date whose year to check. |
Returns
Type | Description |
---|---|
System.Boolean | true if the year represented by |
Last(DateTimeOffset, DayOfWeek)
Gets a date representing the final occurence of a specified day of the week in the current month.
Declaration
public static DateTimeOffset Last(this DateTimeOffset value, DayOfWeek dayOfWeek)
Parameters
Type | Name | Description |
---|---|---|
DateTimeOffset | value | The current date. |
DayOfWeek | dayOfWeek | The day of the week. |
Returns
Type | Description |
---|---|
DateTimeOffset | A |
LastDayOfMonth(DateTimeOffset)
Gets a date representing the last day of the current month.
Declaration
public static DateTimeOffset LastDayOfMonth(this DateTimeOffset value)
Parameters
Type | Name | Description |
---|---|---|
DateTimeOffset | value | The current date. |
Returns
Type | Description |
---|---|
DateTimeOffset | A |
Next(DateTimeOffset, DayOfWeek)
Gets a date representing the next occurence of a specified day of the week in the current month.
Declaration
public static DateTimeOffset Next(this DateTimeOffset value, DayOfWeek dayOfWeek)
Parameters
Type | Name | Description |
---|---|---|
DateTimeOffset | value | The current date. |
DayOfWeek | dayOfWeek | The day of the week. |
Returns
Type | Description |
---|---|
DateTimeOffset | A |