InDateRangeDual

See javadoc - uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual

Available since Koryphe version 1.1.0

The predicate tests 2 date inputs (a start date and an end date) are within a defined range. You can configure the start and end time strings using the following formats:

  • timestamp in milliseconds
  • yyyy/MM
  • yyyy/MM/dd
  • yyyy/MM/dd HH
  • yyyy/MM/dd HH:mm
  • yyyy/MM/dd HH:mm:ss

You can use a space, '-', '/', '_', ':', '|', or '.' to separate the parts.

Examples

In date range with day precision

Java
JSON
Full JSON
Python
final InDateRangeDual function = new InDateRangeDual.Builder()
        .start("2017/01/01")
        .end("2017/02/01")
        .build();
{
  "class" : "InDateRangeDual",
  "start" : "2017/01/01",
  "end" : "2017/02/01"
}
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual",
  "start" : "2017/01/01",
  "end" : "2017/02/01"
}
g.InDateRangeDual( 
  start="2017/01/01", 
  end="2017/02/01" 
)

Input type:

java.lang.Comparable, java.lang.Comparable

Example inputs:

Input TypeInputResult
[java.util.Date, java.util.Date][Fri Jan 01 00:00:00 UTC 2016, Mon Feb 01 00:00:00 UTC 2016]false
[java.util.Date, java.util.Date][Sun Jan 01 00:00:00 UTC 2017, Sun Jan 01 00:00:00 UTC 2017]true
[java.util.Date, java.util.Date][Sun Jan 01 01:00:00 UTC 2017, Sun Jan 01 01:00:00 UTC 2017]true
[java.util.Date, java.util.Date][Sun Jan 01 01:00:00 UTC 2017, Sun Jan 01 23:59:59 UTC 2017]true
[java.util.Date, java.util.Date][Sun Jan 01 01:00:00 UTC 2017, Wed Feb 01 00:00:00 UTC 2017]true
[java.util.Date, java.util.Date][Sun Jan 01 01:00:00 UTC 2017, Wed Feb 01 00:00:01 UTC 2017]true
[ ,][null, null]false

In date range with second precision

Java
JSON
Full JSON
Python
final InDateRangeDual function = new InDateRangeDual.Builder()
        .start("2017/01/01 01:30:10")
        .end("2017/01/01 01:30:50")
        .build();
{
  "class" : "InDateRangeDual",
  "start" : "2017/01/01 01:30:10",
  "end" : "2017/01/01 01:30:50"
}
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual",
  "start" : "2017/01/01 01:30:10",
  "end" : "2017/01/01 01:30:50"
}
g.InDateRangeDual( 
  end="2017/01/01 01:30:50", 
  start="2017/01/01 01:30:10" 
)

Input type:

java.lang.Comparable, java.lang.Comparable

Example inputs:

Input TypeInputResult
[java.util.Date, java.util.Date][Sun Jan 01 01:30:08 UTC 2017, Sun Jan 01 01:30:09 UTC 2017]false
[java.util.Date, java.util.Date][Sun Jan 01 01:30:10 UTC 2017, Sun Jan 01 01:30:10 UTC 2017]true
[java.util.Date, java.util.Date][Sun Jan 01 01:30:10 UTC 2017, Sun Jan 01 01:30:20 UTC 2017]true
[java.util.Date, java.util.Date][Sun Jan 01 01:30:10 UTC 2017, Sun Jan 01 01:30:50 UTC 2017]true
[java.util.Date, java.util.Date][Sun Jan 01 01:30:10 UTC 2017, Sun Jan 01 01:30:51 UTC 2017]true
[ ,][null, null]false

In date range with timestamps

Java
JSON
Full JSON
Python
final InDateRangeDual function = new InDateRangeDual.Builder()
        .start("1483315200")
        .end("1485907200")
        .build();
{
  "class" : "InDateRangeDual",
  "start" : "1483315200",
  "end" : "1485907200"
}
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual",
  "start" : "1483315200",
  "end" : "1485907200"
}
g.InDateRangeDual( 
  start="1483315200", 
  end="1485907200" 
)

Input type:

java.lang.Comparable, java.lang.Comparable

Example inputs:

Input TypeInputResult
[java.util.Date, java.util.Date][Sun Jan 18 04:01:55 UTC 1970, Sun Jan 18 04:01:55 UTC 1970]false
[java.util.Date, java.util.Date][Sun Jan 18 04:01:55 UTC 1970, Sun Jan 18 04:01:55 UTC 1970]true
[java.util.Date, java.util.Date][Sun Jan 18 04:01:55 UTC 1970, Sun Jan 18 04:01:55 UTC 1970]true
[java.util.Date, java.util.Date][Sun Jan 18 04:01:56 UTC 1970, Sun Jan 18 04:45:07 UTC 1970]true
[java.util.Date, java.util.Date][Sun Jan 18 04:01:56 UTC 1970, Sun Jan 18 04:45:07 UTC 1970]true
[ ,][null, null]false

