C# Class FluentDateTimeOffset.DateTimeOffsetExtensions

Static class containing Fluent DateTimeOffset extension methods.
Datei anzeigen Open project: FluentDateTime/FluentDateTime

Public Methods

Method Description
AddBusinessDays ( this current, int days ) : DateTimeOffset

Adds the given number of business days to the DateTimeOffset.

At ( this current, int hour, int minute ) : DateTimeOffset

Returns the given DateTimeOffset with hour and minutes set At given values.

At ( this current, int hour, int minute, int second ) : DateTimeOffset

Returns the given DateTimeOffset with hour and minutes and seconds set At given values.

At ( this current, int hour, int minute, int second, int milliseconds ) : DateTimeOffset

Returns the given DateTimeOffset with hour and minutes and seconds and milliseconds set At given values.

BeginningOfDay ( this date ) : DateTimeOffset

Returns the Start of the given day (the first millisecond of the given DateTimeOffset).

DecreaseTime ( this startDate, System.TimeSpan toSubtract ) : DateTimeOffset

Decreases the DateTimeOffset object with given TimeSpan value.

EndOfDay ( this date ) : DateTimeOffset

Returns the very end of the given day (the last millisecond of the last hour for the given DateTimeOffset).

FirstDayOfMonth ( this current ) : DateTimeOffset

Sets the day of the DateTimeOffset to the first day in that month.

FirstDayOfQuarter ( this current ) : DateTimeOffset

Sets the day of the DateTimeOffset to the first day in that calendar quarter. credit to http://www.devcurry.com/2009/05/find-first-and-last-day-of-current.html

FirstDayOfWeek ( this dateTime ) : DateTimeOffset

Returns a DateTimeOffset adjusted to the beginning of the week.

the beginning of the week is controlled by the current Culture

FirstDayOfYear ( this current ) : DateTimeOffset

Returns the first day of the year keeping the time component intact. Eg, 2011-02-04T06:40:20.005 => 2011-01-01T06:40:20.005

IncreaseTime ( this startDate, System.TimeSpan toAdd ) : DateTimeOffset

Increases the DateTimeOffset object with given TimeSpan value.

IsAfter ( this current, DateTimeOffset toCompareWith ) : bool

Determines whether the specified DateTimeOffset value is After then current value.

IsBefore ( this current, DateTimeOffset toCompareWith ) : bool

Determines whether the specified DateTimeOffset is before then current value.

IsInFuture ( this dateTime ) : bool

Determine if a DateTimeOffset is in the future.

IsInPast ( this dateTime ) : bool

Determine if a DateTimeOffset is in the past.

LastDayOfMonth ( this current ) : DateTimeOffset

Sets the day of the DateTimeOffset to the last day in that month.

LastDayOfQuarter ( this current ) : DateTimeOffset

Sets the day of the DateTimeOffset to the last day in that calendar quarter. credit to http://www.devcurry.com/2009/05/find-first-and-last-day-of-current.html

LastDayOfWeek ( this current ) : DateTimeOffset

Returns the last day of the week keeping the time component intact. Eg, 2011-12-24T06:40:20.005 => 2011-12-25T06:40:20.005

LastDayOfYear ( this current ) : DateTimeOffset

Returns the last day of the year keeping the time component intact. Eg, 2011-12-24T06:40:20.005 => 2011-12-31T06:40:20.005

Midnight ( this value ) : DateTimeOffset

Returns original DateTimeOffset value with time part set to midnight (alias for BeginningOfDay method).

Next ( this start, DayOfWeek day ) : DateTimeOffset

Returns first next occurrence of specified DayOfWeek.

NextDay ( this start ) : DateTimeOffset

Returns DateTimeOffset increased by 24 hours ie Next Day.

NextMonth ( this current ) : DateTimeOffset

Returns the next month keeping the time component intact. Eg, 2012-12-05T06:40:20.005 => 2013-01-05T06:40:20.005 If the next month doesn't have that many days the last day of the next month is used. Eg, 2013-01-31T06:40:20.005 => 2013-02-28T06:40:20.005

NextYear ( this start ) : DateTimeOffset

