The objects of this server class store duration as a date and time from January 1, 1970, 00:00:00.
This method adds SimpleDuration object to the current SimpleDuration object and returns the result.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
duration | SimpleDuration | Y | N |
Return:
Type | Description |
---|
SimpleDuration | The sum of two SimpleDuration objects. |
Example:
Code Block |
---|
|
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() ); |
This method returns the value of the duration in a specified format.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
format | String | N | 'Y-m-d H:i:s' |
Return:
Type | Description |
---|
String | SimpleDuration object |
Example:
Code Block |
---|
language | js |
---|
title | getByFormat |
---|
|
var simple_duration = new SimpleDuration('2 10:00:00');
ss.info(simple_duration.getByFormat('h:m') ); |
This method returns the number of the days of the duration.
Return:
Type | Description |
---|
Integer | The number of the days. |
Example:
Code Block |
---|
language | js |
---|
title | getDayPart |
---|
|
var simple_duration = new SimpleDuration('2 10:00:00');
ss.info(simple_duration.getDayPart() ); // 2 |
This method returns the number of the days, hours and minutes of the duration.
Return:
Type | Description |
---|
String | The number of the days, hours and minutes. |
Example:
Code Block |
---|
language | js |
---|
title | getDisplayValue |
---|
|
var simple_duration = new SimpleDuration('10 10:00:00');
ss.info(simple_duration.getDisplayValue() ); //10 days 10 hours |
This method returns the duration value in 'D H:i:s' format.
Return:
Type | Description |
---|
String | The duration value. |
Example:
Code Block |
---|
language | js |
---|
title | getDurationValue |
---|
|
var simple_duration = new SimpleDuration('10 10:00:00');
ss.info(simple_duration.getDurationValue() ); //10 10:00:00 |
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:
Type | Description |
---|
Integer | The rounded number of days. |
Example:
Code Block |
---|
language | js |
---|
title | getRoundedDayPart |
---|
|
var simple_duration = new SimpleDuration('10 10:00:00');
ss.info(simple_duration.getRoundedDayPart() ); // 10 |
Code Block |
---|
language | js |
---|
title | getRoundedDayPart |
---|
|
var simple_duration = new SimpleDuration('10 14:00:00');
ss.info(simple_duration.getRoundedDayPart() ); // 11 |
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:
Type | Description |
---|
String | The duration string in the object's internal format. |
Example:
Code Block |
---|
|
var simple_duration = new SimpleDuration('10 15:00:00');
ss.info(simple_duration.getValue() ); //1970-01-11 15:00:00 |
This method sets the value in a 'd H:i:s' format.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
duration | String | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
title | setDisplayValue |
---|
|
var simple_duration = new SimpleDuration();
simple_duration.setDisplayValue('2 10:00:00');
ss.info(simple_duration.getDisplayValue() ); //2 days 10 hours |
string / SimpleDateTime
This method sets the value in a 'Y-m-d H:i:s' format.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
dateTime | String | Y | N |
dateTime | SimpleDateTime | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
|
var simple_duration = new SimpleDuration();
simple_duration.setValue('2 10:00:00');
ss.info(simple_duration.getDisplayValue() ); |
This method subtracts one SimpleDuration object from another and returns the result.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
duration | SimpleDuration | Y | N |
Return:
Type | Description |
---|
SimpleDuration | The subtraction result. |
Example:
Code Block |
---|
|
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() ); |