C# Class Aqueduct.Extensions.Dates

Summary for the Dates class
Datei anzeigen Open project: aqueduct/Aqueduct.SitecoreLib

Public Methods

Method Description
CountWeekdays ( this startTime, System.DateTime endTime ) : int

Counts the number of weekdays between two dates.

CountWeekends ( this startTime, System.DateTime endTime ) : int

Counts the number of weekends between two dates.

DaysAgo ( this days ) : System.DateTime

Returns a date in the past by days.

DaysFromNow ( this days ) : System.DateTime

Returns a date in the future by days.

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"

HoursAgo ( this hours ) : System.DateTime

Returns a date in the past by hours.

HoursFromNow ( this hours ) : System.DateTime

Returns a date in the future by hours.

IsDate ( this dt ) : bool

Verifies if the object is a date

IsWeekDay ( this dt ) : bool

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

IsWeekEnd ( this dt ) : bool

Checks to see if the date is Saturday or Sunday

MinutesAgo ( this minutes ) : System.DateTime

Returns a date in the past by minutes

MinutesFromNow ( this minutes ) : System.DateTime

Returns a date in the future by minutes.

ReadableDiff ( this startTime, System.DateTime endTime ) : string

Displays the difference in time between the two dates. Return example is "12 years 4 months 24 days 8 hours 33 minutes 5 seconds"

SecondsAgo ( this seconds ) : System.DateTime

Gets a date in the past according to seconds

SecondsFromNow ( this seconds ) : System.DateTime

Gets a date in the future by seconds.

TimeDiff ( this startTime, System.DateTime endTime ) : string

Displays the difference in time between the two dates. Return example is "12 years 4 months 24 days 8 hours 33 minutes 5 seconds"

Private Methods

Method Description
FormatString ( this str, string previousStr, int t ) : string

Remove leading strings with zeros and adjust for singular/plural

GetSuffix ( int dayNumber ) : string

Method Details

CountWeekdays() public static method

Counts the number of weekdays between two dates.
public static CountWeekdays ( this startTime, System.DateTime endTime ) : int
startTime this The start time.
endTime System.DateTime The end time.
return int

CountWeekends() public static method

Counts the number of weekends between two dates.
public static CountWeekends ( this startTime, System.DateTime endTime ) : int
startTime this The start time.
endTime System.DateTime The end time.
return int

DaysAgo() public static method

Returns a date in the past by days.
public static DaysAgo ( this days ) : System.DateTime
days this The days.
return System.DateTime

DaysFromNow() public static method

Returns a date in the future by days.
public static DaysFromNow ( this days ) : System.DateTime
days this The days.
return System.DateTime

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

HoursAgo() public static method

Returns a date in the past by hours.
public static HoursAgo ( this hours ) : System.DateTime
hours this The hours.
return System.DateTime

HoursFromNow() public static method

Returns a date in the future by hours.
public static HoursFromNow ( this hours ) : System.DateTime
hours this The hours.
return System.DateTime

IsDate() public static method

Verifies if the object is a date
public static IsDate ( this dt ) : bool
dt this The dt.
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

Checks to see if the date is Saturday or Sunday
public static IsWeekEnd ( this dt ) : bool
dt this The dt.
return bool

MinutesAgo() public static method

Returns a date in the past by minutes
public static MinutesAgo ( this minutes ) : System.DateTime
minutes this The minutes.
return System.DateTime

MinutesFromNow() public static method

Returns a date in the future by minutes.
public static MinutesFromNow ( this minutes ) : System.DateTime
minutes this The minutes.
return System.DateTime

ReadableDiff() public static method

Displays the difference in time between the two dates. Return example is "12 years 4 months 24 days 8 hours 33 minutes 5 seconds"
public static ReadableDiff ( this startTime, System.DateTime endTime ) : string
startTime this The start time.
endTime System.DateTime The end time.
return string

SecondsAgo() public static method

Gets a date in the past according to seconds
public static SecondsAgo ( this seconds ) : System.DateTime
seconds this The seconds.
return System.DateTime

SecondsFromNow() public static method

Gets a date in the future by seconds.
public static SecondsFromNow ( this seconds ) : System.DateTime
seconds this The seconds.
return System.DateTime

TimeDiff() public static method

Displays the difference in time between the two dates. Return example is "12 years 4 months 24 days 8 hours 33 minutes 5 seconds"
public static TimeDiff ( this startTime, System.DateTime endTime ) : string
startTime this The start time.
endTime System.DateTime The end time.
return string