Show / Hide Table of Contents

Class DateUtility

Inheritance
Object
DateUtility
Namespace: SuperOffice.Util
Assembly: SoCore.dll
Syntax
public static class DateUtility : Object

Methods

AddReporterHalfYears(DateTime, Int32)

Adds the required amount of half years, then subtracts a second.

Declaration
public static DateTime AddReporterHalfYears(this DateTime date, int halfYearCount = 1)
Parameters
Type Name Description
DateTime date
Int32 halfYearCount
Returns
Type Description
DateTime

AddReporterMonth(DateTime)

Adds a month, then subtracts a second.

Declaration
public static DateTime AddReporterMonth(this DateTime date)
Parameters
Type Name Description
DateTime date
Returns
Type Description
DateTime

AddReporterMonths(DateTime, Int32)

Adds the required amount of months, then subtracts a second.

Declaration
public static DateTime AddReporterMonths(this DateTime date, int monthCount)
Parameters
Type Name Description
DateTime date
Int32 monthCount
Returns
Type Description
DateTime

AddReporterQuarter(DateTime)

Adds a quarter of a year, then subtracts a second.

Declaration
public static DateTime AddReporterQuarter(this DateTime date)
Parameters
Type Name Description
DateTime date
Returns
Type Description
DateTime

AddReporterQuarters(DateTime, Int32)

Adds the required amount of quarters of a year, then subtracts a second.

Declaration
public static DateTime AddReporterQuarters(this DateTime date, int quarterCount)
Parameters
Type Name Description
DateTime date
Int32 quarterCount
Returns
Type Description
DateTime

AddReporterWeek(DateTime)

Adds a week, then subtracts a second.

Declaration
public static DateTime AddReporterWeek(this DateTime date)
Parameters
Type Name Description
DateTime date
Returns
Type Description
DateTime

AddReporterWeeks(DateTime, Int32)

Adds the required number of weeks, then subtracts a second.

Declaration
public static DateTime AddReporterWeeks(this DateTime date, int weekCount)
Parameters
Type Name Description
DateTime date
Int32 weekCount
Returns
Type Description
DateTime

AddReporterYear(DateTime)

Adds a year, then subtracts a second.

Declaration
public static DateTime AddReporterYear(this DateTime date)
Parameters
Type Name Description
DateTime date
Returns
Type Description
DateTime

AddReporterYears(DateTime, Int32)

Adds the required amount of years, then subtracts a second.

Declaration
public static DateTime AddReporterYears(this DateTime date, int yearCount)
Parameters
Type Name Description
DateTime date
Int32 yearCount
Returns
Type Description
DateTime

CalcSeconds(DateTime)

Declaration
public static int CalcSeconds(this DateTime dt)
Parameters
Type Name Description
DateTime dt
Returns
Type Description
Int32

CalculateEndDate(DateTime, Int32, DurationUnit)

Adds the amount of days/months depending on the DurationUnit specified.

Declaration
public static DateTime CalculateEndDate(this DateTime date, int duration, DurationUnit unit)
Parameters
Type Name Description
DateTime date
Int32 duration
DurationUnit unit
Returns
Type Description
DateTime

CalculateEndDate(Int32, DurationUnit)

Adds the amount of days/months depending on the DurationUnit specified to the current datetime.

Declaration
public static DateTime CalculateEndDate(int duration, DurationUnit unit)
Parameters
Type Name Description
Int32 duration
DurationUnit unit
Returns
Type Description
DateTime

CloseEnoughTo(DateTime, DateTime, Int32)

Declaration
public static bool CloseEnoughTo(this DateTime a, DateTime b, int toleranceSeconds = 30)
Parameters
Type Name Description
DateTime a
DateTime b
Int32 toleranceSeconds
Returns
Type Description
Boolean

DropFractionsOfSecond(DateTime, Nullable<DateTimeKind>)

Return a DateTime that is the same as the input parameter, but eliminate all sub-second parts by truncating them. This is how we store datetimes in the database, and should generally be done to avoid meaningless inequalities.

