You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 31 Next »

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):

NameTypeMandatoryDefault Value
durationSimpleDuration


Return:

TypeDescription
SimpleDurationThe sum of the SimpleDuration objects.


Example:

add
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):

NameTypeMandatoryDefault Value
formatString


Return:

TypeDescription
StringSimpleDuration object


Example:

getByFormat
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:

TypeDescriptionMandatoryDefault Value
IntegerThe number of the days.


Example:

getDayPart
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:

getDisplayValue
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:

getDurationValue
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:

getRoundedDayPart
var simple_duration = new SimpleDuration("10 10:00:00");
ss.info( simple_duration.getRoundedDayPart() ); // 10
getRoundedDayPart
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:

getValue
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):

NameTypeMandatoryDefault Value
durationString


Return:

TypeDescription
VoidThis method does not return a value.


Example:

setDisplayValue
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):

NameTypeMandatoryDefault Value
dateTimeString

dateTimeSimpleDateTime


Return:

TypeDescription
VoidThis method does not return a value.


Example:

setValue
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):

NameTypeMandatoryDefault Value
durationSimpleDuration


Return:

TypeDescription
SimpleDurationThe subtraction result.


Example:

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

  • No labels