Class DateTimeAndTimeSpanExtensions
Extensions for the DateTime
and TimeSpan
structs.
Inheritance
DateTimeAndTimeSpanExtensions
Assembly: Acoustics.Shared.dll
Syntax
public static class DateTimeAndTimeSpanExtensions
Methods
|
Improve this Doc
View Source
Absolute(TimeSpan)
Declaration
public static TimeSpan Absolute(this TimeSpan span)
Parameters
Returns
|
Improve this Doc
View Source
Ceiling(DateTimeOffset, TimeSpan)
Declaration
public static DateTimeOffset Ceiling(this DateTimeOffset date, TimeSpan interval)
Parameters
Returns
|
Improve this Doc
View Source
Divide(TimeSpan, Double)
Divides a timespan by an scalar value.
Declaration
public static TimeSpan Divide(this TimeSpan dividend, double divisor)
Parameters
Returns
|
Improve this Doc
View Source
Divide(TimeSpan, Int32)
Divides a timespan by an scalar value.
Declaration
public static TimeSpan Divide(this TimeSpan dividend, int divisor)
Parameters
Returns
|
Improve this Doc
View Source
Divide(TimeSpan, TimeSpan)
Divides a timespan by an timespan and returns a scalar factor.
Declaration
public static double Divide(this TimeSpan dividend, TimeSpan divisor)
Parameters
Returns
|
Improve this Doc
View Source
Floor(DateTimeOffset, TimeSpan)
Declaration
public static DateTimeOffset Floor(this DateTimeOffset date, TimeSpan interval)
Parameters
Returns
|
Improve this Doc
View Source
Humanise(DateTime, DateTime, Boolean)
Get a human-readable string of difference between two DateTimes (eg. 2 hours, 2 hours ago, in 2 hours).
Declaration
public static string Humanise(this DateTime first, DateTime second, bool addSuffixOrPrefix = false)
Parameters
Type |
Name |
Description |
DateTime |
first |
First time (should be earlier).
|
DateTime |
second |
Second time (should be later).
|
Boolean |
addSuffixOrPrefix |
The add Suffix Or Prefix.
|
Returns
Type |
Description |
String |
Human-readable string of difference between two DateTimes.
|
|
Improve this Doc
View Source
Humanise(DateTimeOffset, DateTimeOffset, Boolean)
Get a human-readable string of difference between two DateTimes (eg. 2 hours, 2 hours ago, in 2 hours).
Declaration
public static string Humanise(this DateTimeOffset first, DateTimeOffset second, bool addSuffixOrPrefix = false)
Parameters
Type |
Name |
Description |
DateTimeOffset |
first |
First time (should be earlier).
|
DateTimeOffset |
second |
Second time (should be later).
|
Boolean |
addSuffixOrPrefix |
The add Suffix Or Prefix.
|
Returns
Type |
Description |
String |
Human-readable string of difference between two DateTimes.
|
|
Improve this Doc
View Source
Humanise(TimeSpan, Boolean)
Get a human readable representation of the time span.
Declaration
public static string Humanise(this TimeSpan timeSpan, bool addSuffixOrPrefix = false)
Parameters
Type |
Name |
Description |
TimeSpan |
timeSpan |
The time span.
|
Boolean |
addSuffixOrPrefix |
True to add a suffix or prefix as appropriate. False to not add a suffix or prefix.
|
Returns
Type |
Description |
String |
Human readable representation of the time span.
|
|
Improve this Doc
View Source
Max(TimeSpan, TimeSpan)
Declaration
public static TimeSpan Max(this TimeSpan t1, TimeSpan t2)
Parameters
Returns
|
Improve this Doc
View Source
Min(TimeSpan, TimeSpan)
Declaration
public static TimeSpan Min(this TimeSpan t1, TimeSpan t2)
Parameters
Returns
|
Improve this Doc
View Source
Modulo(TimeSpan, TimeSpan)
Divides a timespan by an timespan and the remainder.
Declaration
public static TimeSpan Modulo(this TimeSpan dividend, TimeSpan divisor)
Parameters
Returns
|
Improve this Doc
View Source
Multiply(TimeSpan, Double)
Multiplies a timespan by a double value.
Declaration
public static TimeSpan Multiply(this TimeSpan multiplicand, double multiplier)
Parameters
Returns
|
Improve this Doc
View Source
Multiply(TimeSpan, Int32)
Multiplies a timespan by a scalar value.
Declaration
public static TimeSpan Multiply(this TimeSpan multiplicand, int multiplier)
Parameters
Returns
|
Improve this Doc
View Source
Round(DateTime, TimeSpan)
Declaration
public static DateTime Round(this DateTime datetime, TimeSpan roundingInterval)
Parameters
Returns
Remarks
|
Improve this Doc
View Source
Round(DateTimeOffset, TimeSpan)
Declaration
public static DateTimeOffset Round(this DateTimeOffset date, TimeSpan roundingInterval)
Parameters
Returns
|
Improve this Doc
View Source
Round(TimeSpan, TimeSpan)
Declaration
public static TimeSpan Round(this TimeSpan time, TimeSpan roundingInterval)
Parameters
Returns
Remarks
|
Improve this Doc
View Source
Round(TimeSpan, TimeSpan, MidpointRounding)
Declaration
public static TimeSpan Round(this TimeSpan time, TimeSpan roundingInterval, MidpointRounding roundingType)
Parameters
Returns
Remarks
|
Improve this Doc
View Source
RoundToTimeOfDay(DateTimeOffset, TimeSpan, DateTimeAndTimeSpanExtensions.RoundingDirection)
Round a date to a time of day.
Declaration
public static DateTimeOffset RoundToTimeOfDay(this DateTimeOffset date, TimeSpan timeOfDay, DateTimeAndTimeSpanExtensions.RoundingDirection direction)
Parameters
Returns
Remarks
|
Improve this Doc
View Source
ToIso8601SafeString(DateTimeOffset)
Formats a date in an ISO8601 format that is compact
and does not contain colons.
Declaration
public static string ToIso8601SafeString(this DateTimeOffset date)
Parameters
Type |
Name |
Description |
DateTimeOffset |
date |
The date to convert to a string.
|
Returns
Type |
Description |
String |
The resulting string.
|
|
Improve this Doc
View Source
ToJavascriptTimestamp(DateTime)
Gets the DateTime formatted as a javascript timestamp.
Declaration
public static long ToJavascriptTimestamp(this DateTime value)
Parameters
Type |
Name |
Description |
DateTime |
value |
The value.
|
Returns
Type |
Description |
Int64 |
Javascript timestamp.
|
|
Improve this Doc
View Source
ToJavascriptTimestamp(DateTimeOffset)
Gets the DateTimeOffset formatted as a javascript timestamp.
Declaration
public static long ToJavascriptTimestamp(this DateTimeOffset value)
Parameters
Returns
Type |
Description |
Int64 |
Javascript timestamp.
|
|
Improve this Doc
View Source
ToTimeZoneString(TimeSpan)
Gets the minutes and seconds of a time span in the format required for an offset from UTC.
Declaration
public static string ToTimeZoneString(this TimeSpan ts)
Parameters
Type |
Name |
Description |
TimeSpan |
ts |
The time span.
|
Returns
Type |
Description |
String |
Time zone offset formatted string.
|