Author Topic: IRD - Time Range Logic Help  (Read 536 times)

Offline kamalnba

  • Newbie
  • *
  • Posts: 30
  • Karma: 0
IRD - Time Range Logic Help
« on: October 09, 2019, 04:12:51 AM »
Hi all,

I need help in building a logic. I am trying to use Day and Time function and compare it against List Object which has Day as Key and value as Range (07:00-18:00).

I have stored Day into Variable1 and Time into Variable2. Now in List Object, i have created a section Type of Call and defined variable 1 as Key(0,1,2,3) and defined the time range (e.g. 07:00-18:00) as value against each Key.

Variable 3 stores range values based on Current day and I want to compare Variable2 with Variable3(range of values).

Please help.

Offline hsujdik

  • Sr. Member
  • ****
  • Posts: 351
  • Karma: 14
    • Genesys Brasil
Re: IRD - Time Range Logic Help
« Reply #1 on: October 09, 2019, 09:22:20 PM »
Can’t you use Statistical Days and Statistical Tables objects for that, and the function IsSpecialDayEx? Or does it have to be a List?

Offline kamalnba

  • Newbie
  • *
  • Posts: 30
  • Karma: 0
Re: IRD - Time Range Logic Help
« Reply #2 on: October 10, 2019, 12:59:37 AM »
Thanks for the response, I am thinking to use List objects so that I can give access to Business in case they would like to change the timing range based on their requirement.
I will let them access GAX over internet and provide permissions for Routing Parameters Module.

Offline kamalnba

  • Newbie
  • *
  • Posts: 30
  • Karma: 0
Re: IRD - Time Range Logic Help
« Reply #3 on: October 10, 2019, 01:03:17 PM »
Thanks for the response, I am thinking to use List objects so that I can give access to Business in case they would like to change the timing range based on their requirement.
I will let them access GAX over internet and provide permissions for Routing Parameters Module.

Any Ideas Guys how to implement this logic..

Offline René

  • Administrator
  • Hero Member
  • *****
  • Posts: 1800
  • Karma: 59
Re: IRD - Time Range Logic Help
« Reply #4 on: October 10, 2019, 09:38:08 PM »
Hi,

Format of your list object is (if I do understand your description correctly):

Section = type of call
Key-value pairs
- Key = day of week (0-6)
- Value = time range (HH:MM-HH:MM)

Example
Code: [Select]
[InboundCall]
1 = 08:00-17:00
2 = 09:00-17:00
...

You should do following to check if current time fits to configured time range or not

block "Function"/
   timeRange = ListGetDataCfg[<list object name>,<call type>,Day[]]

block "If" (continue is true)
timeRange != ""

block "Assign" /
   tRange1 = StrAsciiTok[timeRange,"-",0]
   tRange2 = StrAsciiTok[timeRange,"-",1]

block "If" (fits to time range if true)
  tRange1 > Time[] && tRange2 < Time[]


Note - GAX OPM module supports parameter of Schedule type that you can use but GAX stores configured dates & times in different format, so you should check the format and write your own logic to parse it.

R.
« Last Edit: October 10, 2019, 09:51:10 PM by René »

Offline sorav84

  • Newbie
  • *
  • Posts: 43
  • Karma: 0
Re: IRD - Time Range Logic Help
« Reply #5 on: October 11, 2019, 02:18:16 AM »
if you are looking to compare time since time doesn't have data type. You can retrieve time using the method suggested in previous post and
remove ':' . So your time will become like 0700 , 1800 which is easy to use in if() statements

Offline kamalnba

  • Newbie
  • *
  • Posts: 30
  • Karma: 0
Re: IRD - Time Range Logic Help
« Reply #6 on: October 19, 2019, 01:53:32 AM »
Hi,

Format of your list object is (if I do understand your description correctly):

Section = type of call
Key-value pairs
- Key = day of week (0-6)
- Value = time range (HH:MM-HH:MM)

Example
Code: [Select]
[InboundCall]
1 = 08:00-17:00
2 = 09:00-17:00
...

You should do following to check if current time fits to configured time range or not

block "Function"/
   timeRange = ListGetDataCfg[<list object name>,<call type>,Day[]]

block "If" (continue is true)
timeRange != ""

