Issue in Offset Rounding in case Offset leads to change in the DST state

I am using ES version 7.11.

{
  "size": 0,
  "query": {
    "constant_score": {
      "filter": {
        "bool": {
          "must": [
            {
              "terms": {
                "deleted": [
                  "false"
                ]
              }
            }
          ]
        }
      }
    }
  },
  "aggregations": {
    "DEFAULT": {
      "filter": {
        "match_all": {}
      },
      "aggregations": {
        "DURATION_AGGREGATION": {
          "date_histogram": {
            "script": {
              "inline": "date-range-histo-script",
              "lang": "native",
              "params": {
                "post_offset": "-2d",
                "start_seed": 1640991600000,
                "tzLocation": "Europe/Madrid",
                "pre_offset": "2d",
                "timezone": "Europe/Madrid",
                "end_date_field": "endDate",
                "interval": "1w",
                "max_seed": 1648850399999,
                "start_date_field": "startDate"
              }
            },
            "interval": "1w",
            "min_doc_count": 1,
            "time_zone": "Europe/Madrid",
            "offset": "-172800000ms"
          }
        }
      }
    }
  }
}

My query is related to Offset rounding used in DateHistogramAggregator.class

org/Elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregator.class:165

 long rounded = DateHistogramAggregator.this.preparedRounding.round(value);

Suppose, value is 1648249200000 == > Friday, 25 March 2022 23:00:00 UTC

after rounding the value is 1648245600000 ==> Friday, 25 March 2022 22:00:00 UTC

Reason for above is DST correction has been applied but DST in "Europe/Madrid" starts at 27th March 2022 02:00:00.

public long round(long utcMillis) {
                    return delegatePrepared.round(utcMillis - OffsetRounding.this.offset) + OffsetRounding.this.offset;
                }

org/elasticsearch/common/Rounding.class:1051

This is happening because we are subtracting the offset which shifts the above value to Friday, 27 March 2022 23:00:00 UTC and then we are rounding it in which DST correction is also considered as the value has surpassed DST start time.

Isn't the above DST correction wrong?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.