Interval Functions

abs

Returns the absolute value of a given interval.

Arguments


  • Interval - The given Interval object.

Returns

The absolute value of a given Interval object.

Example

The following example calculates an Interval by subtracting the current time from the first day of year 2000. Then, it displays the absolute value of the resulting interval:
year2k as Time

year2k = '2000-01-01 00:00:00'
interval = year2k - 'now'
display interval
display abs(interval)

addDays

Adds a specified number of days to an Interval object.

Arguments


  • Interval - The interval to which days will be added.
  • Int i - The number of days to be added to the Interval object.

Returns

An Interval object resulting from adding the specified number of days to the given Interval object.

Example

The following example creates an Interval variable named holidays and another named newHolidays, which is the result of adding 10 days to holidays. Then, it displays both the original variable and the one resulting from adding 10 days to the original variable:
holidays as Interval
holidays = '15d20h00m'
	
updatedHolidays as Interval
updatedHolidays = addDays(holidays, i : 10)
	
display "original holidays: " + holidays + 
	    "\n\n updated holidays: " + 
	    updatedHolidays
	

addHours

Adds a specified number of hours to an Interval object.

Arguments


  • Interval - The interval to which hours will be added.
  • Int i - The number of hours to be added to the Interval object.

Returns

An Interval object resulting from adding the specified number of hours to the given Interval object.

Example

The following example creates an Interval variable named deliveryTime and another named newDeliveryTime, which is the result of adding 12 hours to deliveryTime. Then, it displays both the original variable and the one resulting from adding 12 hours to the original variable:
deliveryTime as Interval
newDeliveryTime as Interval
	
deliveryTime = '1d00h00m'
newDeliveryTime = addHours(deliveryTime, i : 12)
	
display "original deliveryTime: " + deliveryTime +
	      "\n\n new deliveryTime: " + newDeliveryTime
	

addMicroSeconds

Adds a specified number of microseconds to an Interval object.

Arguments

Interval
The interval to which microseconds will be added.
Int
The number of microseconds to be added to the Interval object.

Returns

An Interval object resulting from adding the specified number of microseconds to the given Interval object.

Example

The following example creates an Interval variable named retry and another named largerRetry, which is the result of adding 222 microseconds to retry. Then, it displays both the original variable and the one resulting from adding 222 microseconds to the original variable:
retry as Interval
retry = '1m30.600s'
	
largerRetry as Interval
largerRetry = addMicroSeconds(retry, i : 222)
	
display "old retry: " + retry + "\n\nnew retry: " + 
	    largerRetry
	

addMinutes

Adds a specified number of minutes to an Interval object.

Arguments

Interval
The interval to which minutes will be added.
Int
The number of minutes to be added to the Interval object.

Returns

An Interval object resulting from adding the specified number of minutes to the given Interval object.

Example

The following example creates an Interval variable named breakTime and another named newBreakTime, which is the result of adding 25 minutes to breakTime. Then, it displays both the original variable and the one resulting from adding 25 minutes to the original variable:
breakTime as Interval
breakTime = '1h20m00s'
	
newBreakTime as Interval
newBreakTime = addMinutes(breakTime, i : 25)
	
display "old break-time: " +breakTime + 
	    "\n\n new break-time: "+ newBreakTime

addMonths

Adds a specified number of months to an Interval object.

Arguments


  • Interval - The interval to which months will be added.
  • Int i - The number of months to be added to the Interval object.

Returns

An Interval object resulting from adding the specified number of months to the given Interval object.

Example

The following example defines an Interval fishingSeason. Then, it creates a new Interval named newFishingSeason, which is the result of adding a month to fishingSeason. Both the original interval and the result of the addition are displayed:
fishingSeason as Interval
fishingSeason = '1M20d'
	
newFishingSeason as Interval
newFishingSeason = addMonths(fishingSeason, i : 1)
	
display "original fishingSeason: " + fishingSeason + 
	   "\n\nnew fishingSeason: " + newFishingSeason

addYears

Adds a specified number of years to an Interval object.

Arguments


  • Interval - The Interval object to which years will be added.
  • Int i - The number of years to be added to the Interval object.

Returns

The Interval object resulting from adding the specified number of years to the given Interval.

Example

licensePeriod as Interval
licensePeriod = '1Y6M'
	
newLicensePeriod as Interval
newLicensePeriod = addYears(licensePeriod, i : 1)
	
display "original license period: "+ licensePeriod + 
	   "\n\nnew license period: " + newLicensePeriod 

format

Returns a String representation of the given interval. This String representation is based on the current locale.

Arguments


  • Interval - The given Interval object.

Returns

A String representation of the given Interval based on the current locale.

Example

interval as Interval
interval = '2Y6M15d12h30m30s'
display format(interval)

intValue

Returns the Int value of an Interval objects. This value represents the number of seconds in the interval.

Arguments


  • Interval - The Interval object.

Returns

An Int representing the number of seconds in the given interval.

Example

The following example displays the Int representation, that is to say, the number of seconds in an interval of 1 hour, 30 minutes, and 20 seconds:
display intValue('1h30m20s')

max

Returns the greater of two Interval objects.

Arguments


  • Interval - The given Interval object.
  • Interval b - Another Interval object.

Returns

The greater of the two Interval objects.

Example

The following example displays the greater Interval between 1 hour and 20 minutes and 1 hour and 35 minutes:
display max('1h20m', b : '1h35m')

min

Returns the smaller of two Interval objects.

Arguments


  • Interval - The given Interval object.
  • Interval b - Another Interval object.

Returns

The smaller of the two Interval objects.

Example

The following example displays the smaller Interval between 1 hour and 20 minutes and 1 hour and 35 minutes:
display min('1h20m', b : '1h35m')

sleep

Causes the current BP-method to sleep for the specified number of time. Note that you cannot sleep past the current timeout. While the method is sleeping the timeout period is still running, therefore the sleep is applicable for the defined interval or until timeout, whatever happens first.

Arguments

Interval - Time to wait

Example

The following example pauses the execution for 5 seconds:
sleep('5s')