Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Waher.Content.Duration Struct Reference

Represents a duration value, as defined by the xsd:duration data type: http://www.w3.org/TR/xmlschema-2/#duration More...

Inheritance diagram for Waher.Content.Duration:
Waher.Script.Functions.DateAndTime.ISeconds Waher.Script.Functions.DateAndTime.IMinutes Waher.Script.Functions.DateAndTime.IHours Waher.Script.Functions.DateAndTime.IDays Waher.Script.Functions.DateAndTime.IMonths Waher.Script.Functions.DateAndTime.IYears

Public Member Functions

 Duration (bool Negation, int Years, int Months, int Days, int Hours, int Minutes, double Seconds)
 Represents a duration value, as defined by the xsd:duration data type: http://www.w3.org/TR/xmlschema-2/#duration More...
 
 Duration (string s)
 Represents a duration value, as defined by the xsd:duration data type: http://www.w3.org/TR/xmlschema-2/#duration More...
 
override bool Equals (object obj)
 
override int GetHashCode ()
 
override string ToString ()
 
int CompareTo (Duration other)
 Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object. More...
 
Duration Negate ()
 Negates the duration. More...
 

Static Public Member Functions

static Duration Parse (string s)
 Parses a duration from its string representation. More...
 
static bool TryParse (string s, out Duration Result)
 Tries to parse a duration value. More...
 
static System.DateTime operator+ (System.DateTime Timepoint, Duration Offset)
 Adds a duration to a System.DateTime value. More...
 
static System.DateTime operator- (System.DateTime Timepoint, Duration Offset)
 Subtracts a duration from a System.DateTime value. More...
 
static bool operator< (Duration D1, Duration D2)
 Checks if duration D1 is less than duration D2 . More...
 
static bool operator<= (Duration D1, Duration D2)
 Checks if duration D1 is less than or equal to duration D2 . More...
 
static bool operator> (Duration D1, Duration D2)
 Checks if duration D1 is greater than duration D2 . More...
 
static bool operator>= (Duration D1, Duration D2)
 Checks if duration D1 is greater than or equal to duration D2 . More...
 
static bool operator== (Duration D1, Duration D2)
 Checks if duration D1 is equal to duration D2 . More...
 
static bool operator!= (Duration D1, Duration D2)
 Checks if duration D1 is not equal to duration D2 . More...
 
static Duration operator+ (Duration D1, Duration D2)
 Adds two durations. More...
 
static Duration operator- (Duration D1, Duration D2)
 Adds two durations. More...
 
static Duration operator* (int Scalar, Duration D)
 Scalar multiplication of an integer and a duration. More...
 
static Duration operator* (Duration D, int Scalar)
 Scalar multiplication of a duration and an integer. More...
 
static Duration FromYears (int Years)
 Creates a Duration object from a given number of years. More...
 
static Duration FromMonths (int Months)
 Creates a Duration object from a given number of months. More...
 
static Duration FromDays (int Days)
 Creates a Duration object from a given number of days. More...
 
static Duration FromHours (int Hours)
 Creates a Duration object from a given number of hours. More...
 
static Duration FromMinutes (int Minutes)
 Creates a Duration object from a given number of minutes. More...
 
static Duration FromSeconds (int Seconds)
 Creates a Duration object from a given number of seconds. More...
 
static Duration FromTimeSpan (System.TimeSpan TS)
 Converts a TimeSpan to a Duration. (This will loose milliseconds.) More...
 
static Duration GetDurationBetween (System.DateTime From, System.DateTime To)
 Calculates the duration between two dates. More...
 

Static Public Attributes

static readonly Duration Zero = new Duration(false, 0, 0, 0, 0, 0, 0)
 Zero value More...
 

Properties

int Years [get, set]
 Number of years. More...
 
int Months [get, set]
 Number of months. More...
 
int Days [get, set]
 Number of days. More...
 
int Hours [get, set]
 Number of hours. More...
 
int Minutes [get, set]
 Number of minutes. More...
 
double Seconds [get, set]
 Number of seconds. More...
 
bool Negation [get, set]
 If the duration is negative (true) or positive (false). More...
 

Detailed Description

Represents a duration value, as defined by the xsd:duration data type: http://www.w3.org/TR/xmlschema-2/#duration

Definition at line 13 of file Duration.cs.

Constructor & Destructor Documentation

◆ Duration() [1/2]

Waher.Content.Duration.Duration ( bool  Negation,
int  Years,
int  Months,
int  Days,
int  Hours,
int  Minutes,
double  Seconds 
)

Represents a duration value, as defined by the xsd:duration data type: http://www.w3.org/TR/xmlschema-2/#duration

