willow-utils/src/main/java/com/btr/proxy/selector/pac/PacScriptMethods.java
@Override
  public boolean dateRange(Object day1, Object month1, Object year1,
      Object day2, Object month2, Object year2, Object gmt) {

    // Guess the parameter meanings.
    Map<String, Integer> params = new HashMap<String, Integer>();
    parseDateParam(params, day1);
    parseDateParam(params, month1);
    parseDateParam(params, year1);
    parseDateParam(params, day2);
    parseDateParam(params, month2);
    parseDateParam(params, year2);
    parseDateParam(params, gmt);

    // Get current date
    boolean useGmt = params.get("gmt") != null;
    Calendar cal = getCurrentTime(useGmt);
    Date current = cal.getTime();

    // Build the "from" date
    if (params.get("day1") != null) {
      cal.set(Calendar.DAY_OF_MONTH, params.get("day1"));
    }
    if (params.get("month1") != null) {
      cal.set(Calendar.MONTH, params.get("month1"));
    }
    if (params.get("year1") != null) {
      cal.set(Calendar.YEAR, params.get("year1"));
    }
    Date from = cal.getTime();

    // Build the "to" date
    Date to;
    if (params.get("day2") != null) {
      cal.set(Calendar.DAY_OF_MONTH, params.get("day2"));
    }
    if (params.get("month2") != null) {
      cal.set(Calendar.MONTH, params.get("month2"));
    }
    if (params.get("year2") != null) {
      cal.set(Calendar.YEAR, params.get("year2"));
    }
    to = cal.getTime();

    // Need to increment to the next month?
    if (to.before(from)) {
      cal.add(Calendar.MONTH, +1);
      to = cal.getTime();
    }
    // Need to increment to the next year?
    if (to.before(from)) {
      cal.add(Calendar.YEAR, +1);
      cal.add(Calendar.MONTH, -1);
      to = cal.getTime();
    }

    return current.compareTo(from) >= 0 && current.compareTo(to) <= 0;
  }
@Override
  public boolean dateRange(Object day1, Object month1, Object year1,
      Object day2, Object month2, Object year2, Object gmt) {

    // Guess the parameter meanings.
    Map<String, Integer> params = new HashMap<String, Integer>();
    parseDateParam(params, day1);
    parseDateParam(params, month1);
    parseDateParam(params, year1);
    parseDateParam(params, day2);
    parseDateParam(params, month2);
    parseDateParam(params, year2);
    parseDateParam(params, gmt);

    // Get current date
    boolean useGmt = params.get("gmt") != null;
    Calendar cal = getCurrentTime(useGmt);
    Date current = cal.getTime();

    // Build the "from" date
    if (params.get("day1") != null) {
      cal.set(Calendar.DAY_OF_MONTH, params.get("day1"));
    }
    if (params.get("month1") != null) {
      cal.set(Calendar.MONTH, params.get("month1"));
    }
    if (params.get("year1") != null) {
      cal.set(Calendar.YEAR, params.get("year1"));
    }
    Date from = cal.getTime();

    // Build the "to" date
    Date to;
    if (params.get("day2") != null) {
      cal.set(Calendar.DAY_OF_MONTH, params.get("day2"));
    }
    if (params.get("month2") != null) {
      cal.set(Calendar.MONTH, params.get("month2"));
    }
    if (params.get("year2") != null) {
      cal.set(Calendar.YEAR, params.get("year2"));
    }
    to = cal.getTime();

    // Need to increment to the next month?
    if (to.before(from)) {
      cal.add(Calendar.MONTH, +1);
      to = cal.getTime();
    }
    // Need to increment to the next year?
    if (to.before(from)) {
      cal.add(Calendar.YEAR, +1);
      cal.add(Calendar.MONTH, -1);
      to = cal.getTime();
    }

    return current.compareTo(from) >= 0 && current.compareTo(to) <= 0;
  }
@ Override public boolean dateRange ( Object day1 , Object month1 , Object year1 , Object day2 , Object month2 , Object year2 , Object gmt ) { // Guess the parameter meanings. Map < String , Integer > params = new HashMap < String , Integer > ( ) ; parseDateParam ( params , day1 ) ; parseDateParam ( params , month1 ) ; parseDateParam ( params , year1 ) ; parseDateParam ( params , day2 ) ; parseDateParam ( params , month2 ) ; parseDateParam ( params , year2 ) ; parseDateParam ( params , gmt ) ; // Get current date boolean useGmt = params . get ( "gmt" ) != null ; Calendar cal = getCurrentTime ( useGmt ) ; Date current = cal . getTime ( ) ; // Build the "from" date if ( params . get ( "day1" ) != null ) { cal . set ( Calendar . DAY_OF_MONTH , params . get ( "day1" ) ) ; } if ( params . get ( "month1" ) != null ) { cal . set ( Calendar . MONTH , params . get ( "month1" ) ) ; } if ( params . get ( "year1" ) != null ) { cal . set ( Calendar . YEAR , params . get ( "year1" ) ) ; } Date from = cal . getTime ( ) ; // Build the "to" date Date to ; if ( params . get ( "day2" ) != null ) { cal . set ( Calendar . DAY_OF_MONTH , params . get ( "day2" ) ) ; } if ( params . get ( "month2" ) != null ) { cal . set ( Calendar . MONTH , params . get ( "month2" ) ) ; } if ( params . get ( "year2" ) != null ) { cal . set ( Calendar . YEAR , params . get ( "year2" ) ) ; } to = cal . getTime ( ) ; // Need to increment to the next month? if ( to . before ( from ) ) { cal . add ( Calendar . MONTH , + 1 ) ; to = cal . getTime ( ) ; } // Need to increment to the next year? if ( to . before ( from ) ) { cal . add ( Calendar . YEAR , + 1 ) ; cal . add ( Calendar . MONTH , - 1 ) ; to = cal . getTime ( ) ; } return current . compareTo ( from ) >= 0 && current . compareTo ( to ) <= 0 ; }
***********************************************************************
Only the first parameter is mandatory. All other parameters can be left out
therefore the meaning of the parameters changes. The method definition
shows the version with the most possible parameters filled. The real
meaning of the parameters is guessed from it's value. If "from" and "to"
are specified then the bounds are inclusive. If the "GMT" parameter is
specified, times are taken to be in GMT, otherwise the local time zone is
used.

@param day1
is the day of month between 1 and 31 (as an integer).
@param month1
one of JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
@param year1
is the full year number, for example 1995 (but not 95). Integer.
@param day2
is the day of month between 1 and 31 (as an integer).
@param month2
one of JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
@param year2
is the full year number, for example 1995 (but not 95). Integer.
@param gmt
"GMT" for gmt time format else "undefined"
@return true if the current date matches the given range.
**********************************************************************
*********************************************************************** Only the first parameter is mandatory . All other parameters can be left out therefore the meaning of the parameters changes . The method definition shows the version with the most possible parameters filled . The real meaning of the parameters is guessed from it s value . If from and to are specified then the bounds are inclusive . If the GMT parameter is specified times are taken to be in GMT otherwise the local time zone is used .