In date range exclusive

Java
JSON
Full JSON
Python
final InDateRangeDual function = new InDateRangeDual.Builder()
        .start("2017/01/01")
        .end("2017/02/01")
        .startInclusive(false)
        .endInclusive(false)
        .build();
{
  "class" : "InDateRangeDual",
  "start" : "2017/01/01",
  "end" : "2017/02/01",
  "startInclusive" : false,
  "endInclusive" : false
}
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual",
  "start" : "2017/01/01",
  "end" : "2017/02/01",
  "startInclusive" : false,
  "endInclusive" : false
}
g.InDateRangeDual( 
  start_inclusive=False, 
  start="2017/01/01", 
  end_inclusive=False, 
  end="2017/02/01" 
)

Input type:

java.lang.Comparable, java.lang.Comparable

Example inputs:

Input TypeInputResult
[java.util.Date, java.util.Date][Fri Jan 01 00:00:00 UTC 2016, Mon Feb 01 00:00:00 UTC 2016]false
[java.util.Date, java.util.Date][Sun Jan 01 00:00:00 UTC 2017, Sun Jan 01 00:00:00 UTC 2017]false
[java.util.Date, java.util.Date][Sun Jan 01 01:00:00 UTC 2017, Sun Jan 01 01:00:00 UTC 2017]true
[java.util.Date, java.util.Date][Sun Jan 01 01:00:00 UTC 2017, Sun Jan 01 23:59:59 UTC 2017]true
[java.util.Date, java.util.Date][Sun Jan 01 01:00:00 UTC 2017, Wed Feb 01 00:00:00 UTC 2017]true
[java.util.Date, java.util.Date][Sun Jan 01 01:00:00 UTC 2017, Wed Feb 01 00:00:01 UTC 2017]true
[ ,][null, null]false

Within the last week

If the end of the range is not specified then the end of the range is unbounded.

Java
JSON
Full JSON
Python
final InDateRangeDual function = new InDateRangeDual.Builder()
        .startOffset(-7L)
                // end is not set - it is unbounded
        .offsetUnit(TimeUnit.DAY)
        .build();
{
  "class" : "InDateRangeDual",
  "startOffset" : -7,
  "offsetUnit" : "DAY"
}
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual",
  "startOffset" : -7,
  "offsetUnit" : "DAY"
}
g.InDateRangeDual( 
  offset_unit="DAY", 
  start_offset=-7 
)

Input type:

java.lang.Comparable, java.lang.Comparable

Example inputs:

Input TypeInputResult
[java.util.Date, java.util.Date][Wed Sep 12 13:20:59 UTC 2018, Thu Sep 13 13:20:59 UTC 2018]false
[java.util.Date, java.util.Date][Sat Sep 15 13:20:59 UTC 2018, Sat Sep 15 13:20:59 UTC 2018]true
[java.util.Date, java.util.Date][Sat Sep 15 13:20:59 UTC 2018, Thu Sep 20 13:20:59 UTC 2018]true
[java.util.Date, java.util.Date][Fri Sep 21 13:20:59 UTC 2018, Fri Sep 21 13:20:59 UTC 2018]true
[ ,][null, null]false

Exactly 7 hours ago

Java
JSON
Full JSON
Python
final InDateRangeDual function = new InDateRangeDual.Builder()
        .startOffset(-7L)
        .endOffset(-6L)
        .endInclusive(false)
        .offsetUnit(TimeUnit.HOUR)
        .build();
{
  "class" : "InDateRangeDual",
  "startOffset" : -7,
  "endOffset" : -6,
  "endInclusive" : false,
  "offsetUnit" : "HOUR"
}
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual",
  "startOffset" : -7,
  "endOffset" : -6,
  "endInclusive" : false,
  "offsetUnit" : "HOUR"
}
g.InDateRangeDual( 
  start_offset=-7, 
  end_inclusive=False, 
  offset_unit="HOUR", 
  end_offset=-6 
)

Input type:

java.lang.Comparable, java.lang.Comparable

Example inputs:

Input TypeInputResult
[java.util.Date, java.util.Date][Fri Sep 21 05:20:59 UTC 2018, Fri Sep 21 06:20:59 UTC 2018]false
[java.util.Date, java.util.Date][Fri Sep 21 06:21:09 UTC 2018, Fri Sep 21 06:21:19 UTC 2018]true
[java.util.Date, java.util.Date][Fri Sep 21 06:21:09 UTC 2018, Fri Sep 21 07:20:49 UTC 2018]true
[java.util.Date, java.util.Date][Fri Sep 21 06:21:09 UTC 2018, Fri Sep 21 07:21:09 UTC 2018]true
[java.util.Date, java.util.Date][Fri Sep 21 06:21:09 UTC 2018, Fri Sep 21 13:20:59 UTC 2018]true
[ ,][null, null]false

Fully uncontained range

