Skip to main content

roundDateToESInterval

@elastic/chartsExports


@elastic/charts / roundDateToESInterval

Function: roundDateToESInterval()

roundDateToESInterval(date, interval, snapTo, timeZone): UnixTimestamp

Round a Date or unix timestamp to the beginning or end of the corresponding Elasticsearch date histogram bucket. It uses the date histogram aggregation Elasticsearch formula to compute the fixed interval bucket, and it uses an internal selected date/time library to compute the calendar one.

Parameters

date: number | Date

a unix timestamp or a Date object

interval: ESCalendarInterval | ESFixedInterval

the description of the Elasticsearch interval you want to round to

snapTo: "start" | "end"

if you want to snap the date at the start or at the end of the interval

timeZone: string

a IANA timezone

Returns

UnixTimestamp

Source

packages/charts/src/utils/chrono/elasticsearch.ts:96


Generated using typedoc-plugin-markdown and TypeDoc