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

add(duration)


This method adds SimpleDuration object to the current SimpleDuration object and returns the result.


Parameter(s):

NameTypeMandatoryDefault Value
durationSimpleDurationYN


Return:

TypeDescription
SimpleDurationThe sum of two 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)


This method returns the value of the duration in a specified format.


Parameter(s):

NameTypeMandatoryDefault Value
formatStringN'Y-m-d H:i:s'


Return:

TypeDescription
StringSimpleDuration object


Example:

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


getDayPart()


This method 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()


This method 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()


This method 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()


This method 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()


This method 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 the 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)


This method sets the value in a 'd H:i:s' format.


Parameter(s):

NameTypeMandatoryDefault Value
durationStringYN


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)


This method sets the value in a 'Y-m-d H:i:s' format.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeStringYN
dateTimeSimpleDateTimeYN


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)


This method subtracts one SimpleDuration object from another and returns the result.


Parameter(s):

NameTypeMandatoryDefault Value
durationSimpleDurationYN


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() );