Declaration
public static DateTime DropFractionsOfSecond(this DateTime input, Nullable<DateTimeKind> kind = null)
Parameters
Type Name Description
DateTime input

Input datetime

Nullable<DateTimeKind> kind

Optional override of DateTime.Kind; the returned value will have this kind. If null or not specified then the original Kind will be propagated

Returns
Type Description
DateTime

Earliest(DateTime[])

Declaration
public static DateTime Earliest(params DateTime[] dates)
Parameters
Type Name Description
DateTime[] dates
Returns
Type Description
DateTime

GetFirstInMonth(DateTime)

Declaration
public static DateTime GetFirstInMonth(this DateTime date)
Parameters
Type Name Description
DateTime date
Returns
Type Description
DateTime

GetStartOfHalfYear(DateTime)

Gets the start of the half year of the input date.

Declaration
public static DateTime GetStartOfHalfYear(this DateTime date)
Parameters
Type Name Description
DateTime date
Returns
Type Description
DateTime

GetStartOfMonth(DateTime)

Gets the start of the month of the input date.

Declaration
public static DateTime GetStartOfMonth(this DateTime date)
Parameters
Type Name Description
DateTime date
Returns
Type Description
DateTime

GetStartOfQuarter(DateTime)

Gets the start of the quarter that the input date is within.

Declaration
public static DateTime GetStartOfQuarter(this DateTime date)
Parameters
Type Name Description
DateTime date
Returns
Type Description
DateTime

Returns a datetime representing the first second of the first day of the quarter.

GetStartOfWeek(DateTime, Boolean)

Gets the start of the week of the input date.

Declaration
public static DateTime GetStartOfWeek(this DateTime date, bool weekStartsOnSunday = false)
Parameters
Type Name Description
DateTime date
Boolean weekStartsOnSunday
Returns
Type Description
DateTime

GetStartOfYear(DateTime)

Gets the start of the year of the input date.

Declaration
public static DateTime GetStartOfYear(this DateTime date)
Parameters
Type Name Description
DateTime date
Returns
Type Description
DateTime

GetWeekStartDelta(DateTime, Boolean)

Calculate how many days we need to go back from given date to get to the start-of-week day. This is sunday or monday depending on preference. In .NET, dow 0 is sunday.

Declaration
public static int GetWeekStartDelta(this DateTime date, bool weekStartsOnSunday = false)
Parameters
Type Name Description
DateTime date
Boolean weekStartsOnSunday
Returns
Type Description
Int32

Day of week delta, a negative value which when added to date will produce start of first day

Latest(DateTime[])

Declaration
public static DateTime Latest(params DateTime[] dates)
Parameters
Type Name Description
DateTime[] dates
Returns
Type Description
DateTime

Round(DateTime, Int32, RoundDirection)

Declaration
public static DateTime Round(DateTime dateTime, int minutes, RoundDirection direction)
Parameters
Type Name Description
DateTime dateTime
Int32 minutes
RoundDirection direction
Returns
Type Description
DateTime

SetTime(DateTime, Int32, Int32, Int32, Int32)

Declaration
public static DateTime SetTime(this DateTime dt, int hour, int minute, int second = 0, int millisecond = 0)
Parameters
Type Name Description
DateTime dt
Int32 hour
Int32 minute
Int32 second
Int32 millisecond
Returns
Type Description
DateTime

SetToEndOfDay(DateTime)

Copies date and sets the time component to be 23:59:59.

Declaration
public static DateTime SetToEndOfDay(this DateTime date)
Parameters
Type Name Description
DateTime date
Returns
Type Description
DateTime

A copy of date, with the time component set to 23:59:59

ToMinutes(Double)

Declaration
public static int ToMinutes(this double seconds)
Parameters
Type Name Description
Double seconds
Returns
Type Description
Int32

ToMinutes(TimeSpan)

Declaration
public static int ToMinutes(this TimeSpan span)
Parameters
Type Name Description
TimeSpan span
Returns
Type Description
Int32
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top