Class DateOnlyExtensions
Time-related extension methods for
Inheritance
Namespace: X10D.Time
Assembly: X10D.dll
Syntax
public static class DateOnlyExtensions : object
Methods
| Improve this Doc View SourceAge(DateOnly)
Returns the rounded-down integer number of years since a given date as of today.
Declaration
public static int Age(this DateOnly value)
Parameters
Type | Name | Description |
---|---|---|
DateOnly | value | The date from which to calculate. |
Returns
Type | Description |
---|---|
System.Int32 | The rounded-down integer number of years since |
Age(DateOnly, DateOnly)
Returns the rounded-down integer number of years since a given date as of another specified date.
Declaration
public static int Age(this DateOnly value, DateOnly referenceDate)
Parameters
Type | Name | Description |
---|---|---|
DateOnly | value | The date from which to calculate. |
DateOnly | referenceDate | The date to use as the calculation reference. |
Returns
Type | Description |
---|---|
System.Int32 | The rounded-down integer number of years since |
Deconstruct(DateOnly, out Int32, out Int32, out Int32)
Deconstructs the current
Declaration
public static void Deconstruct(this DateOnly value, out int year, out int month, out int day)
Parameters
Type | Name | Description |
---|---|---|
DateOnly | value | The date to deconstruct. |
System.Int32 | year | When this method returns, contains the year. |
System.Int32 | month | When this method returns, contains the month. |
System.Int32 | day | When this method returns, contains the day. |
First(DateOnly, DayOfWeek)
Gets a date representing the first occurence of a specified day of the week in the current month.
Declaration
public static DateOnly First(this DateOnly value, DayOfWeek dayOfWeek)
Parameters
Type | Name | Description |
---|---|---|
DateOnly | value | The current date. |
DayOfWeek | dayOfWeek | The day of the week. |
Returns
Type | Description |
---|---|
DateOnly | A |
FirstDayOfMonth(DateOnly)
Gets a date representing the first day of the current month.
Declaration
public static DateOnly FirstDayOfMonth(this DateOnly value)
Parameters
Type | Name | Description |
---|---|---|
DateOnly | value | The current date. |
Returns
Type | Description |
---|---|
DateOnly | A |
GetIso8601WeekOfYear(DateOnly)
Gets the ISO-8601 week number of the year for the current date.
Declaration
public static int GetIso8601WeekOfYear(this DateOnly value)
Parameters
Type | Name | Description |
---|---|---|
DateOnly | 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(DateOnly)
Returns a value indicating whether the year represented by the current
Declaration
public static bool IsLeapYear(this DateOnly value)
Parameters
Type | Name | Description |
---|---|---|
DateOnly | value | The date whose year to check. |
Returns
Type | Description |
---|---|
System.Boolean | true if the year represented by |
Last(DateOnly, DayOfWeek)
Gets a date representing the final occurence of a specified day of the week in the current month.
Declaration
public static DateOnly Last(this DateOnly value, DayOfWeek dayOfWeek)
Parameters
Type | Name | Description |
---|---|---|
DateOnly | value | The current date. |
DayOfWeek | dayOfWeek | The day of the week. |
Returns
Type | Description |
---|---|
DateOnly | A |
LastDayOfMonth(DateOnly)
Gets a date representing the last day of the current month.
Declaration
public static DateOnly LastDayOfMonth(this DateOnly value)
Parameters
Type | Name | Description |
---|---|---|
DateOnly | value | The current date. |
Returns
Type | Description |
---|---|
DateOnly | A |
Next(DateOnly, DayOfWeek)
Gets a date representing the next occurence of a specified day of the week in the current month.
Declaration
public static DateOnly Next(this DateOnly value, DayOfWeek dayOfWeek)
Parameters
Type | Name | Description |
---|---|---|
DateOnly | value | The current date. |
DayOfWeek | dayOfWeek | The day of the week. |
Returns
Type | Description |
---|---|
DateOnly | A |
ToUnixTimeMilliseconds(DateOnly, TimeOnly)
Returns the number of milliseconds that have elapsed since 1970-01-01T00:00:00.000Z.
Declaration
public static long ToUnixTimeMilliseconds(this DateOnly value, TimeOnly time)
Parameters
Type | Name | Description |
---|---|---|
DateOnly | value | The current date. |
TimeOnly | time | A reference time to use with the current date. |
Returns
Type | Description |
---|---|
System.Int64 | The number of milliseconds that have elapsed since 1970-01-01T00:00:00.000Z. |
ToUnixTimeSeconds(DateOnly, TimeOnly)
Returns the number of seconds that have elapsed since 1970-01-01T00:00:00.000Z.
Declaration
public static long ToUnixTimeSeconds(this DateOnly value, TimeOnly time)
Parameters
Type | Name | Description |
---|---|---|
DateOnly | value | The current date. |
TimeOnly | time | A reference time to use with the current date. |
Returns
Type | Description |
---|---|
System.Int64 | The number of seconds that have elapsed since 1970-01-01T00:00:00.000Z. |