Joutsen  v0.4.1
Public Member Functions | Static Public Member Functions | Public Attributes | Properties | List of all members
Joutsen.System.TimeDelta Class Reference

A class representing a relative amount of time between dates. More...

Public Member Functions

 TimeDelta ()
 Creates a new instance for the current culture. More...
 
 TimeDelta (DateTimeFormatInfo dateTimeInfo)
 Creates a new instance with specific datetime format infos. More...
 
DateTime ToDateTime ()
 Create a Datetime value out of the delta using the current date as the basis for missing absolute values. More...
 
DateTime ToDateTime (DateTime referenceDateTime)
 Create a Datetime value out of the delta using the referenceDateTime as the basis for missing absolute values. More...
 
DateTime Add (DateTime dateTime)
 Adds the delta to an existing date creating a new date representing the point in time the delta describes. More...
 
override String ToString ()
 
override bool Equals (object obj)
 
override int GetHashCode ()
 

Static Public Member Functions

static DateTime operator+ (DateTime datetime, TimeDelta delta)
 

Public Attributes

const int LAST_DAY_OF_MONTH = 31
 Defines the absolute month day that represents the last day of the resulting month. More...
 
const int LAST_WEEK_OF_YEAR = 54
 Defines the absolute week number that represents the last week of the resulting year. More...
 
const int LAST_DAY_OF_YEAR = 366
 Defines the absolute year day that represents the last day of the resulting year. More...
 
const int LAST_WEEK_OF_MONTH = 6
 Defines the absolute week in the month that represents the last week of a month. More...
 
const int LAST_WEEKDAY_OCCURANCE_IN_MONTH = 5
 Defines the last possible occurance in a month. More...
 

Properties

int Years [get, set]
 The relative amount of years the delta describes. More...
 
int Months [get, set]
 The relative amount of monthss the delta describes. More...
 
int Weeks [get, set]
 The relative amount of weeks the delta describes. More...
 
int Days [get, set]
 The relative amount of days the delta describes. More...
 
int Hours [get, set]
 The relative amount of hours the delta describes. More...
 
int Minutes [get, set]
 The relative amount of minutes the delta describes. More...
 
int Seconds [get, set]
 The relative amount of seconds the delta describes. More...
 
int Milliseconds [get, set]
 The relative amount of millisceods the delta describes. More...
 
int Year [get, set]
 Absolute Values. More...
 
int Month [get, set]
 The absolute month the delta describes. More...
 
int WeekOfYear [get, set]
 The absolute week number the delta describes. More...
 
int WeekOfMonth [get, set]
 The week offset of the weekday. More...
 
int DayOfMonth [get, set]
 The absolute day in the month the delta describes. More...
 
DayOfWeek WeekDay [get, set]
 The absolute day of the week the delta describes. More...
 
int WeekDayOccurance [get, set]
 The occurance of the weekday within the month. More...
 
int DayOfYear [get, set]
 The absolute day in the year the delta describes. More...
 
int Hour [get, set]
 The absolute hour the delta describes. More...
 
int Minute [get, set]
 The absolute minute the delta describes. More...
 
int Second [get, set]
 The absolute second the delta describes. More...
 
int Millisecond [get, set]
 The absolute millisecond the delta describes. More...
 

Detailed Description

A class representing a relative amount of time between dates.

Remarks
The class can be used to modifiy dates with relative values. It allows the definition of absolute and relative parts of dates (e.g. 3 weeks in 2020). It also allows to define dates using weeks and days of the year. But its main purpose is to define complex relative deltas of dates (e.g. second friday after 2 months and 2 days).
Since
0.4.1

Constructor & Destructor Documentation

◆ TimeDelta() [1/2]

Joutsen.System.TimeDelta.TimeDelta ( )

Creates a new instance for the current culture.

◆ TimeDelta() [2/2]

Joutsen.System.TimeDelta.TimeDelta ( DateTimeFormatInfo  dateTimeInfo)

Creates a new instance with specific datetime format infos.

Member Function Documentation

◆ Add()

DateTime Joutsen.System.TimeDelta.Add ( DateTime  dateTime)

Adds the delta to an existing date creating a new date representing the point in time the delta describes.

Remarks
The delta is applied by using the passed datetime value as the base for all missing absolute values. After that all relative values are applied. Some of the provided values may contradict each other and it is important to know that they are applied in order from year down to milliseconds. This can result in some values not being relevant (e.g. if yearday and week is provided the week value can change the day of the result to a value that is different from the provided yeardate).

