eclipse-ditto / ditto

Eclipse Ditto™: Digital Twin framework of Eclipse IoT - main repository
https://eclipse.dev/ditto/
Eclipse Public License 2.0
691 stars 225 forks source link

Provide time placeholders in RQL with ability to specify plus and minus "duration" #1854

Closed thjaeckle closed 10 months ago

thjaeckle commented 10 months ago

Currently, there is the time:now placeholder which can be used in RQL queries, e.g. like this:

ge(features/ConnectionStatus/properties/status/readyUntil,time:now)

The currently implemented time placeholders are:

It would be very useful to be able to also specify a plus and minus offset to "now":

Syntax idea: To keep it simple, the existing placeholders could support optionally the following syntax:

<sign> := + | -

<unit> := "ms" | "s" | "m" | "h" | "d"
<dittoDuration> := <integer><unit>

<offset> := <sign><dittoDuration>

time:now<offset>
time:now_epoch_millis<offset>

Where Ditto duration is defined by implementation class DittoDuration.

Examples:

thjaeckle commented 10 months ago

Additional idea: Rounding up/down to the next full "ms" | "s" | "m" | "h" | "d".

Syntax could be e.g.:

time:now_round-d       # rounding down to today's start of the day
time:now-1d_round-d    # rounding down to yesterday's start of the day
time:now-1d_round-h    # rounding down to yesterday's start of the current hour

time:now_round+m       # rounding up the current time to the next full minute

Or:

time:now_floor_d       # rounding down to today's start of the day
time:now-1d_floor_d    # rounding down to yesterday's start of the day
time:now-1d_floor_h    # rounding down to yesterday's start of the current hour

time:now_ceil_m        # rounding up the current time to the next full minute

Or:

time:now[-d]       # rounding down to today's start of the day
time:now-1d[-d]    # rounding down to yesterday's start of the day
time:now-1d[-h]    # rounding down to yesterday's start of the current hour

time:now[+m]       # rounding up the current time to the next full minute