InTimeRangeDual

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

Available since Koryphe version 1.1.0

The predicate tests 2 timestamp (long) inputs (a start timestamp and an end timestamp) 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 time range with day precision

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

Input type:

java.lang.Comparable, java.lang.Comparable

Example inputs:

Input TypeInputResult
[java.lang.Long, java.lang.Long][1451606400000, 1454284800000]false
[java.lang.Long, java.lang.Long][1483228800000, 1483228800000]true
[java.lang.Long, java.lang.Long][1483232400000, 1483232400000]true
[java.lang.Long, java.lang.Long][1483232400000, 1483315199000]true
[java.lang.Long, java.lang.Long][1483232400000, 1485907200000]true
[java.lang.Long, java.lang.Long][1483232400000, 1485907201000]true
[ ,][null, null]false

In time range with second precision

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

Input type:

java.lang.Comparable, java.lang.Comparable

Example inputs:

Input TypeInputResult
[java.lang.Long, java.lang.Long][1483234208000, 1483234209000]false
[java.lang.Long, java.lang.Long][1483234210000, 1483234210000]true
[java.lang.Long, java.lang.Long][1483234210000, 1483234220000]true
[java.lang.Long, java.lang.Long][1483234210000, 1483234250000]true
[java.lang.Long, java.lang.Long][1483234210000, 1483234251000]true
[ ,][null, null]false

In time range with timestamps

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

Input type:

java.lang.Comparable, java.lang.Comparable

Example inputs:

Input TypeInputResult
[java.lang.Long, java.lang.Long][1483315198, 1483315199]false
[java.lang.Long, java.lang.Long][1483315198, 1483315200]true
[java.lang.Long, java.lang.Long][1483315200, 1483315201]true
[java.lang.Long, java.lang.Long][1483316200, 1485907200]true
[java.lang.Long, java.lang.Long][1483316200, 1485907201]true
[ ,][null, null]false

In time range exclusive

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

Input type:

java.lang.Comparable, java.lang.Comparable

Example inputs:

Input TypeInputResult
[java.lang.Long, java.lang.Long][1451606400000, 1454284800000]false
[java.lang.Long, java.lang.Long][1483228800000, 1483228800000]false
[java.lang.Long, java.lang.Long][1483232400000, 1483232400000]true
[java.lang.Long, java.lang.Long][1483232400000, 1483315199000]true
[java.lang.Long, java.lang.Long][1483232400000, 1485907200000]true
[java.lang.Long, java.lang.Long][1483232400000, 1485907201000]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 InTimeRangeDual function = new InTimeRangeDual.Builder()
        .startOffset(-7L)
                // end is not set - it is unbounded
        .offsetUnit(TimeUnit.DAY)
        .build();
{
  "class" : "InTimeRangeDual",
  "startOffset" : -7,
  "offsetUnit" : "DAY"
}
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.range.InTimeRangeDual",
  "startOffset" : -7,
  "offsetUnit" : "DAY"
}
g.InTimeRangeDual( 
  start_offset=-7, 
  offset_unit="DAY" 
)

Input type:

java.lang.Comparable, java.lang.Comparable

Example inputs:

Input TypeInputResult
[java.lang.Long, java.lang.Long][1664707165111, 1664793565111]false
[java.lang.Long, java.lang.Long][1664966365111, 1664966365112]true
[java.lang.Long, java.lang.Long][1664966365111, 1665398365111]true
[java.lang.Long, java.lang.Long][1665484765101, 1665484765111]true
[ ,][null, null]false

Exactly 7 hours ago

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

Input type:

java.lang.Comparable, java.lang.Comparable

Example inputs:

Input TypeInputResult
[java.lang.Long, java.lang.Long][1665455965158, 1665459565148]false
[java.lang.Long, java.lang.Long][1665459575158, 1665459585158]true
[java.lang.Long, java.lang.Long][1665459575158, 1665463155158]true
[java.lang.Long, java.lang.Long][1665459575158, 1665463175158]true
[java.lang.Long, java.lang.Long][1665459575158, 1665484765158]true
[ ,][null, null]false

In date range with time unit microseconds

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

Input type:

java.lang.Comparable, java.lang.Comparable

Example inputs:

Input TypeInputResult
[java.lang.Long, java.lang.Long][1451606400000000, 1454284800000000]false
[java.lang.Long, java.lang.Long][1483228800000000, 1483228800000000]true
[java.lang.Long, java.lang.Long][1483232400000000, 1483232400000000]true
[java.lang.Long, java.lang.Long][1483232400000000, 1483315199000000]true
[java.lang.Long, java.lang.Long][1483232400000000, 1485907200000000]true
[java.lang.Long, java.lang.Long][1483232400000000, 1485907201000000]true
[ ,][null, null]false

Fully uncontained range

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

Input type:

java.lang.Comparable, java.lang.Comparable

Example inputs:

Input TypeInputResult
[java.lang.Long, java.lang.Long][1483228800000, 1485907200000]false
[java.lang.Long, java.lang.Long][1483228800000, 1491004800000]true
[java.lang.Long, java.lang.Long][1491004800000, 1493596800000]true
[java.lang.Long, java.lang.Long][1491004800000, 1504224000000]true
[java.lang.Long, java.lang.Long][1504224000000, 1506816000000]false
[ ,][null, null]false

Start contained range

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

Input type:

java.lang.Comparable, java.lang.Comparable

Example inputs:

Input TypeInputResult
[java.lang.Long, java.lang.Long][1483228800000, 1485907200000]false
[java.lang.Long, java.lang.Long][1483228800000, 1491004800000]false
[java.lang.Long, java.lang.Long][1491004800000, 1493596800000]true
[java.lang.Long, java.lang.Long][1491004800000, 1504224000000]true
[java.lang.Long, java.lang.Long][1504224000000, 1506816000000]false
[ ,][null, null]false

Fully contained range

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

Input type:

java.lang.Comparable, java.lang.Comparable

Example inputs:

Input TypeInputResult
[java.lang.Long, java.lang.Long][1483228800000, 1485907200000]false
[java.lang.Long, java.lang.Long][1483228800000, 1491004800000]false
[java.lang.Long, java.lang.Long][1491004800000, 1493596800000]true
[java.lang.Long, java.lang.Long][1491004800000, 1504224000000]false
[java.lang.Long, java.lang.Long][1504224000000, 1506816000000]false
[ ,][null, null]false

results matching ""

    No results matching ""