Expiry Calculations

Expiry Types

None

Buckets with a none expiry will not expire until the value of the bucket reaches zero.

Absolute

An absolute expiry date allows the user to pick a set date and time for when the bucket will expire. Once the date and time of the set date has been reached, the balance within the bucket will be removed from the wallet.

Calculated

A Calculated expiry date allows the user - using a structure model of number of months, number of weeks, number of days, number of hours, number of minutes, number of seconds - to set an arbitrary date in the future as the expiry date.

The expiry date is calculated (and recalculated if needed) from the start point - the point in time when the bucket is applied to a wallet.

Additionally, Leap year and end of month cases are handled within the [[OCS]] calculated expiry automatically. For example, with an expiry calculation of 1 month set with a start point of Janurary 31st, then the 28th (or 29th depending on if the year is a leap year) of Feburary is set as the expiry date.

Rounding

It is possible to round the calculated expiry if the expiry is needing to be a certain timeframe.

There are three fields that need to be set for rounding are: round_method, round_to, and round_boundary.

Round Method

The round method defines how the rounding will be handled. There is a total of five possible values for the round method. These values are:

Method Description
None No rounding will be done against the calculated expiry.
Up Rounds the given round_to value up to the next value.
Down Rounds the given round_to value down to the previous value.
Half Up Rounds the given round_to value half way to the next full value for round_to
Half Down Rounds the given round_to value half way to the previous full value for round_ro
Round To

“Round To” defines what value of the calculated expiry will be used to round on. The possible values are as follows:

Round Boundary

The “Round Boundary” value defines what value should be considered the boundary for either rounding up or down. This value is highly dependent on the value of round_to:

Round To Value Description of boundary
minute What seconds is considered the boundary for the minute.
hour Which minute is considered the boundary for the hour.
day Which hour is considered the boundary for the day.
week Which day is considered the boundary for the week.
month Which day is considered the boundary for the month.

Expiry Examples

An expiry is set to 1 week from now, but round to the earlier Wednesday:

{
"weeks": 1, 
"round_to": "weeks", 
"round_method": "down", 
"round_boundary": 3
}

The OCS will select the next calendar day which is a Wednesday and expire at midnight on that Wednesday. This would give an actual expiry period of between minutes (if it were just before Wednesday) or 7 days.