block "Assign" /
   tRange1 = StrAsciiTok[timeRange,"-",0]
   tRange2 = StrAsciiTok[timeRange,"-",1]

block "If" (fits to time range if true)
  tRange1 > Time[] && tRange2 < Time[]


Note - GAX OPM module supports parameter of Schedule type that you can use but GAX stores configured dates & times in different format, so you should check the format and write your own logic to parse it.

R.


Yes you are correct at your understanding. I have question on the recommendation.

1. What would be type for Variable Time Range and tRange1 & tRange2.
2. I have created List objects in CME, How Can I show them under parameters in GAX or I have to create the Parameter Template, Group and Parameters from scratch?

TIMERANGE != "" is showing (Error) parse error, bad symbol: '"


TYA.


Offline terry

  • Sr. Member
  • ****
  • Posts: 286
  • Karma: 34
Re: IRD - Time Range Logic Help
« Reply #7 on: October 19, 2019, 03:20:59 AM »
StrAsciiTok works with strings - input timeRange as well as output will be strings.

When comparing string type with time type (like in fragment tRange1 > Time[]) data will be converted to the same type (which is the type of left value),  in this case - string and strings will be compared (as strings).


Offline Dionysis

  • Sr. Member
  • ****
  • Posts: 392
  • Karma: 8
Re: IRD - Time Range Logic Help
« Reply #8 on: October 19, 2019, 07:10:15 AM »
This should be relatively simple to implement, however I wouldn't be comparing strings.  I would convert all the times to integers so that you can easily compare them as integers.

There are probably other ways but this is how I'd go about it.

- take your value from the list object, let's assume 07:00-18:00, and use string functions to set 2 variables of 07:00 and 18:00.
- Then cast each of these into hours and minutes separately as integers.
var1 = 7
var2 = 0
var3 = 18
var4 = 0
- Then use some simple math to create open and close time variable in seconds.
open = 25200
close = 64800
- Then finally set a current time variable to be the number of seconds since midnight (there is a specific function which returns this value).
- Once you have all of this it's a simple matter of comparing the values (make sure you use int type variables):
If open < current time & close > current time.

With all this said though, I've never built an open / close strategy like this, I've always used statistical days or GAX OPM time range parameters.  GAX is very complex to parse though and does not account for daylight savings.
if len(description) < enough:
    from troubleshooting.skills import psychic

Offline kamalnba

  • Newbie
  • *
  • Posts: 30
  • Karma: 0
Re: IRD - Time Range Logic Help
« Reply #9 on: October 19, 2019, 07:17:55 AM »
StrAsciiTok works with strings - input timeRange as well as output will be strings.

When comparing string type with time type (like in fragment tRange1 > Time[]) data will be converted to the same type (which is the type of left value),  in this case - string and strings will be compared (as strings).

Thank you. I have created the subroutine with your feedback and will test it on Monday and post the results.

Offline terry

  • Sr. Member
  • ****
  • Posts: 286
  • Karma: 34
Re: IRD - Time Range Logic Help
« Reply #10 on: October 19, 2019, 10:40:12 AM »
If comparing strings (alphanumerically) is not desirable, probably straightforward type TIME can be used (function Time, for example, returns values of this type).
It was widely used in past (5.x), still implicitly used currently (if you loom at code generated by IRD for time segmentation object - TIME literals are there). Values of this type store inside number of minutes from midnight.

Set IRD option default/tools_tuneup=extended, restart IRD, create variable(s) of type TIME.
Assign to them string (for example result of StrAsciiTok) which has format like hh:mm or hh:mm PM, hh:mm AM, etc. That's all - assigning will result implicit conversion into type of variable (un this case in TIME format) and  comparing these TIME variables with function Time will be done directly on TIME values without any string involved.
 




Offline sorav84

  • Newbie
  • *
  • Posts: 43
  • Karma: 0
Re: IRD - Time Range Logic Help
« Reply #11 on: October 20, 2019, 04:12:23 PM »
I would say removing ':'  is very neat, clean and nifty logic.

You can do any comparison of time like integer, no need to convert time to seconds, no need to setup data types or build big subroutines.

e.g. lets say your OOH is 07:00 - 15:00 and current time is any value between them i.e. 13:00, when you remove ':' you get
0700
1300
1500
then its simple integer comparison  0700<1300 && 1300<1500