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( 
  end="2017/02/01", 
  start="2017/01/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( 
  end="1485907200", 
  start="1483315200" 
)

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( 
  end_inclusive=False, 
  start_inclusive=False, 
  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]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( 
  offset_unit="DAY", 
  start_offset=-7 
)

Input type:

java.lang.Comparable, java.lang.Comparable

Example inputs:

Input TypeInputResult
[java.lang.Long, java.lang.Long][1537868000067, 1537954400067]false
[java.lang.Long, java.lang.Long][1538127200067, 1538127200068]true
[java.lang.Long, java.lang.Long][1538127200067, 1538559200067]true
[java.lang.Long, java.lang.Long][1538645600057, 1538645600067]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( 
  offset_unit="HOUR", 
  start_offset=-7, 
  end_inclusive=False, 
  end_offset=-6 
)

Input type:

java.lang.Comparable, java.lang.Comparable

Example inputs:

Input TypeInputResult
[java.lang.Long, java.lang.Long][1538616800178, 1538620400168]false
[java.lang.Long, java.lang.Long][1538620410178, 1538620420178]true
[java.lang.Long, java.lang.Long][1538620410178, 1538623990178]true
[java.lang.Long, java.lang.Long][1538620410178, 1538624010178]true
[java.lang.Long, java.lang.Long][1538620410178, 1538645600178]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( 
  end="2017/08/01", 
  start="2017/03/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_fully_contained=True, 
  end="2017/08/01", 
  start="2017/03/01", 
  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( 
  end="2017/08/01", 
  end_fully_contained=True, 
  start="2017/03/01", 
  start_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 ""