Show / Hide Table of Contents

Class TimeSpan

A class for representing a time span.

Syntax

Constructors

TimeSpan

Initializes a new instance of the TimeSpan class.

Declaration
TimeSpan

Methods

addDay(Integer)

Adds the given number of days to the currently set time span.

Declaration
Void addDay(Integer num)
Parameters
Type Name Description
Integer num

Number of days to add to the time span.

Returns
Type Description
Void

addHour(Integer)

Adds the given number of hours to the currently set time span.

Declaration
Void addHour(Integer num)
Parameters
Type Name Description
Integer num

Number of hours to add to the time span.

Returns
Type Description
Void

addMin(Integer)

Adds the given number of minutes to the currently set time span.

Declaration
Void addMin(Integer num)
Parameters
Type Name Description
Integer num

Number of minutes to add to the time span.

Returns
Type Description
Void

addSec(Integer)

Adds the given number of seconds to the currently set time span.

Declaration
Void addSec(Integer num)
Parameters
Type Name Description
Integer num

Number of seconds to add to the time span.

Returns
Type Description
Void

addYear(Integer)

Adds the given number of years to the currently set time span.

Declaration
Void addYear(Integer num)
Parameters
Type Name Description
Integer num

Number of years to add to the time span.

Returns
Type Description
Void

getDay()

Returns the day field of the time span as an integer.

Declaration
Integer getDay()
Returns
Type Description
Integer

Day field as an integer.

getHour()

Returns the hour field of the time span as an integer.

Declaration
Integer getHour()
Returns
Type Description
Integer

getMin()

Returns the minute field of the time span as an integer.

Declaration
Integer getMin()
Returns
Type Description
Integer

getSec()

Returns the seconds field of the time span as an integer.

Declaration
Integer getSec()
Returns
Type Description
Void

getYear()

Returns the year field of the time span as an integer.

Declaration
Integer getYear()
Returns
Type Description
Integer

isNegative()

Checks if this is a negative time span.

Declaration
Bool isNegative()
Returns
Type Description
Bool

True if this is a negative time span; otherwise, false.

set(Integer,Integer,Integer,Integer,Integer)

Initializes a time span object.

Declaration
Void set(Integer years, Integer days, Integer hours, Integer minutes, Integer seconds)
Parameters
Type Name Description
Integer years

Number of years

Integer days

Number of days

Integer hours

Number of hours

Integer minutes

Number of minutes

Integer seconds

Number of seconds.

Returns
Type Description
Void

setNegative(Bool)

Positive time span is default, but if you add a negative number of years/days/hours/minutes/seconds, you may get a negative times pan.

Declaration
Void setNegative(Bool negative)
Parameters
Type Name Description
Bool negative
Returns
Type Description
Void

toDays()

Returns the time span as a number of days. A one year time span will return 365.

Declaration
Integer toDays()
Returns
Type Description
Integer

toHours()

Returns the time span as a number of hours. A one day time span will return 24.

Declaration
Integer toHours()
Returns
Type Description
Integer

toMinutes()

Returns the time span as a number of minutes. A one hour time span will return 60.

Declaration
Integer toMinutes()
Returns
Type Description
Integer

toSeconds()

Returns the time span as a number of seconds. A one minute time span will return 60.

Declaration
Integer toSeconds()
Returns
Type Description
Integer

toString(Integer,Integer,Integer,Bool)

Returns the time span as a string representation, on given format and language.

Declaration
String toString(Integer mode, Integer lang, Integer maxMode, Bool short)
Parameters
Type Name Description
Integer mode

Mode2Year = 0 Mode2Day = 1 Mode2Hour = 2 Mode2Min = 3 Mode2Sec = 4

Integer lang

0 = Norwegian; 1 = English; 2 = German; 3 = Swedish; 4 = Danish; 5 = Dutch"

Integer maxMode

Mode2Year = 0 Mode2Day = 1 Mode2Hour = 2 Mode2Min = 3 Mode2Sec = 4

Bool short

True if you want short version of text (for example, m instead of minutes).

Returns
Type Description

A string representation of the time span, on the given format and in the given language.

Examples
TimeSpan ts;
printLine(ts.toString(3,1,1,false));
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top