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

Offline kamalnba

  • Newbie
  • *
  • Posts: 35
  • Karma: 0
IRD - Time Range Logic Help
« on: October 08, 2019, 07:12:51 PM »
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

  • Hero Member
  • *****
  • Posts: 541
  • Karma: 30
Re: IRD - Time Range Logic Help
« Reply #1 on: October 09, 2019, 12: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: 35
  • Karma: 0
Re: IRD - Time Range Logic Help
« Reply #2 on: October 09, 2019, 03:59:37 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.

Offline kamalnba

  • Newbie
  • *
  • Posts: 35
  • Karma: 0
Re: IRD - Time Range Logic Help
« Reply #3 on: October 10, 2019, 04:03:17 AM »
[quote author=kamalnba link=topic=11455.msg52203#msg52203 date=1570636777]
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.
[/quote]

Any Ideas Guys how to implement this logic..

Offline René

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

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

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

Example
[code][InboundCall]
1 = 08:00-17:00
2 = 09:00-17:00
...
[/code]

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, 12:51:10 PM by René »

Offline sorav84

  • Newbie
  • *
  • Posts: 43
  • Karma: 0
Re: IRD - Time Range Logic Help
« Reply #5 on: October 10, 2019, 05:18:16 PM »
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: 35
  • Karma: 0
Re: IRD - Time Range Logic Help
« Reply #6 on: October 18, 2019, 04:53:32 PM »
[quote author=René link=topic=11455.msg52207#msg52207 date=1570711088]
Hi,

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

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

Example
[code][InboundCall]
1 = 08:00-17:00
2 = 09:00-17:00
...
[/code]

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.
[/quote]


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 [b](Error) parse error, bad symbol: '"[/b]


TYA.


Offline terry

  • Sr. Member
  • ****
  • Posts: 328
  • Karma: 35
Re: IRD - Time Range Logic Help
« Reply #7 on: October 18, 2019, 06:20:59 PM »
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: 408
  • Karma: 8
Re: IRD - Time Range Logic Help
« Reply #8 on: October 18, 2019, 10:10:15 PM »
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.

Offline kamalnba

  • Newbie
  • *
  • Posts: 35
  • Karma: 0
Re: IRD - Time Range Logic Help
« Reply #9 on: October 18, 2019, 10:17:55 PM »
[quote author=terry link=topic=11455.msg52226#msg52226 date=1571422859]
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).
[/quote]

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: 328
  • Karma: 35
Re: IRD - Time Range Logic Help
« Reply #10 on: October 19, 2019, 01: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, 07:12:23 AM »
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