C# Class Aspectacular.DateTimeExtensions

Contains utility & convenience DateTime methods
Datei anzeigen Open project: vgribok/Aspectacular

Public Methods

Method Description
FromSortableIntDateTime ( this sortableDateTime, DateTimeKind dtKind = DateTimeKind.Unspecified ) : System.DateTime

Returns DateTime created from an integer in the YYYYMMDD, YYYYMMDDHHmmss, or YYYYMMDDHHmmssFFF format.

FromSortableIntDateTime ( this sortableDateTime, DateTimeKind dtKind = DateTimeKind.Unspecified ) : DateTime?

Returns DateTime created from an integer in the YYYYMMDD, YYYYMMDDHHmmss, or YYYYMMDDHHmmssFFF format.

FromSortableIntTime ( this sortableDateTime, System.DateTime datePart = default(DateTime) ) : System.DateTime

Returns time value via DateTime result created from integer in the HHmmss or HHmmssFFF format. Optional "FFF" is milliseconds.

FromSortableIntTime ( this sortableDateTime, System.DateTime datePart = default(DateTime) ) : DateTime?

Returns time value via DateTime result created from integer in the HHmmss or HHmmssFFF format. Optional "FFF" is milliseconds.

GoTo ( this dt, bool>.Func stopCondFunc, DateTime>.Func stepFunc ) : System.DateTime

DateTime loop functional implementation. Continues calling stepFunc while searchFunc keeps returning true: while (!searchFunc(dt)) dt = stepFunc(dt); return dt;

GoTo ( this dt, bool>.Func stopCondFunc, DateTimeOffset>.Func stepFunc ) : DateTimeOffset

DateTimeOffset loop functional implementation. Continues calling stepFunc while searchFunc keeps returning true: while (!searchFunc(dt)) dt = stepFunc(dt); return dt;

IsUtc ( this dto ) : bool

Returns true if DateTimeOffset represents UTC time.

PreviousMoment ( this dt ) : System.DateTime

Subtracts 1 tick from the given time.

PreviousMoment ( this dt ) : DateTimeOffset

Subtracts 1 tick from the given time.

Quarter ( this dt ) : int

Returns quarter number 1..4

ToDateTime ( this dto, DateTimeKind kind ) : System.DateTime
ToSortableIntDate ( this dt ) : int

Converts date part of the date time to integer in the YYYYMMDD format.

ToSortableIntTime ( this dt, bool includeMilliseconds = false ) : int

Returns integer in the format of HHmmss or HHmmssFFF. Optional "FFF" is milliseconds.

ToSortableLongDateTime ( this dt, bool includeMilliseconds = false ) : long

Returns integer in the format of YYYYMMDDHHmmss or similar with fractional seconds.

ToSortableLongTime ( this dt, bool includeMilliseconds = false ) : long

Returns integer in the format of HHmmss or HHmmssFFF. Optional "FFF" is milliseconds.

WeekOfYear ( this dt, CalendarWeekRule whatIsFirstWeek = CalendarWeekRule.FirstFourDayWeek ) : int

Returns ISO-8601 week number in the year.

Method Details

FromSortableIntDateTime() public static method

Returns DateTime created from an integer in the YYYYMMDD, YYYYMMDDHHmmss, or YYYYMMDDHHmmssFFF format.
public static FromSortableIntDateTime ( this sortableDateTime, DateTimeKind dtKind = DateTimeKind.Unspecified ) : System.DateTime
sortableDateTime this
dtKind DateTimeKind
return System.DateTime

FromSortableIntDateTime() public static method

Returns DateTime created from an integer in the YYYYMMDD, YYYYMMDDHHmmss, or YYYYMMDDHHmmssFFF format.
public static FromSortableIntDateTime ( this sortableDateTime, DateTimeKind dtKind = DateTimeKind.Unspecified ) : DateTime?
sortableDateTime this
dtKind DateTimeKind
return DateTime?

FromSortableIntTime() public static method

Returns time value via DateTime result created from integer in the HHmmss or HHmmssFFF format. Optional "FFF" is milliseconds.
public static FromSortableIntTime ( this sortableDateTime, System.DateTime datePart = default(DateTime) ) : System.DateTime
sortableDateTime this
datePart System.DateTime Date to which time will be appended.
return System.DateTime

FromSortableIntTime() public static method

Returns time value via DateTime result created from integer in the HHmmss or HHmmssFFF format. Optional "FFF" is milliseconds.
public static FromSortableIntTime ( this sortableDateTime, System.DateTime datePart = default(DateTime) ) : DateTime?
sortableDateTime this
datePart System.DateTime Date to which time will be appended.
return DateTime?

GoTo() public static method

DateTime loop functional implementation. Continues calling stepFunc while searchFunc keeps returning true: while (!searchFunc(dt)) dt = stepFunc(dt); return dt;
public static GoTo ( this dt, bool>.Func stopCondFunc, DateTime>.Func stepFunc ) : System.DateTime
dt this
stopCondFunc bool>.Func
stepFunc DateTime>.Func
return System.DateTime

GoTo() public static method

DateTimeOffset loop functional implementation. Continues calling stepFunc while searchFunc keeps returning true: while (!searchFunc(dt)) dt = stepFunc(dt); return dt;
public static GoTo ( this dt, bool>.Func stopCondFunc, DateTimeOffset>.Func stepFunc ) : DateTimeOffset
dt this
stopCondFunc bool>.Func
stepFunc DateTimeOffset>.Func
return DateTimeOffset

IsUtc() public static method

Returns true if DateTimeOffset represents UTC time.
public static IsUtc ( this dto ) : bool
dto this
return bool

PreviousMoment() public static method

Subtracts 1 tick from the given time.
public static PreviousMoment ( this dt ) : System.DateTime
dt this
return System.DateTime

PreviousMoment() public static method

Subtracts 1 tick from the given time.
public static PreviousMoment ( this dt ) : DateTimeOffset
dt this
return DateTimeOffset

Quarter() public static method

Returns quarter number 1..4
public static Quarter ( this dt ) : int
dt this
return int

ToDateTime() public static method

public static ToDateTime ( this dto, DateTimeKind kind ) : System.DateTime
dto this
kind DateTimeKind
return System.DateTime

ToSortableIntDate() public static method

Converts date part of the date time to integer in the YYYYMMDD format.
public static ToSortableIntDate ( this dt ) : int
dt this
return int

ToSortableIntTime() public static method

Returns integer in the format of HHmmss or HHmmssFFF. Optional "FFF" is milliseconds.
public static ToSortableIntTime ( this dt, bool includeMilliseconds = false ) : int
dt this
includeMilliseconds bool
return int

ToSortableLongDateTime() public static method

Returns integer in the format of YYYYMMDDHHmmss or similar with fractional seconds.
public static ToSortableLongDateTime ( this dt, bool includeMilliseconds = false ) : long
dt this
includeMilliseconds bool
return long

ToSortableLongTime() public static method

Returns integer in the format of HHmmss or HHmmssFFF. Optional "FFF" is milliseconds.
public static ToSortableLongTime ( this dt, bool includeMilliseconds = false ) : long
dt this
includeMilliseconds bool
return long

WeekOfYear() public static method

Returns ISO-8601 week number in the year.
public static WeekOfYear ( this dt, CalendarWeekRule whatIsFirstWeek = CalendarWeekRule.FirstFourDayWeek ) : int
dt this
whatIsFirstWeek CalendarWeekRule /// Tells whether the first week can be a) any incomplete week, b) a week with 4 days or /// more, or c) full week only. ///
return int