0% found this document useful (0 votes)
45 views2 pages

40.number of Days in February

Uploaded by

A
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views2 pages

40.number of Days in February

Uploaded by

A
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Let’s create a use case in Pega to determine the number of days in February for

a given year using a Data Transform. This use case will involve creating a Data
Transform that uses the provided function to set the number of days in
February.

Step 1: Create Properties

1. Create a property to hold the year input. For example, Year.

2. Create a property to hold the number of days in February. For example, DaysInFebruary.

Step 2: Create a Data Transform

1. Navigate to the Data Transform section in your Pega application.

2. Create a new Data Transform. Name it something like DetermineDaysInFebruary.

Step 3: Define the Logic in the Data Transform

1. Set the default value of DaysInFebruary to 28.

2. Add a step to check if the year is a leap year. You can use the following logic:

o If Year % 4 == 0 and (Year % 100 != 0 or Year % 400 == 0), then set DaysInFebruary to 29.

Here’s how you can structure the Data Transform:

1. Set .DaysInFebruary = 28

2. When .Year % 4 == 0

- When .Year % 100 != 0

- Set .DaysInFebruary = 29

- Otherwise

- When .Year % 400 == 0

- Set .DaysInFebruary = 29

Step 4: Test the Data Transform

1. Create a test case to verify the Data Transform.

2. Input different years to ensure the logic works correctly:

o For example, input 2020 (leap year) and check if DaysInFebruary is set to 29.

Confidential - Not for Public Consumption or Distribution


o Input 2021 (non-leap year) and check if DaysInFebruary is set to 28.

Leap Year Rules:


A year is a leap year if it is divisible by 4.
However, if the year is also divisible by 100, it is not a leap year unless it is also divisible by 400.

Function Breakdown:
Param.Year % 4 == 0: This checks if the year is divisible by 4.
Param.Year % 100 == 0: This checks if the year is divisible by 100.

Param.Year % 400 != 0: This checks if the year is not divisible by 400.


&&: Logical AND operator.
!: Logical NOT operator.
? 29 : 28: This is the ternary operator. If the condition before the ? is true, it returns 29;
otherwise, it returns 28.

Combined Logic:
(Param.Year % 4 == 0 && !(Param.Year % 100 == 0 && Param.Year % 400 != 0))
First, it checks if the year is divisible by 4.
Then, it checks if the year is divisible by 100 and not divisible by 400.
If the year is divisible by 4 and either not divisible by 100 or divisible by 400, it returns 29
(indicating a leap year with 29 days in February).

Otherwise, it returns 28 (indicating a common year with 28 days in February).


So, the function correctly determines the number of days in February based on whether the
year is a leap year or not.

Confidential - Not for Public Consumption or Distribution

You might also like