Class DateTimeExtensions
This static class holds methods that can be used to express MongoDB specific operations in LINQ queries.
public static class DateTimeExtensions
- Inheritance
-
DateTimeExtensions
- Inherited Members
Methods
Add(DateTime, long, DateTimeUnit)
Adds a value of the specified unit to a DateTime.
public static DateTime Add(this DateTime @this, long value, DateTimeUnit unit)
Parameters
thisDateTimeThe original DateTime.
valuelongThe value to be added.
unitDateTimeUnitThe unit.
Returns
- DateTime
The resulting DateTime.
Add(DateTime, long, DateTimeUnit, string)
Adds a value of the specified unit to a DateTime taking a timezone into consideration.
public static DateTime Add(this DateTime @this, long value, DateTimeUnit unit, string timezone)
Parameters
thisDateTimeThe original DateTime.
valuelongThe value to be added.
unitDateTimeUnitThe unit.
timezonestringThe timezone.
Returns
- DateTime
The resulting DateTime.
Remarks
See the server documentation for $dateAdd for information on timezones in MongoDB.
Add(DateTime, TimeSpan, string)
Adds a TimeSpan value to a DateTime taking a timezone into consideration.
public static DateTime Add(this DateTime @this, TimeSpan value, string timezone)
Parameters
thisDateTimeThe original DateTime.
valueTimeSpanThe value to be added.
timezonestringThe timezone.
Returns
- DateTime
The resulting DateTime.
Remarks
See the server documentation for $dateAdd for information on timezones in MongoDB.
AddDays(DateTime, double, string)
Adds a value in days to a DateTime taking a timezone into consideration.
public static DateTime AddDays(this DateTime @this, double value, string timezone)
Parameters
thisDateTimeThe original DateTime.
valuedoubleThe value to be added.
timezonestringThe timezone.
Returns
- DateTime
The resulting DateTime.
Remarks
See the server documentation for $dateAdd for information on timezones in MongoDB.
AddHours(DateTime, double, string)
Adds a value in hours to a DateTime taking a timezone into consideration.
public static DateTime AddHours(this DateTime @this, double value, string timezone)
Parameters
thisDateTimeThe original DateTime.
valuedoubleThe value to be added.
timezonestringThe timezone.
Returns
- DateTime
The resulting DateTime.
Remarks
See the server documentation for $dateAdd for information on timezones in MongoDB.
AddMilliseconds(DateTime, double, string)
Adds a value in milliseconds to a DateTime taking a timezone into consideration.
public static DateTime AddMilliseconds(this DateTime @this, double value, string timezone)
Parameters
thisDateTimeThe original DateTime.
valuedoubleThe value to be added.
timezonestringThe timezone.
Returns
- DateTime
The resulting DateTime.
Remarks
See the server documentation for $dateAdd for information on timezones in MongoDB.
AddMinutes(DateTime, double, string)
Adds a value in minutes to a DateTime taking a timezone into consideration.
public static DateTime AddMinutes(this DateTime @this, double value, string timezone)
Parameters
thisDateTimeThe original DateTime.
valuedoubleThe value to be added.
timezonestringThe timezone.
Returns
- DateTime
The resulting DateTime.
Remarks
See the server documentation for $dateAdd for information on timezones in MongoDB.
AddMonths(DateTime, int, string)
Adds a value in months to a DateTime taking a timezone into consideration.
public static DateTime AddMonths(this DateTime @this, int value, string timezone)
Parameters
Returns
- DateTime
The resulting DateTime.
Remarks
See the server documentation for $dateAdd for information on timezones in MongoDB.
AddQuarters(DateTime, int)
Adds a value in quarters to a DateTime.
public static DateTime AddQuarters(this DateTime @this, int value)
Parameters
Returns
- DateTime
The resulting DateTime.
AddQuarters(DateTime, int, string)
Adds a value in quarters to a DateTime taking a timezone into consideration.
public static DateTime AddQuarters(this DateTime @this, int value, string timezone)
Parameters
Returns
- DateTime
The resulting DateTime.
Remarks
See the server documentation for $dateAdd for information on timezones in MongoDB.
AddSeconds(DateTime, double, string)
Adds a value in seconds to a DateTime taking a timezone into consideration.
public static DateTime AddSeconds(this DateTime @this, double value, string timezone)
Parameters
thisDateTimeThe original DateTime.
valuedoubleThe value to be added.
timezonestringThe timezone.
Returns
- DateTime
The resulting DateTime.
Remarks
See the server documentation for $dateAdd for information on timezones in MongoDB.
AddWeeks(DateTime, int)
Adds a value in weeks to a DateTime taking.
public static DateTime AddWeeks(this DateTime @this, int value)
Parameters
Returns
- DateTime
The resulting DateTime.
AddWeeks(DateTime, int, string)
Adds a value in weeks to a DateTime taking a timezone into consideration.
public static DateTime AddWeeks(this DateTime @this, int value, string timezone)
Parameters
Returns
- DateTime
The resulting DateTime.
Remarks
See the server documentation for $dateAdd for information on timezones in MongoDB.
AddYears(DateTime, int, string)
Adds a value in years to a DateTime taking a timezone into consideration.
public static DateTime AddYears(this DateTime @this, int value, string timezone)
Parameters
Returns
- DateTime
The resulting DateTime.
Remarks
See the server documentation for $dateAdd for information on timezones in MongoDB.
Subtract(DateTime, DateTime, DateTimeUnit)
Subtracts the start date from the end date returning the result in the specified unit.
public static long Subtract(this DateTime @this, DateTime startDate, DateTimeUnit unit)
Parameters
thisDateTimeThe original DateTime.
startDateDateTimeThe start date.
unitDateTimeUnitThe unit.
Returns
- long
The result.
Subtract(DateTime, DateTime, DateTimeUnit, string)
Subtracts the start date from the end date returning the result in the specified unit taking a timezone into consideration.
public static long Subtract(this DateTime @this, DateTime startDate, DateTimeUnit unit, string timezone)
Parameters
thisDateTimeThe original DateTime.
startDateDateTimeThe start date.
unitDateTimeUnitThe unit.
timezonestringThe timezone.
Returns
- long
The result.
Remarks
See the server documentation for $dateDiff for information on timezones in MongoDB.
Subtract(DateTime, DateTime, string)
Subtracts the start date from the end date returning a TimeSpan taking a timezone into consideration.
public static TimeSpan Subtract(this DateTime @this, DateTime value, string timezone)
Parameters
thisDateTimeThe original DateTime.
valueDateTimeThe value to be added.
timezonestringThe timezone.
Returns
- TimeSpan
The resulting DateTime.
Remarks
See the server documentation for $dateDiff for information on timezones in MongoDB.
Subtract(DateTime, long, DateTimeUnit)
Subtracts a value of the specified unit from a DateTime.
public static DateTime Subtract(this DateTime @this, long value, DateTimeUnit unit)
Parameters
thisDateTimeThe original DateTime.
valuelongThe value to be added.
unitDateTimeUnitThe unit.
Returns
- DateTime
The resulting DateTime.
Subtract(DateTime, long, DateTimeUnit, string)
Subtracts a value of the specified unit from a DateTime taking a timezone into consideration.
public static DateTime Subtract(this DateTime @this, long value, DateTimeUnit unit, string timezone)
Parameters
thisDateTimeThe original DateTime.
valuelongThe value to be added.
unitDateTimeUnitThe unit.
timezonestringThe timezone.
Returns
- DateTime
The resulting DateTime.
Remarks
See the server documentation for $dateSubtract for information on timezones in MongoDB.
Subtract(DateTime, TimeSpan, string)
Subtracts a TimeSpan from a date taking a timezone into consideration.
public static DateTime Subtract(this DateTime @this, TimeSpan value, string timezone)
Parameters
thisDateTimeThe original DateTime.
valueTimeSpanThe value to be added.
timezonestringThe timezone.
Returns
- DateTime
The resulting DateTime.
Remarks
See the server documentation for $dateSubtract for information on timezones in MongoDB.
ToString(DateTime, string, string)
Converts a DateTime value to a string.
public static string ToString(this DateTime @this, string format, string timezone)
Parameters
thisDateTimeThe DateTime value.
formatstringThe format string (optional, can be null).
timezonestringThe timezone to use in the returned string (optional, can be null).
Returns
- string
The DateTime value converted to a string.
Truncate(DateTime, DateTimeUnit)
Truncates a DateTime value to the specified unit.
public static DateTime Truncate(this DateTime @this, DateTimeUnit unit)
Parameters
thisDateTimeThe original DateTime.
unitDateTimeUnitThe unit.
Returns
- DateTime
The resulting DateTime.
Truncate(DateTime, DateTimeUnit, long)
Truncates a DateTime value to the specified unit and bin size.
public static DateTime Truncate(this DateTime @this, DateTimeUnit unit, long binSize)
Parameters
thisDateTimeThe original DateTime.
unitDateTimeUnitThe unit.
binSizelongThe bin size.
Returns
- DateTime
The resulting DateTime.
Truncate(DateTime, DateTimeUnit, long, string)
Truncates a DateTime value to the specified unit and bin size taking a timezone into consideration.
public static DateTime Truncate(this DateTime @this, DateTimeUnit unit, long binSize, string timezone)
Parameters
thisDateTimeThe original DateTime.
unitDateTimeUnitThe unit.
binSizelongThe bin size.
timezonestringThe timezone.
Returns
- DateTime
The resulting DateTime.
Remarks
See the server documentation for $dateTrunc for information on timezones in MongoDB.
Week(DateTime)
Returns the week number of a specified DateTime value.
public static int Week(this DateTime @this)
Parameters
thisDateTimeThe DateTime value.
Returns
- int
The week number of a specified DateTime value.
Week(DateTime, string)
Returns the week number of a specified DateTime value.
public static int Week(this DateTime @this, string timezone)
Parameters
Returns
- int
The week number of a specified DateTime value.