Returns the same date (same Day, Month, Hour, Minute, Second etc) in the next calendar year. If that day does not exist in next year in same month, number of missing days is added to the last day in same month next year.

Noon ( this value ) : DateTimeOffset

Returns original DateTimeOffset value with time part set to Noon (12:00:00h).

Previous ( this start, DayOfWeek day ) : DateTimeOffset

Returns first next occurrence of specified DayOfWeek.

PreviousDay ( this start ) : DateTimeOffset

Returns DateTimeOffset decreased by 24h period ie Previous Day.

PreviousMonth ( this current ) : DateTimeOffset

Returns the previous month keeping the time component intact. Eg, 2010-01-20T06:40:20.005 => 2009-12-20T06:40:20.005 If the previous month doesn't have that many days the last day of the previous month is used. Eg, 2009-03-31T06:40:20.005 => 2009-02-28T06:40:20.005

PreviousYear ( this start ) : DateTimeOffset

Returns the same date (same Day, Month, Hour, Minute, Second etc) in the previous calendar year. If that day does not exist in previous year in same month, number of missing days is added to the last day in same month previous year.

Round ( this dateTime, RoundTo rt ) : DateTimeOffset
SameDay ( this current, DateTimeOffset date ) : bool

Determines whether the specified DateTimeOffset value is exactly the same day (day + month + year) then current

SameMonth ( this current, DateTimeOffset date ) : bool

Determines whether the specified DateTimeOffset value is exactly the same month (month + year) then current. Eg, 2015-12-01 and 2014-12-01 => False

SameYear ( this current, DateTimeOffset date ) : bool

Determines whether the specified DateTimeOffset value is exactly the same year then current. Eg, 2015-12-01 and 2015-01-01 => True

SetDate ( this value, int year ) : DateTimeOffset

Returns DateTimeOffset with changed Year part.

SetDate ( this value, int year, int month ) : DateTimeOffset

Returns DateTimeOffset with changed Year and Month part.

SetDate ( this value, int year, int month, int day ) : DateTimeOffset

Returns DateTimeOffset with changed Year, Month and Day part.

SetDay ( this value, int day ) : DateTimeOffset

Returns DateTimeOffset with changed Day part.

SetHour ( this originalDate, int hour ) : DateTimeOffset

Returns DateTimeOffset with changed Hour part.

SetMillisecond ( this originalDate, int millisecond ) : DateTimeOffset

Returns DateTimeOffset with changed Millisecond part.

SetMinute ( this originalDate, int minute ) : DateTimeOffset

Returns DateTimeOffset with changed Minute part.

SetMonth ( this value, int month ) : DateTimeOffset

Returns DateTimeOffset with changed Month part.

SetSecond ( this originalDate, int second ) : DateTimeOffset

Returns DateTimeOffset with changed Second part.

SetTime ( this originalDate, int hour ) : DateTimeOffset

Returns the original DateTimeOffset with Hour part changed to supplied hour parameter.

SetTime ( this originalDate, int hour, int minute ) : DateTimeOffset

Returns the original DateTimeOffset with Hour and Minute parts changed to supplied hour and minute parameters.

SetTime ( this originalDate, int hour, int minute, int second ) : DateTimeOffset

Returns the original DateTimeOffset with Hour, Minute and Second parts changed to supplied hour, minute and second parameters.

SetTime ( this originalDate, int hour, int minute, int second, int millisecond ) : DateTimeOffset

Returns the original DateTimeOffset with Hour, Minute, Second and Millisecond parts changed to supplied hour, minute, second and millisecond parameters.

SetYear ( this value, int year ) : DateTimeOffset

Returns DateTimeOffset with changed Year part.

SubtractBusinessDays ( this current, int days ) : DateTimeOffset

Subtracts the given number of business days to the DateTimeOffset.

WeekAfter ( this start ) : DateTimeOffset

Increases supplied DateTimeOffset for 7 days ie returns the Next Week.

WeekEarlier ( this start ) : DateTimeOffset

Decreases supplied DateTimeOffset for 7 days ie returns the Previous Week.

Private Methods

Method Description
StartOfWeek ( this dateTime ) : DateTimeOffset

Method Details

AddBusinessDays() public static method

