Brekeke Forum Index » Brekeke SIP Server Forum

Post new topic   Reply to topic
$time
Author Message
noiptel
Brekeke Talented


Joined: 22 Feb 2010
Posts: 68
Location: USA

PostPosted: Fri Sep 23, 2011 7:33 am    Post subject: $time Reply with quote

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/networkpatterns.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.
Back to top
View user's profile
Laurie
Brekeke Master Guru


Joined: 07 Jan 2008
Posts: 245

PostPosted: Tue Sep 27, 2011 10:25 am    Post subject: Reply with quote

$time( "HH:mm" ) = ^10:3[2-9]|^10:[4-5]|^1[12]|^13:0|^13:1[0-5]
Back to top
View user's profile
noiptel
Brekeke Talented


Joined: 22 Feb 2010
Posts: 68
Location: USA

PostPosted: Mon Nov 14, 2011 9:02 pm    Post subject: Reply with quote

Can you please if the below syntax is correct?

From 2AM to 7:30PM

$time( “HH:mm” ) = ^0[2-9]|^1[0-8]|^19:3[0]
Back to top
View user's profile
ambrosio
Brekeke Master Guru


Joined: 27 Mar 2008
Posts: 215

PostPosted: Mon Nov 14, 2011 9:51 pm    Post subject: Reply with quote

$time( “HH:mm” ) = ^0[2-9]|^1[0-8]|^19:[0-3]
Back to top
View user's profile
noiptel
Brekeke Talented


Joined: 22 Feb 2010
Posts: 68
Location: USA

PostPosted: Tue Dec 06, 2011 4:48 pm    Post subject: Reply with quote

it is not working, can you please verify rule
Back to top
View user's profile
noiptel
Brekeke Talented


Joined: 22 Feb 2010
Posts: 68
Location: USA

PostPosted: Mon Jan 02, 2012 12:34 pm    Post subject: Reply with quote

The below rule works well to block calls from 2AM to 6PM:

$time=^0[2-9]|^1[0-7]

We need the correct rule to block calls from 2AM to 6:30PM

Please help

Thanks
Back to top
View user's profile
Laurie
Brekeke Master Guru


Joined: 07 Jan 2008
Posts: 245

PostPosted: Mon Jan 02, 2012 3:22 pm    Post subject: Reply with quote

try the following dialplan plugin method.

Code:

  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
Back to top
View user's profile
Laurie
Brekeke Master Guru


Joined: 07 Jan 2008
Posts: 245

PostPosted: Mon Jan 02, 2012 3:23 pm    Post subject: Reply with quote

>We need the correct rule to block calls from 2AM to 6:30PM

it will be
$plugin.range( "2:00", "18:30" ) = true
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    Brekeke Forum Index » Brekeke SIP Server Forum All times are GMT - 7 Hours
Page 1 of 1