Parameters
NegationIf the duration is negative (true) or positive (false).
YearsNumber of years.
MonthsNumber of months.
DaysNumber of days.
HoursNumber of hours.
MinutesNumber of minutes.
SecondsNumber of seconds.

Definition at line 36 of file Duration.cs.

◆ Duration() [2/2]

Waher.Content.Duration.Duration ( string  s)

Represents a duration value, as defined by the xsd:duration data type: http://www.w3.org/TR/xmlschema-2/#duration

Parameters
sString representation of duration.

Definition at line 52 of file Duration.cs.

Member Function Documentation

◆ CompareTo()

int Waher.Content.Duration.CompareTo ( Duration  other)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

Parameters
otherAn object to compare with this instance.
Returns
A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes other in the sort order. Zero This instance occurs in the same position in the sort order as other. Greater than zero This instance follows other in the sort order.

Definition at line 664 of file Duration.cs.

◆ Equals()

override bool Waher.Content.Duration.Equals ( object  obj)

Definition at line 501 of file Duration.cs.

◆ FromDays()

static Duration Waher.Content.Duration.FromDays ( int  Days)
static

Creates a Duration object from a given number of days.

Parameters
DaysNumber of days.
Returns
Duration object.

Definition at line 604 of file Duration.cs.

◆ FromHours()

static Duration Waher.Content.Duration.FromHours ( int  Hours)
static

Creates a Duration object from a given number of hours.

Parameters
HoursNumber of hours.
Returns
Duration object.

Definition at line 614 of file Duration.cs.

◆ FromMinutes()

static Duration Waher.Content.Duration.FromMinutes ( int  Minutes)
static

Creates a Duration object from a given number of minutes.

Parameters
MinutesNumber of minutes.
Returns
Duration object.

Definition at line 624 of file Duration.cs.

◆ FromMonths()

static Duration Waher.Content.Duration.FromMonths ( int  Months)
static

Creates a Duration object from a given number of months.

Parameters
MonthsNumber of months.
Returns
Duration object.

Definition at line 594 of file Duration.cs.

◆ FromSeconds()

static Duration Waher.Content.Duration.FromSeconds ( int  Seconds)
static

Creates a Duration object from a given number of seconds.

Parameters
SecondsNumber of seconds.
Returns
Duration object.

Definition at line 634 of file Duration.cs.

◆ FromTimeSpan()

static Duration Waher.Content.Duration.FromTimeSpan ( System.TimeSpan  TS)
static

Converts a TimeSpan to a Duration. (This will loose milliseconds.)

Parameters
TSTimeSpan value.
Returns
Duration value

Definition at line 644 of file Duration.cs.

◆ FromYears()

static Duration Waher.Content.Duration.FromYears ( int  Years)
static

Creates a Duration object from a given number of years.

Parameters
YearsNumber of years.
Returns
Duration object.

Definition at line 584 of file Duration.cs.

◆ GetDurationBetween()

static Duration Waher.Content.Duration.GetDurationBetween ( System.DateTime  From,
System.DateTime  To 
)
static

Calculates the duration between two dates.

Parameters
FromStarting point.
ToEnding point.
Returns
Duration between.

Definition at line 694 of file Duration.cs.

◆ GetHashCode()

override int Waher.Content.Duration.GetHashCode ( )

Definition at line 510 of file Duration.cs.

◆ Negate()

Duration Waher.Content.Duration.Negate ( )

Negates the duration.

Returns
Negated duration.

Definition at line 676 of file Duration.cs.

◆ operator!=()

static bool Waher.Content.Duration.operator!= ( Duration  D1,
Duration  D2 
)
static

Checks if duration D1 is not equal to duration D2 .

Parameters
D1Duration 1
D2Duration 2
Returns
If D1 !=D2 .

Definition at line 376 of file Duration.cs.

◆ operator*() [1/2]

static Duration Waher.Content.Duration.operator* ( Duration  D,
int  Scalar 
)
static

Scalar multiplication of a duration and an integer.

Parameters
DDuration
ScalarInteger scalar.
Returns
Duration*Scalar

Definition at line 495 of file Duration.cs.

◆ operator*() [2/2]

static Duration Waher.Content.Duration.operator* ( int  Scalar,
Duration  D 
)
static

Scalar multiplication of an integer and a duration.

Parameters
ScalarInteger scalar.
DDuration
Returns
Scalar*Duration

Definition at line 460 of file Duration.cs.

◆ operator+() [1/2]

static Duration Waher.Content.Duration.operator+ ( Duration  D1,
Duration  D2 
)
static

Adds two durations.

Parameters
D1Duration 1
D2Duration 2
Returns
If D1 +D2 .

Definition at line 396 of file Duration.cs.

◆ operator+() [2/2]

static System.DateTime Waher.Content.Duration.operator+ ( System.DateTime  Timepoint,
Duration  Offset 
)
static