Adds the given number of business days to the DateTimeOffset.
public static AddBusinessDays ( this current, int days ) : DateTimeOffset
current this The date to be changed.
days int Number of business days to be added.
return DateTimeOffset

At() public static method

Returns the given DateTimeOffset with hour and minutes set At given values.
public static At ( this current, int hour, int minute ) : DateTimeOffset
current this The current to be changed.
hour int The hour to set time to.
minute int The minute to set time to.
return DateTimeOffset

At() public static method

Returns the given DateTimeOffset with hour and minutes and seconds set At given values.
public static At ( this current, int hour, int minute, int second ) : DateTimeOffset
current this The current to be changed.
hour int The hour to set time to.
minute int The minute to set time to.
second int The second to set time to.
return DateTimeOffset

At() public static method

Returns the given DateTimeOffset with hour and minutes and seconds and milliseconds set At given values.
public static At ( this current, int hour, int minute, int second, int milliseconds ) : DateTimeOffset
current this The current to be changed.
hour int The hour to set time to.
minute int The minute to set time to.
second int The second to set time to.
milliseconds int The milliseconds to set time to.
return DateTimeOffset

BeginningOfDay() public static method

Returns the Start of the given day (the first millisecond of the given DateTimeOffset).
public static BeginningOfDay ( this date ) : DateTimeOffset
date this
return DateTimeOffset

DecreaseTime() public static method

Decreases the DateTimeOffset object with given TimeSpan value.
public static DecreaseTime ( this startDate, System.TimeSpan toSubtract ) : DateTimeOffset
startDate this
toSubtract System.TimeSpan
return DateTimeOffset

EndOfDay() public static method

Returns the very end of the given day (the last millisecond of the last hour for the given DateTimeOffset).
public static EndOfDay ( this date ) : DateTimeOffset
date this
return DateTimeOffset

FirstDayOfMonth() public static method

Sets the day of the DateTimeOffset to the first day in that month.
public static FirstDayOfMonth ( this current ) : DateTimeOffset
current this The current to be changed.
return DateTimeOffset

FirstDayOfQuarter() public static method

Sets the day of the DateTimeOffset to the first day in that calendar quarter. credit to http://www.devcurry.com/2009/05/find-first-and-last-day-of-current.html
public static FirstDayOfQuarter ( this current ) : DateTimeOffset
current this
return DateTimeOffset

FirstDayOfWeek() public static method

Returns a DateTimeOffset adjusted to the beginning of the week.
the beginning of the week is controlled by the current Culture
public static FirstDayOfWeek ( this dateTime ) : DateTimeOffset
dateTime this The DateTimeOffset to adjust
return DateTimeOffset

FirstDayOfYear() public static method

Returns the first day of the year keeping the time component intact. Eg, 2011-02-04T06:40:20.005 => 2011-01-01T06:40:20.005
public static FirstDayOfYear ( this current ) : DateTimeOffset
current this The DateTimeOffset to adjust
return DateTimeOffset

IncreaseTime() public static method

Increases the DateTimeOffset object with given TimeSpan value.
public static IncreaseTime ( this startDate, System.TimeSpan toAdd ) : DateTimeOffset
startDate this
toAdd System.TimeSpan
return DateTimeOffset

IsAfter() public static method

Determines whether the specified DateTimeOffset value is After then current value.
public static IsAfter ( this current, DateTimeOffset toCompareWith ) : bool
current this The current value.
toCompareWith DateTimeOffset Value to compare with.
return bool

IsBefore() public static method

Determines whether the specified DateTimeOffset is before then current value.
public static IsBefore ( this current, DateTimeOffset toCompareWith ) : bool
current this The current value.
toCompareWith DateTimeOffset Value to compare with.
return bool

IsInFuture() public static method

Determine if a DateTimeOffset is in the future.
public static IsInFuture ( this dateTime ) : bool
dateTime this The date to be checked.
return bool

IsInPast() public static method

Determine if a DateTimeOffset is in the past.
public static IsInPast ( this dateTime ) : bool
dateTime this The date to be checked.
return bool

LastDayOfMonth() public static method

Sets the day of the DateTimeOffset to the last day in that month.
public static LastDayOfMonth ( this current ) : DateTimeOffset
current this The current DateTimeOffset to be changed.
return DateTimeOffset