Java
JSON
Full JSON
Python
final InDateRangeDual function = new InDateRangeDual.Builder()
        .start("2017/03/01")
        .end("2017/08/01")
        .startFullyContained(false)
        .endFullyContained(false)
        .build();
{
  "class" : "InDateRangeDual",
  "start" : "2017/03/01",
  "end" : "2017/08/01",
  "endFullyContained" : false,
  "startFullyContained" : false
}
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual",
  "start" : "2017/03/01",
  "end" : "2017/08/01",
  "endFullyContained" : false,
  "startFullyContained" : false
}
g.InDateRangeDual( 
  start_fully_contained=False, 
  start="2017/03/01", 
  end_fully_contained=False, 
  end="2017/08/01" 
)

Input type:

java.lang.Comparable, java.lang.Comparable

Example inputs:

Input TypeInputResult
[java.util.Date, java.util.Date][Sun Jan 01 00:00:00 UTC 2017, Wed Feb 01 00:00:00 UTC 2017]false
[java.util.Date, java.util.Date][Sun Jan 01 00:00:00 UTC 2017, Sat Apr 01 00:00:00 UTC 2017]true
[java.util.Date, java.util.Date][Sat Apr 01 00:00:00 UTC 2017, Mon May 01 00:00:00 UTC 2017]true
[java.util.Date, java.util.Date][Sat Apr 01 00:00:00 UTC 2017, Fri Sep 01 00:00:00 UTC 2017]true
[java.util.Date, java.util.Date][Fri Sep 01 00:00:00 UTC 2017, Sun Oct 01 00:00:00 UTC 2017]false
[ ,][null, null]false

Start contained range

Java
JSON
Full JSON
Python
final InDateRangeDual function = new InDateRangeDual.Builder()
        .start("2017/03/01")
        .end("2017/08/01")
        .startFullyContained(true)
        .endFullyContained(false)
        .build();
{
  "class" : "InDateRangeDual",
  "start" : "2017/03/01",
  "end" : "2017/08/01",
  "endFullyContained" : false,
  "startFullyContained" : true
}
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual",
  "start" : "2017/03/01",
  "end" : "2017/08/01",
  "endFullyContained" : false,
  "startFullyContained" : true
}
g.InDateRangeDual( 
  start_fully_contained=True, 
  start="2017/03/01", 
  end="2017/08/01", 
  end_fully_contained=False 
)

Input type:

java.lang.Comparable, java.lang.Comparable

Example inputs:

Input TypeInputResult
[java.util.Date, java.util.Date][Sun Jan 01 00:00:00 UTC 2017, Wed Feb 01 00:00:00 UTC 2017]false
[java.util.Date, java.util.Date][Sun Jan 01 00:00:00 UTC 2017, Sat Apr 01 00:00:00 UTC 2017]false
[java.util.Date, java.util.Date][Sat Apr 01 00:00:00 UTC 2017, Mon May 01 00:00:00 UTC 2017]true
[java.util.Date, java.util.Date][Sat Apr 01 00:00:00 UTC 2017, Fri Sep 01 00:00:00 UTC 2017]true
[java.util.Date, java.util.Date][Fri Sep 01 00:00:00 UTC 2017, Sun Oct 01 00:00:00 UTC 2017]false
[ ,][null, null]false

Fully contained range

Java
JSON
Full JSON
Python
final InDateRangeDual function = new InDateRangeDual.Builder()
        .start("2017/03/01")
        .end("2017/08/01")
        .startFullyContained(true)
        .endFullyContained(true)
        .build();
{
  "class" : "InDateRangeDual",
  "start" : "2017/03/01",
  "end" : "2017/08/01",
  "endFullyContained" : true,
  "startFullyContained" : true
}
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual",
  "start" : "2017/03/01",
  "end" : "2017/08/01",
  "endFullyContained" : true,
  "startFullyContained" : true
}
g.InDateRangeDual( 
  start="2017/03/01", 
  start_fully_contained=True, 
  end_fully_contained=True, 
  end="2017/08/01" 
)

Input type:

java.lang.Comparable, java.lang.Comparable

Example inputs:

Input TypeInputResult
[java.util.Date, java.util.Date][Sun Jan 01 00:00:00 UTC 2017, Wed Feb 01 00:00:00 UTC 2017]false
[java.util.Date, java.util.Date][Sun Jan 01 00:00:00 UTC 2017, Sat Apr 01 00:00:00 UTC 2017]false
[java.util.Date, java.util.Date][Sat Apr 01 00:00:00 UTC 2017, Mon May 01 00:00:00 UTC 2017]true
[java.util.Date, java.util.Date][Sat Apr 01 00:00:00 UTC 2017, Fri Sep 01 00:00:00 UTC 2017]false
[java.util.Date, java.util.Date][Fri Sep 01 00:00:00 UTC 2017, Sun Oct 01 00:00:00 UTC 2017]false
[ ,][null, null]false

results matching ""

    No results matching ""