C# Class Utilities.Extensions.DateExtensions

Mostra file Open project: feanz/Utilities

Public Methods

Method Description
Diff ( this dateOne, System.DateTime dateTwo ) : System.TimeSpan

Diffs the specified date.

DiffDays ( this dateOne, System.DateTime dateTwo ) : double

Returns a double indicating the number of days between two dates (past is negative)

DiffDays ( this dateOne, string dateTwo ) : double

Returns a double indicating the number of days between two dates (past is negative)

DiffHours ( this dateOne, System.DateTime dateTwo ) : double

Returns a double indicating the number of days between two dates (past is negative)

DiffHours ( this dateOne, string dateTwo ) : double

Returns a double indicating the number of days between two dates (past is negative)

DiffMinutes ( this dateOne, System.DateTime dateTwo ) : double

Returns a double indicating the number of days between two dates (past is negative)

DiffMinutes ( this dateOne, string dateTwo ) : double

Returns a double indicating the number of days between two dates (past is negative)

GetDateDayWithSuffix ( this date ) : string

Given a datetime object, returns the formatted day, "15th"

GetFormattedMonthAndDay ( this date ) : string

Given a datetime object, returns the formatted month and day, i.e. "April 15th"

IsLastDayOfMonth ( this date ) : bool

Determines whether [is last day of month] [the specified date].

IsLeapYear ( this date ) : bool

Determines whether [is leap year] [the specified date].

IsWeekDay ( this dt ) : bool

Checks to see if the date is a week day (Mon - Fri)

IsWeekend ( this source ) : bool

Determines whether the specified date is a weekend.

LastDayOfMonth ( this date ) : int

Gets the Last the day of month.

SetDay ( this source, int day ) : System.DateTime

Returns a new instance of DateTime with a different day of the month.

SetMonth ( this source, int month ) : System.DateTime

Returns a new instance of DateTime with a different month.

SetYear ( this source, int year ) : System.DateTime

Returns a new instance of DateTime with a different year.

ToMigrationString ( this dt ) : string

Returns a datetime formatted as a string in yyyyMMddhhmm

Method Details

Diff() public static method

Diffs the specified date.
public static Diff ( this dateOne, System.DateTime dateTwo ) : System.TimeSpan
dateOne this The date one.
dateTwo System.DateTime The date two.
return System.TimeSpan

DiffDays() public static method

Returns a double indicating the number of days between two dates (past is negative)
public static DiffDays ( this dateOne, System.DateTime dateTwo ) : double
dateOne this The date one.
dateTwo System.DateTime The date two.
return double

DiffDays() public static method

Returns a double indicating the number of days between two dates (past is negative)
public static DiffDays ( this dateOne, string dateTwo ) : double
dateOne this The date one.
dateTwo string The date two.
return double

DiffHours() public static method

Returns a double indicating the number of days between two dates (past is negative)
public static DiffHours ( this dateOne, System.DateTime dateTwo ) : double
dateOne this The date one.
dateTwo System.DateTime The date two.
return double

DiffHours() public static method

Returns a double indicating the number of days between two dates (past is negative)
public static DiffHours ( this dateOne, string dateTwo ) : double
dateOne this The date one.
dateTwo string The date two.
return double

DiffMinutes() public static method

Returns a double indicating the number of days between two dates (past is negative)
public static DiffMinutes ( this dateOne, System.DateTime dateTwo ) : double
dateOne this The date one.
dateTwo System.DateTime The date two.
return double

DiffMinutes() public static method

Returns a double indicating the number of days between two dates (past is negative)
public static DiffMinutes ( this dateOne, string dateTwo ) : double
dateOne this The date one.
dateTwo string The date two.
return double

GetDateDayWithSuffix() public static method

Given a datetime object, returns the formatted day, "15th"
public static GetDateDayWithSuffix ( this date ) : string
date this The date to extract the string from
return string

GetFormattedMonthAndDay() public static method

Given a datetime object, returns the formatted month and day, i.e. "April 15th"
public static GetFormattedMonthAndDay ( this date ) : string
date this The date to extract the string from
return string

IsLastDayOfMonth() public static method

Determines whether [is last day of month] [the specified date].
public static IsLastDayOfMonth ( this date ) : bool
date this The date.
return bool

IsLeapYear() public static method

Determines whether [is leap year] [the specified date].
public static IsLeapYear ( this date ) : bool
date this The date.
return bool

IsWeekDay() public static method

Checks to see if the date is a week day (Mon - Fri)
public static IsWeekDay ( this dt ) : bool
dt this The dt.
return bool

IsWeekend() public static method

Determines whether the specified date is a weekend.
public static IsWeekend ( this source ) : bool
source this Source date
return bool

LastDayOfMonth() public static method

Gets the Last the day of month.
public static LastDayOfMonth ( this date ) : int
date this The date.
return int

SetDay() public static method

Returns a new instance of DateTime with a different day of the month.
public static SetDay ( this source, int day ) : System.DateTime
source this Base DateTime object to modify
day int Day of the month (1-31)
return System.DateTime

SetMonth() public static method

Returns a new instance of DateTime with a different month.
public static SetMonth ( this source, int month ) : System.DateTime
source this Base DateTime object to modify
month int The month as an integer (1-12)
return System.DateTime

SetYear() public static method

Returns a new instance of DateTime with a different year.
public static SetYear ( this source, int year ) : System.DateTime
source this Base DateTime object to modify
year int The year
return System.DateTime

ToMigrationString() public static method

Returns a datetime formatted as a string in yyyyMMddhhmm
public static ToMigrationString ( this dt ) : string
dt this The datetime to convert
return string