LastDayOfQuarter() public static method

Sets the day of the DateTimeOffset to the last day in that calendar quarter. credit to http://www.devcurry.com/2009/05/find-first-and-last-day-of-current.html
public static LastDayOfQuarter ( this current ) : DateTimeOffset
current this
return DateTimeOffset

LastDayOfWeek() public static method

Returns the last day of the week keeping the time component intact. Eg, 2011-12-24T06:40:20.005 => 2011-12-25T06:40:20.005
public static LastDayOfWeek ( this current ) : DateTimeOffset
current this The DateTimeOffset to adjust
return DateTimeOffset

LastDayOfYear() public static method

Returns the last day of the year keeping the time component intact. Eg, 2011-12-24T06:40:20.005 => 2011-12-31T06:40:20.005
public static LastDayOfYear ( this current ) : DateTimeOffset
current this The DateTimeOffset to adjust
return DateTimeOffset

Midnight() public static method

Returns original DateTimeOffset value with time part set to midnight (alias for BeginningOfDay method).
public static Midnight ( this value ) : DateTimeOffset
value this
return DateTimeOffset

Next() public static method

Returns first next occurrence of specified DayOfWeek.
public static Next ( this start, DayOfWeek day ) : DateTimeOffset
start this
day DayOfWeek
return DateTimeOffset

NextDay() public static method

Returns DateTimeOffset increased by 24 hours ie Next Day.
public static NextDay ( this start ) : DateTimeOffset
start this
return DateTimeOffset

NextMonth() public static method

Returns the next month keeping the time component intact. Eg, 2012-12-05T06:40:20.005 => 2013-01-05T06:40:20.005 If the next month doesn't have that many days the last day of the next month is used. Eg, 2013-01-31T06:40:20.005 => 2013-02-28T06:40:20.005
public static NextMonth ( this current ) : DateTimeOffset
current this The DateTimeOffset to adjust
return DateTimeOffset

NextYear() public static method

Returns the same date (same Day, Month, Hour, Minute, Second etc) in the next calendar year. If that day does not exist in next year in same month, number of missing days is added to the last day in same month next year.
public static NextYear ( this start ) : DateTimeOffset
start this
return DateTimeOffset

Noon() public static method

Returns original DateTimeOffset value with time part set to Noon (12:00:00h).
public static Noon ( this value ) : DateTimeOffset
value this The find Noon for.
return DateTimeOffset

Previous() public static method

Returns first next occurrence of specified DayOfWeek.
public static Previous ( this start, DayOfWeek day ) : DateTimeOffset
start this
day DayOfWeek
return DateTimeOffset

PreviousDay() public static method

Returns DateTimeOffset decreased by 24h period ie Previous Day.
public static PreviousDay ( this start ) : DateTimeOffset
start this
return DateTimeOffset

PreviousMonth() public static method

Returns the previous month keeping the time component intact. Eg, 2010-01-20T06:40:20.005 => 2009-12-20T06:40:20.005 If the previous month doesn't have that many days the last day of the previous month is used. Eg, 2009-03-31T06:40:20.005 => 2009-02-28T06:40:20.005
public static PreviousMonth ( this current ) : DateTimeOffset
current this The DateTimeOffset to adjust
return DateTimeOffset

PreviousYear() public static method

Returns the same date (same Day, Month, Hour, Minute, Second etc) in the previous calendar year. If that day does not exist in previous year in same month, number of missing days is added to the last day in same month previous year.
public static PreviousYear ( this start ) : DateTimeOffset
start this
return DateTimeOffset

Round() public static method

public static Round ( this dateTime, RoundTo rt ) : DateTimeOffset
dateTime this
rt RoundTo
return DateTimeOffset

SameDay() public static method

Determines whether the specified DateTimeOffset value is exactly the same day (day + month + year) then current
public static SameDay ( this current, DateTimeOffset date ) : bool
current this The current value
date DateTimeOffset Value to compare with
return bool

SameMonth() public static method

