$time

Discuss any topic about Brekeke SIP Server.

Moderator: Brekeke Support Team

Post Reply
noiptel
Posts: 68
Joined: Mon Feb 22, 2010 9:24 pm
Location: USA

$time

Post by noiptel »

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.
Laurie
Posts: 245
Joined: Mon Jan 07, 2008 12:25 pm

Post by Laurie »

$time( "HH:mm" ) = ^10:3[2-9]|^10:[4-5]|^1[12]|^13:0|^13:1[0-5]
noiptel
Posts: 68
Joined: Mon Feb 22, 2010 9:24 pm
Location: USA

Post by noiptel »

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]
ambrosio
Posts: 215
Joined: Thu Mar 27, 2008 12:20 pm

Post by ambrosio »

$time( “HH:mm” ) = ^0[2-9]|^1[0-8]|^19:[0-3]
noiptel
Posts: 68
Joined: Mon Feb 22, 2010 9:24 pm
Location: USA

Post by noiptel »

it is not working, can you please verify rule
noiptel
Posts: 68
Joined: Mon Feb 22, 2010 9:24 pm
Location: USA

Post by noiptel »

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
Laurie
Posts: 245
Joined: Mon Jan 07, 2008 12:25 pm

Post by Laurie »

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.
Laurie
Posts: 245
Joined: Mon Jan 07, 2008 12:25 pm

Post by Laurie »

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

it will be
$plugin.range( "2:00", "18:30" ) = true
Post Reply