Skip to main content
Version: 9.0.0

Custom Date

A Custom Date class was created in order to help to work with the Date type of control. If you don`t need a fixed date, but it should be changed depending on the current date, you can use the methods available in the Date Picker type of Pega model control or customize it if needed.

E.g.:

await pega.datePickerByDataTestId('veryImportantDate').setTodayPlusDays(10);
await pega.datePickerByDataTestId ('anotherVeryImportantDate').setTodayMinusDays(1234);

How to customize the date:

Applying this method, you can set up:

  • the order of elements;
  • type of displaying the month (number, or the abbreviated month name);
  • the separator used ('/', ‘-' or '.’):
console.log(`${today().plusMonths(1).toString('-', ['y','m','d'])}`)
//output: 2020-11-19

console.log(`${today().plusDays(31).toString(' ', ['d','M','y'])}`)
//output: 19 Nov 2020

It includes comparison methods also:

console.log(`${today().plusDays(422).isBeforeThan(today().plusYears(2))}`)
//output: true
info

Date Picker control accepts Custom date format to be set. e.g.:

await pega.datePickerByDataTestId('Date').set(today().plusDays(5));
tip

If you need to get a string value and to use it in any type of control, you need to apply:

  • toString (default separator is ., the default order is ['m', 'd', 'y'])
  • toStringBySlash function (default separator is /, the default order is ['m', 'd', 'y']).