Determines whether the specified DateTimeOffset value is exactly the same month (month + year) then current. Eg, 2015-12-01 and 2014-12-01 => False
public static SameMonth ( this current, DateTimeOffset date ) : bool
current this The current value
date DateTimeOffset Value to compare with
return bool

SameYear() public static method

Determines whether the specified DateTimeOffset value is exactly the same year then current. Eg, 2015-12-01 and 2015-01-01 => True
public static SameYear ( this current, DateTimeOffset date ) : bool
current this The current value
date DateTimeOffset Value to compare with
return bool

SetDate() public static method

Returns DateTimeOffset with changed Year part.
public static SetDate ( this value, int year ) : DateTimeOffset
value this
year int
return DateTimeOffset

SetDate() public static method

Returns DateTimeOffset with changed Year and Month part.
public static SetDate ( this value, int year, int month ) : DateTimeOffset
value this
year int
month int
return DateTimeOffset

SetDate() public static method

Returns DateTimeOffset with changed Year, Month and Day part.
public static SetDate ( this value, int year, int month, int day ) : DateTimeOffset
value this
year int
month int
day int
return DateTimeOffset

SetDay() public static method

Returns DateTimeOffset with changed Day part.
public static SetDay ( this value, int day ) : DateTimeOffset
value this
day int
return DateTimeOffset

SetHour() public static method

Returns DateTimeOffset with changed Hour part.
public static SetHour ( this originalDate, int hour ) : DateTimeOffset
originalDate this
hour int
return DateTimeOffset

SetMillisecond() public static method

Returns DateTimeOffset with changed Millisecond part.
public static SetMillisecond ( this originalDate, int millisecond ) : DateTimeOffset
originalDate this
millisecond int
return DateTimeOffset

SetMinute() public static method

Returns DateTimeOffset with changed Minute part.
public static SetMinute ( this originalDate, int minute ) : DateTimeOffset
originalDate this
minute int
return DateTimeOffset

SetMonth() public static method

Returns DateTimeOffset with changed Month part.
public static SetMonth ( this value, int month ) : DateTimeOffset
value this
month int
return DateTimeOffset

SetSecond() public static method

Returns DateTimeOffset with changed Second part.
public static SetSecond ( this originalDate, int second ) : DateTimeOffset
originalDate this
second int
return DateTimeOffset

SetTime() public static method

Returns the original DateTimeOffset with Hour part changed to supplied hour parameter.
public static SetTime ( this originalDate, int hour ) : DateTimeOffset
originalDate this
hour int
return DateTimeOffset

SetTime() public static method

Returns the original DateTimeOffset with Hour and Minute parts changed to supplied hour and minute parameters.
public static SetTime ( this originalDate, int hour, int minute ) : DateTimeOffset
originalDate this
hour int
minute int
return DateTimeOffset

SetTime() public static method

Returns the original DateTimeOffset with Hour, Minute and Second parts changed to supplied hour, minute and second parameters.
public static SetTime ( this originalDate, int hour, int minute, int second ) : DateTimeOffset
originalDate this
hour int
minute int
second int
return DateTimeOffset

SetTime() public static method

Returns the original DateTimeOffset with Hour, Minute, Second and Millisecond parts changed to supplied hour, minute, second and millisecond parameters.
public static SetTime ( this originalDate, int hour, int minute, int second, int millisecond ) : DateTimeOffset
originalDate this
hour int
minute int
second int
millisecond int
return DateTimeOffset

SetYear() public static method

Returns DateTimeOffset with changed Year part.
public static SetYear ( this value, int year ) : DateTimeOffset
value this
year int
return DateTimeOffset

SubtractBusinessDays() public static method

Subtracts the given number of business days to the DateTimeOffset.
public static SubtractBusinessDays ( this current, int days ) : DateTimeOffset
current this The date to be changed.
days int Number of business days to be subtracted.
return DateTimeOffset

WeekAfter() public static method

Increases supplied DateTimeOffset for 7 days ie returns the Next Week.
public static WeekAfter ( this start ) : DateTimeOffset
start this
return DateTimeOffset

WeekEarlier() public static method

Decreases supplied DateTimeOffset for 7 days ie returns the Previous Week.
public static WeekEarlier ( this start ) : DateTimeOffset
start this
return DateTimeOffset