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 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 12 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 35 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 51 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 619 of file Duration.cs.

◆ Equals()

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

Definition at line 454 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 559 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 569 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 579 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 549 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 589 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 599 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 539 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 649 of file Duration.cs.

◆ GetHashCode()

override int Waher.Content.Duration.GetHashCode ( )

Definition at line 463 of file Duration.cs.

◆ Negate()

Duration Waher.Content.Duration.Negate ( )

Negates the duration.

Returns
Negated duration.

Definition at line 631 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 375 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 395 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 195 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 427 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 247 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 299 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 313 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 355 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 327 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 341 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 71 of file Duration.cs.

◆ ToString()

override string Waher.Content.Duration.ToString ( )

Definition at line 471 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 85 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 532 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 147 of file Duration.cs.

◆ Hours

int Waher.Content.Duration.Hours
getset

Number of hours.

Implements Waher.Script.Functions.DateAndTime.IHours.

Definition at line 156 of file Duration.cs.

◆ Minutes

int Waher.Content.Duration.Minutes
getset

Number of minutes.

Implements Waher.Script.Functions.DateAndTime.IMinutes.

Definition at line 165 of file Duration.cs.

◆ Months

int Waher.Content.Duration.Months
getset

Number of months.

Implements Waher.Script.Functions.DateAndTime.IMonths.

Definition at line 138 of file Duration.cs.

◆ Negation

bool Waher.Content.Duration.Negation
getset

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

Definition at line 183 of file Duration.cs.

◆ Seconds

double Waher.Content.Duration.Seconds
getset

Number of seconds.

Implements Waher.Script.Functions.DateAndTime.ISeconds.

Definition at line 174 of file Duration.cs.

◆ Years

int Waher.Content.Duration.Years
getset

Number of years.

Implements Waher.Script.Functions.DateAndTime.IYears.

Definition at line 129 of file Duration.cs.


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