1. Brekeke Product Name and version:Version 2.4.3.9 Advanced
2. Java version:
3. OS type and the version:
4. UA (phone), gateway or other hardware/software involved:
5. Select your network pattern from http://www.brekeke-sip.com/bbs/network/ ... terns.html :
6. Your problem: I would like to write a rule with the below time window:
From 10:32AM to 1:15PM
Please confirm how this should be written.
Thanks.
$time
Moderator: Brekeke Support Team
try the following dialplan plugin method.
Code: Select all
static public String range( String[] arg, SIPpacket sippacket, Properties pr ) throws Exception
{
if ( ( arg != null ) && ( arg.length > 1 ) ) {
int i1 = arg[0].indexOf( ':' ) ;
int i2 = arg[1].indexOf( ':' ) ;
if ( ( i1 > 0 ) && ( i2 > 0 ) ) {
int hour1 = Integer.valueOf( arg[0].substring( 0, i1 ) ) ;
int min1 = Integer.valueOf( arg[0].substring( i1 + 1 ) ) ;
long time1 = ( hour1 * 60 ) + min1 ;
int hour2 = Integer.valueOf( arg[1].substring( 0, i2 ) ) ;
int min2 = Integer.valueOf( arg[1].substring( i2 + 1 ) ) ;
long time2 = ( hour2 * 60 ) + min2 ;
Calendar cal = Calendar.getInstance() ;
// time zone
if ( ( arg.length > 2 ) && ( arg[2] != null ) ) {
cal.setTimeZone( TimeZone.getTimeZone( arg[2] ) ) ;
}
int hourNow = cal.get( Calendar.HOUR_OF_DAY ) ;
int minNow = cal.get( Calendar.MINUTE ) ;
long timeNow = ( hourNow * 60 ) + minNow ;
if ( ( time1 <= timeNow ) && ( timeNow <= time2 ) ) {
return ( "true" ) ;
}
}
}
return ( "false" ) ;
}
Last edited by Laurie on Mon Jan 02, 2012 3:24 pm, edited 1 time in total.