You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 37 Next »
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):
Name | Type | Mandatory | Default Value |
---|---|---|---|
duration | SimpleDuration | Y | N |
Return:
Type | Description |
---|---|
SimpleDuration | The 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):
Name | Type | Mandatory | Default Value |
---|---|---|---|
format | String | N | 'Y-m-d H:i:s' |
Return:
Type | Description |
---|---|
String | SimpleDuration 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:
Type | Description |
---|---|
Integer | The 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:
Type | Description |
---|---|
String | The 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:
Type | Description |
---|---|
String | The 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:
Type | Description |
---|---|
Integer | The 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:
Type | Description |
---|---|
String | The 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):
Name | Type | Mandatory | Default Value |
---|---|---|---|
duration | String | Y | N |
Return:
Type | Description |
---|---|
Void | This 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):
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:
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):
Name | Type | Mandatory | Default Value |
---|---|---|---|
duration | SimpleDuration | Y | N |
Return:
Type | Description |
---|---|
SimpleDuration | The 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() );
- No labels