Adds a duration to a System.DateTime value.

Parameters
TimepointSystem.DateTime value.
OffsetOffset.
Returns
Timepoint +Offset .

Definition at line 196 of file Duration.cs.

◆ operator-() [1/2]

static Duration Waher.Content.Duration.operator- ( Duration  D1,
Duration  D2 
)
static

Adds two durations.

Parameters
D1Duration 1
D2Duration 2
Returns
If D1 +D2 .

Definition at line 428 of file Duration.cs.

◆ operator-() [2/2]

static System.DateTime Waher.Content.Duration.operator- ( System.DateTime  Timepoint,
Duration  Offset 
)
static

Subtracts a duration from a System.DateTime value.

Parameters
TimepointSystem.DateTime value.
OffsetOffset.
Returns
Timepoint -Offset .

Definition at line 248 of file Duration.cs.

◆ operator<()

static bool Waher.Content.Duration.operator< ( Duration  D1,
Duration  D2 
)
static

Checks if duration D1 is less than duration D2 .

Parameters
D1Duration 1
D2Duration 2
Returns
If D1 <D2 .

Definition at line 300 of file Duration.cs.

◆ operator<=()

static bool Waher.Content.Duration.operator<= ( Duration  D1,
Duration  D2 
)
static

Checks if duration D1 is less than or equal to duration D2 .

Parameters
D1Duration 1
D2Duration 2
Returns
If D1 <=D2 .

Definition at line 314 of file Duration.cs.

◆ operator==()

static bool Waher.Content.Duration.operator== ( Duration  D1,
Duration  D2 
)
static

Checks if duration D1 is equal to duration D2 .

Parameters
D1Duration 1
D2Duration 2
Returns
If D1 ==D2 .

Definition at line 356 of file Duration.cs.

◆ operator>()

static bool Waher.Content.Duration.operator> ( Duration  D1,
Duration  D2 
)
static

Checks if duration D1 is greater than duration D2 .

Parameters
D1Duration 1
D2Duration 2
Returns
If D1 >D2 .

Definition at line 328 of file Duration.cs.

◆ operator>=()

static bool Waher.Content.Duration.operator>= ( Duration  D1,
Duration  D2 
)
static

Checks if duration D1 is greater than or equal to duration D2 .

Parameters
D1Duration 1
D2Duration 2
Returns
If D1 >=D2 .

Definition at line 342 of file Duration.cs.

◆ Parse()

static Duration Waher.Content.Duration.Parse ( string  s)
static

Parses a duration from its string representation.

Parameters
sString representation of duration.
Returns
Duration
Exceptions
ArgumentExceptionIf s does not represent a valid duration.

Definition at line 72 of file Duration.cs.

◆ ToString()

override string Waher.Content.Duration.ToString ( )

Definition at line 516 of file Duration.cs.

◆ TryParse()

static bool Waher.Content.Duration.TryParse ( string  s,
out Duration  Result 
)
static

Tries to parse a duration value.

Parameters
sString
ResultDuration, if successful.
Returns
If the string could be parsed.

Definition at line 86 of file Duration.cs.

Member Data Documentation

◆ Zero

readonly Duration Waher.Content.Duration.Zero = new Duration(false, 0, 0, 0, 0, 0, 0)
static

Zero value

Definition at line 577 of file Duration.cs.

Property Documentation

◆ Days

int Waher.Content.Duration.Days
getset

Number of days.

Implements Waher.Script.Functions.DateAndTime.IDays.

Definition at line 148 of file Duration.cs.

◆ Hours

int Waher.Content.Duration.Hours
getset

Number of hours.

Implements Waher.Script.Functions.DateAndTime.IHours.

Definition at line 157 of file Duration.cs.

◆ Minutes

int Waher.Content.Duration.Minutes
getset

Number of minutes.

Implements Waher.Script.Functions.DateAndTime.IMinutes.

Definition at line 166 of file Duration.cs.

◆ Months

int Waher.Content.Duration.Months
getset

Number of months.

Implements Waher.Script.Functions.DateAndTime.IMonths.

Definition at line 139 of file Duration.cs.

◆ Negation

bool Waher.Content.Duration.Negation
getset

If the duration is negative (true) or positive (false).

Definition at line 184 of file Duration.cs.

◆ Seconds

double Waher.Content.Duration.Seconds
getset

Number of seconds.

Implements Waher.Script.Functions.DateAndTime.ISeconds.

Definition at line 175 of file Duration.cs.

◆ Years

int Waher.Content.Duration.Years
getset

Number of years.

Implements Waher.Script.Functions.DateAndTime.IYears.

Definition at line 130 of file Duration.cs.


The documentation for this struct was generated from the following file: