Need help in Date Time conversion along with timezone and matching for Validation in an Interface

Certified Associate Developer

Hi Experts,

Need your help in the following issue:

Here is a validation for a Date and Time(captured in text) field along with the Timezone as shown below.

/*Code -- Test_Rule_Timezone*/
/*We are getting Date and Time and the Timzezone selected by the user from the dropdown*/
/*Based on the Timezone selection(cons!CDM2_VAL_STANDARD_TIMEZONE) we are subtracting the hours 
that is stored in the constant(cons!TEST_CONS_TIMEZONE) from the date and time selected by the user*/
a!localVariables(
  local!hours: a!match(
    value: ri!timezone,
    equals: cons!CDM2_VAL_STANDARD_TIMEZONE[1],
    then: cons!TEST_CONS_TIMEZONE[1],
    equals: cons!CDM2_VAL_STANDARD_TIMEZONE[2],
    then: cons!TEST_CONS_TIMEZONE[2],
    equals: cons!CDM2_VAL_STANDARD_TIMEZONE[3],
    then: cons!TEST_CONS_TIMEZONE[3],
    equals: cons!CDM2_VAL_STANDARD_TIMEZONE[4],
    then: cons!TEST_CONS_TIMEZONE[4],
    equals: cons!CDM2_VAL_STANDARD_TIMEZONE[5],
    then: cons!TEST_CONS_TIMEZONE[5],
    equals: cons!CDM2_VAL_STANDARD_TIMEZONE[6],
    then: cons!TEST_CONS_TIMEZONE[6],
    equals: cons!CDM2_VAL_DAYLIGHT_TIMEZONE_DISPLAY[1],
    then: cons!TEST_CONS_TIMEZONE[8],
    equals: cons!CDM2_VAL_DAYLIGHT_TIMEZONE_DISPLAY[2],
    then: cons!TEST_CONS_TIMEZONE[9],
    equals: cons!CDM2_VAL_DAYLIGHT_TIMEZONE_DISPLAY[3],
    then: cons!TEST_CONS_TIMEZONE[10],
    equals: cons!CDM2_VAL_DAYLIGHT_TIMEZONE_DISPLAY[4],
    then: cons!TEST_CONS_TIMEZONE[11],
    equals: cons!CDM2_VAL_DAYLIGHT_TIMEZONE_DISPLAY[5],
    then: cons!TEST_CONS_TIMEZONE[12],
    equals: cons!CDM2_VAL_DAYLIGHT_TIMEZONE_DISPLAY[6],
    then: cons!TEST_CONS_TIMEZONE[13],
    default: 0
  ),
  local!minutes: tointeger(index(split(local!hours,":"),2,0)),
  if(
    a!isNullOrEmpty(ri!dateTime),
    null(),
    a!subtractDateTime(ri!dateTime,0,0,0,local!hours,local!minutes)
    )
)

I need to validate that the Search Start Date + Search Start Time + Timezone -----should be less than the current system timezone,

Search End Date + Search End Time + Timezone -----should be less than the current system timezone.

Also Search Start Date + Search Start Time + Timezone(UTC)  <  Search End Date + Search End Time + Timezone(like UTC-7).

I am attaching the code for the same, need your help as I am not able to get the desired output.

Thank you in advance for your help!

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Associate Developer

    /*Code for the Validation*/
    
    if(rule!Test_Rule_Timezone(timezone: fv!item.timeZone, dateTime: fv!item.startSearchDateTime) > rule!CDM2_DateTime_Converter(     date: todate(split(now()," ")[1]),     time: text(gmt(local(now(),"GMT")), "mm/dd/yyyy hh:mm:ss")   ),
                            "Please select a Date Time on or before current Date Time.",
                            if(
                              and(
                                a!isNotNullOrEmpty(fv!item.startSearchDate),
                                a!isNotNullOrEmpty(fv!item.endSearchDate),
                                rule!Test_Rule_Timezone(timezone: fv!item.timeZone, dateTime: fv!item.startSearchDateTime) > rule!Test_Rule_Timezone(timezone: fv!item.timeZone, dateTime: fv!item.endSearchDateTime)
                              ),
                              "'Search Start Date Time' can not be after 'Search End Date Time'",
                              {}
                            )
                            ), 

Reply
  • 0
    Certified Associate Developer

    /*Code for the Validation*/
    
    if(rule!Test_Rule_Timezone(timezone: fv!item.timeZone, dateTime: fv!item.startSearchDateTime) > rule!CDM2_DateTime_Converter(     date: todate(split(now()," ")[1]),     time: text(gmt(local(now(),"GMT")), "mm/dd/yyyy hh:mm:ss")   ),
                            "Please select a Date Time on or before current Date Time.",
                            if(
                              and(
                                a!isNotNullOrEmpty(fv!item.startSearchDate),
                                a!isNotNullOrEmpty(fv!item.endSearchDate),
                                rule!Test_Rule_Timezone(timezone: fv!item.timeZone, dateTime: fv!item.startSearchDateTime) > rule!Test_Rule_Timezone(timezone: fv!item.timeZone, dateTime: fv!item.endSearchDateTime)
                              ),
                              "'Search Start Date Time' can not be after 'Search End Date Time'",
                              {}
                            )
                            ), 

Children
No Data