◆ Equals()

override bool Joutsen.System.TimeDelta.Equals ( object  obj)

◆ GetHashCode()

override int Joutsen.System.TimeDelta.GetHashCode ( )

◆ operator+()

static DateTime Joutsen.System.TimeDelta.operator+ ( DateTime  datetime,
TimeDelta  delta 
)
static

◆ ToDateTime() [1/2]

DateTime Joutsen.System.TimeDelta.ToDateTime ( )

Create a Datetime value out of the delta using the current date as the basis for missing absolute values.

◆ ToDateTime() [2/2]

DateTime Joutsen.System.TimeDelta.ToDateTime ( DateTime  referenceDateTime)

Create a Datetime value out of the delta using the referenceDateTime as the basis for missing absolute values.

◆ ToString()

override String Joutsen.System.TimeDelta.ToString ( )

Member Data Documentation

◆ LAST_DAY_OF_MONTH

const int Joutsen.System.TimeDelta.LAST_DAY_OF_MONTH = 31

Defines the absolute month day that represents the last day of the resulting month.

◆ LAST_DAY_OF_YEAR

const int Joutsen.System.TimeDelta.LAST_DAY_OF_YEAR = 366

Defines the absolute year day that represents the last day of the resulting year.

◆ LAST_WEEK_OF_MONTH

const int Joutsen.System.TimeDelta.LAST_WEEK_OF_MONTH = 6

Defines the absolute week in the month that represents the last week of a month.

◆ LAST_WEEK_OF_YEAR

const int Joutsen.System.TimeDelta.LAST_WEEK_OF_YEAR = 54

Defines the absolute week number that represents the last week of the resulting year.

◆ LAST_WEEKDAY_OCCURANCE_IN_MONTH

const int Joutsen.System.TimeDelta.LAST_WEEKDAY_OCCURANCE_IN_MONTH = 5

Defines the last possible occurance in a month.

Property Documentation

◆ DayOfMonth

int Joutsen.System.TimeDelta.DayOfMonth
getset

The absolute day in the month the delta describes.

◆ DayOfYear

int Joutsen.System.TimeDelta.DayOfYear
getset

The absolute day in the year the delta describes.

◆ Days

int Joutsen.System.TimeDelta.Days
getset

The relative amount of days the delta describes.

◆ Hour

int Joutsen.System.TimeDelta.Hour
getset

The absolute hour the delta describes.

◆ Hours

int Joutsen.System.TimeDelta.Hours
getset

The relative amount of hours the delta describes.

◆ Millisecond

int Joutsen.System.TimeDelta.Millisecond
getset

The absolute millisecond the delta describes.

◆ Milliseconds

int Joutsen.System.TimeDelta.Milliseconds
getset

The relative amount of millisceods the delta describes.

◆ Minute

int Joutsen.System.TimeDelta.Minute
getset

The absolute minute the delta describes.

◆ Minutes

int Joutsen.System.TimeDelta.Minutes
getset

The relative amount of minutes the delta describes.

◆ Month

int Joutsen.System.TimeDelta.Month
getset

The absolute month the delta describes.

◆ Months

int Joutsen.System.TimeDelta.Months
getset

The relative amount of monthss the delta describes.

◆ Second

int Joutsen.System.TimeDelta.Second
getset

The absolute second the delta describes.

◆ Seconds

int Joutsen.System.TimeDelta.Seconds
getset

The relative amount of seconds the delta describes.

◆ WeekDay

DayOfWeek Joutsen.System.TimeDelta.WeekDay
getset

The absolute day of the week the delta describes.

◆ WeekDayOccurance

int Joutsen.System.TimeDelta.WeekDayOccurance
getset

The occurance of the weekday within the month.

E.g. Second Thursday.

◆ WeekOfMonth

int Joutsen.System.TimeDelta.WeekOfMonth
getset

The week offset of the weekday.

By default this is 0 meaning the weekday of the current week.

◆ WeekOfYear

int Joutsen.System.TimeDelta.WeekOfYear
getset

The absolute week number the delta describes.

◆ Weeks

int Joutsen.System.TimeDelta.Weeks
getset

The relative amount of weeks the delta describes.

◆ Year

int Joutsen.System.TimeDelta.Year
getset

Absolute Values.

The absolute year the delta describes.

◆ Years

int Joutsen.System.TimeDelta.Years
getset

The relative amount of years the delta describes.