The objects of this server class store duration as a date and time from January 1, 1970, 00:00:00.

add(duration)

Summarizes two SimpleDuration objects and returns the result.


Parameter(s):

NameType
durationSimpleDuration


Return:

TypeDescription
SimpleDurationThe sum of the SimpleDuration objects.


Example:

var simple_duration = new SimpleDuration("2 10:00:00");
var simple_duration_1 = new SimpleDuration("01:00:00");
var result = simple_duration.add(simple_duration_1);
ss.info( result.getDisplayValue() );


getByFormat(format)

Returns the value of the duration in a specified format.


Parameter(s):

NameType
formatString


Return:

TypeDescription
StringSimpleDuration object


Example:

var simple_duration = new SimpleDuration("2 10:00:00");
ss.info( simple_duration.getByFormat('h:m') );


getDayPart()

Returns the number of the days of the duration.


Return:

TypeDescription
IntegerThe number of the days.


Example:

var simple_duration = new SimpleDuration("2 10:00:00");
ss.info( simple_duration.getDayPart() ); // 2


getDisplayValue()

Returns the number of the days, hours and minutes of the duration.


Return:

TypeDescription
StringThe number of the days, hours and minutes.


Example:

var simple_duration = new SimpleDuration("10 10:00:00");
ss.info( simple_duration.getDisplayValue() );  //10 days 10 hours


getDurationValue()

Returns the duration value in 'D H:i:s' format.


Return:

TypeDescription
StringThe duration value


Example:

var simple_duration = new SimpleDuration("10 10:00:00");
ss.info( simple_duration.getDurationValue() ); //10 10:00:00


getRoundedDayPart()

Returns the rounded number of days. If the number of hours is more than 12, then round the value up. Otherwise, round it down.


Return:

TypeDescription
IntegerThe rounded number of days.


Example:

var simple_duration = new SimpleDuration("10 10:00:00");
ss.info( simple_duration.getRoundedDayPart() ); // 10


var simple_duration = new SimpleDuration("10 14:00:00");
ss.info( simple_duration.getRoundedDayPart() ); // 11



getValue()

Returns the internal value of the SimpleDuration object.

SimpleDuration objects store the duration as a date and time past January 1, 1970, 00:00:00.

Return:

TypeDescription
StringThe duration string in object's internal format.


Example:

var simple_duration = new SimpleDuration("10 15:00:00");
ss.info( simple_duration.getValue() ); //1970-01-11 15:00:00



setDisplayValue(duration)

Sets the value in a 'd H:i:s' format.


Parameter(s):

NameType
durationString


Return:

TypeDescription
VoidThis method does not return a value.


Example:

var simple_duration = new SimpleDuration();
simple_duration.setDisplayValue("2 10:00:00");
ss.info( simple_duration.getDisplayValue() ); //2 days 10 hours



setValue(string / SimpleDateTime dateTime)

Sets the value in a 'Y-m-d H:i:s' format.


Parameter(s):

NameType
dateTimeString
dateTimeSimpleDateTime


Return:

TypeDescription
VoidThis method does not return a value.


Example:

var simple_duration = new SimpleDuration();
simple_duration.setValue("2 10:00:00");
ss.info( simple_duration.getDisplayValue() );


subtract(duration)

Subtracts one SimpleDuration object from another and returns the result.


Parameter(s):

NameType
durationSimpleDuration


Return:

TypeDescription
SimpleDurationThe subtraction result.


Example:

var simple_duration = new SimpleDuration('10 05:00:00');
var simple_duration_1 = new SimpleDuration('05:00:00');
var result= simple_duration .subtract(simple_duration_1);
ss.info( result.getDisplayValue() );