Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: PLAT-7684

...

Code Block
{
    // Convert the given Date-with-time object into a Date with only the year and month
    to_month_date: x => Date.UTC(x.getFullYear(), x.getMonth() - 1),

    // Get the start of the previous month based on the given date or the current time if no parameters are given
    prev_month_start: x => this.to_month_date((x || Date.now()).minusMonths(1)),

    // Get the end time of the previous month based on the given date or the current time if no parameters are given
    prev_month_end: x => this.to_month_date((x || Date.now()).withDayOfMonth(1)).minusSeconds(1),
    prev_month_start_string: x => this.prev_month_start(x).toString().split('T')[0],
    prev_month_end_string: x => this.prev_month_end(x).toString().split('T')[0],
    prev_month_start_epoch: x => this.prev_month_start(x).getTime(),
    prev_month_end_epoch: x => this.prev_month_end(x).getTime()
}


Example 3

In the following example, the spread operator …other can be used to indicate that zero or more parameters can be accepted. As a result, the CONCAT function has two or more parameters. This function returns the concatenation of all parameters.

Code Block
CONCAT: (x, y, ...other) => other.reduce((accum, curVal) => accum + curVal, x.toString() + y.toString()


The 'this' Variable

You may have noticed in the example expression library listed above that the function references the this variable. When defining an object literal, the this variable is set to the object being constructed so that you can reference other functions and data values. The overlay works like the "merge()" method on objects where existing properties are updated instead of replacing the entire object.

...