Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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

SimpleDuration(duration)


Instantiates a new SimpleDuration object.


Parameter(s):

NameTypeMandatoryDefault Value
durationInteger (seconds)N''
durationString (duration displayValue)N''



Example:

Code Block
languagejs
themeEclipse
titleSimpleDuration
linenumberstrue
const durationOne = new SimpleDuration(3600);
const durationTwo = new SimpleDuration('00:30:00');


add(duration)


Summarizes This method sums two SimpleDuration objects and returns the result.


Parameter(s):

NameTypeMandatoryDefault Value
durationSimpleDurationYN


Return:

TypeDescription
SimpleDurationThe sum of the two SimpleDuration objects.


Example:

Code Block
languagejs
themeEclipse
titleadd
linenumberstrue
varconst simple_durationdurationOne = new SimpleDuration("2 10:00:00"3600);
var simple_duration_1const durationTwo = new SimpleDuration("01'00:0030:00"');
varconst resulttotalDuration = simple_durationdurationOne.add(simple_duration_1durationTwo);
ss.info( resulttotalDuration.getDisplayValuegetDurationValue() );
// Info: 01:30:00


getByFormat(format)


Returns This method allows to get the duration value of the duration in a specified the format you need.


Parameter(s):

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


Return:

TypeDescription
StringSimpleDuration object


Example:

Code Block
languagejs
themeEclipse
titlegetByFormat
linenumberstrue
const datetimevar simple_duration = new SimpleDuration("2 10:00:00"SimpleDateTime('2019-11-12 15:34:13');
const duration = new SimpleDuration(datetime.getNumericValue());
ss.info( simple_duration.getByFormat('h:m') );j F Y (D) H:i:s'));
// Info: 12 November 2019 (Tue) 15:34:13

getDayPart()


Returns the This method allows to get the duration value in number of the days of the duration.


Return:

TypeDescription
IntegerThe number of the days.


Example:

Code Block
languagejs
themeEclipse
titlegetDayPart
linenumberstrue
constvar simple_duration = new SimpleDuration("2'02 1001:0030:00"');
ss.info( simple_duration.getDayPart() ); 
// Info: 2


getDisplayValue()


Returns This method allows to get the number of the days, hours, and minutes of from the durationSimpleDuration object.


Return:

TypeDescription
StringThe number of the days, hours and minutes.


Example:

Code Block
languagejs
themeEclipse
titlegetDisplayValue
linenumberstrue
varconst simple_duration = new SimpleDuration(3605);
ss.info(duration.getDisplayValue());
// Info: 1 hour 5 seconds


getDurationSeconds()


This method returns the duration value in seconds.


Return:

TypeDescription
IntegerThe duration value in seconds.


Example:

Code Block
languagejs
themeEclipse
titlegetDurationSeconds
linenumberstrue
const duration = new SimpleDuration('("10 10:00:00"');
ss.info( simple_duration.getDisplayValuegetDurationSeconds() );  
//10 days 10 hoursInfo: 36000

getDurationValue()


Returns This method allows to get the duration value in from the SimpleDuration object in 'D H:i:s' format.


Return:

TypeDescription
StringThe duration value.


Example:

Code Block
languagejs
themeEclipse
titlegetDurationValue
linenumberstrue
const var simple_duration = new SimpleDuration("10 10:00:00"7200);
ss.info( simple_duration.getDurationValue() ); 
//10 Info: 1002:00:00


getRoundedDayPart()


Returns This method returns the rounded number of days taking into account the quantity of hours in the SimpleDuration object. If the number of hours is more than 12, then round the method rounds the value up. Otherwise, round it rounds the value down.


Return:

TypeDescription
IntegerThe rounded number of days.


Example:

Code Block
languagejs
themeEclipse
titlegetRoundedDayPart
var simple_duration = new SimpleDuration("10 10:00:00");
ss.info( simple_duration.getRoundedDayPart() ); // 10
linenumberstrue
const 
Code Block
languagejs
titlegetRoundedDayPart
var simple_duration = new SimpleDuration("10'5 1412:0052:00"22');
ss.info( simple_duration.getRoundedDayPart() ); 
//Info: 116

getValue()


Returns the internal value of the SimpleDuration objectThis method returns the date and time value in the internal format.

SimpleDuration objects store

the

duration as a date and time

past January

starting with January 1, 1970, 00:00:00.


Return:

TypeDescription
StringThe duration string in the object's internal format.


Example:

Code Block
languagejs
themeEclipse
titlegetValue
linenumberstrue
constvar simple_duration = new SimpleDuration("'10 15:00:00"');
ss.info( simple_duration.getValue() ); 
//Info: 1970-01-11 15:00:00

Example 2:

Code Block
languagejs
themeEclipse
titlegetValue
linenumberstrue
const myUserId = ss.getUserId();
const timestamp = Number(myUserId.slice(0, 10)); // User created at
const duration = new SimpleDuration(timestamp);
ss.info(duration.getValue());
// Info: 2019-05-31 14:02:39


setDisplayValue(duration)


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

Code Block
languagejs
themeEclipse
titlesetDisplayValue
linenumberstrue
const var simple_duration = new SimpleDuration();
simple_duration.setDisplayValue("'2 10:00:00"');
ss.info( simple_duration.getDisplayValue() ); 
//Info: 2 days 10 hours


setValue(

string / SimpleDateTime

dateTime)


Sets This method sets the value in a 'YYYYY-mMM-d HDD hh:imm:sss' format.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeStringYN
dateTimeSimpleDateTimeYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titlesetValue
linenumberstrue
varconst simple_durationdurationOne = new SimpleDuration();
simple_durationdurationOne.setValue("2 10'2019-08-01 09:00:00"');
ss.info(durationOne.getByFormat());
const durationTwo = new SimpleDuration();
durationTwo.setValue( simple_duration.getDisplayValue() );new SimpleDateTime('2019-09-05 12:00:00'));
ss.info(durationTwo.getByFormat());
// Info: 2019-08-01 09:00:00
// Info: 2019-09-05 12:00:00


subtract(duration)


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


Parameter(s):

NameTypeMandatoryDefault Value
durationSimpleDurationYN


Return:

TypeDescription
SimpleDurationThe subtraction result object.


Example:

Code Block
languagejs
themeEclipse
titlesubtract
linenumberstrue
const durationOnevar simple_duration = new SimpleDuration();
durationOne.setValue('10 05:00:002019-11-08 20:01:58');
var simple_duration_1const durationTwo = new SimpleDuration('05:00:00'3600);
varconst datetime result= simple_duration durationOne.subtract(simple_duration_1durationTwo);
ss.info( resultdatetime.getDisplayValuegetByFormat() );
// Info: 2019-11-08 19:01:58


Table of Contents
absoluteUrltrue
classfixedPosition