title: passing and comparing datetime values with different timezones in elastic search and nest
body: <p>I am trying to pass a datetime value as an argument (timezone incognizant value which is in timezone 'UTC') in a query that compares the argument to a datetime value (timezone congnizant value which is in timezone '-05:00') inside an elastic search doc and returns documents.</p>
  
  <p>Questions:
  <br>
  1. Am I doing it correctly in my code below? 
  <br>
      2. Is ES going to handle the complexity of different timezone of the datetime argument before comparing it to the document datetime values ?
  <br>
      3. Is ES going to return the documents with the original datetime timezone values ?
  <br>
      4. Any documentation unraveling the internals of elastic search instance timezone handling ?
  <br>
  <br>
  The below code returns values, but I am unsure if it is achieving the desired objective.
  <br>
  Followed this <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html" rel="nofollow noreferrer">link</a> but it is limited to some basics
  <br>
      Thanks in advance.</p>
  
  <p>ES source document:</p>
  
  <pre><code>{
    "took" : 12,
    "timed_out" : false,
    "_shards" : {
      "total" : 5,
      "successful" : 5,
      "skipped" : 0,
      "failed" : 0
    },
  
    "hits" : {
      "total" : 2700881,
      "max_score" : 1.0,
      "hits" : [
        {
          "_index" : "test_index",
          "_type" : "doc",
          "_id" : "R22224!!5333e7e4-9ee3-45f4-9dc3-2a8b8d8cdcf8",
          "_score" : 1.0,
          "_source" : {
            "duration" : 14986283,
            "group_id" : "com",
            "var_time" : "2018-04-24T17:05:13.082-05:00",
            "var_name" : "2",
          }
        }
      ]
    }
  }
  </code></pre>
  
  <p><br></p>
  
  <pre><code>public class RawDocument
  {
  
      [PropertyName("duration")]
      public long Duration { get; set; }
  
      [PropertyName("group_id")]
      public string GroupId { get; set; }
  
      [PropertyName("var_time")]
      public DateTime Vartime { get; set; }
  
      [PropertyName("var_name")]
      public string Varname { get; set; }
  
  }
  </code></pre>
  
  <p><br></p>
  
  <pre><code>static void Main(string[] args)
  {
  
      var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
  
      var settings = new ConnectionSettings(pool)
          .DefaultMappingFor&lt;RawDocument&gt;(m =&gt; m
                .IndexName(test_index)
                .TypeName("doc"));
  
      var client = new ElasticClient(settings);
  
      //argument being passed into the query is maxExtractionTime datetime values. maxExtractionTime is in UTC
      //maxExtractionTime is being compared to var_time datetime with timezone values
      DateTime maxExtractionTime;
      maxExtractionTime = DateTime oDate = DateTime.ParseExact("2019-02-08 16:10:40.000", "yyyy-MM-dd HH:mm.fff", System.Globalization.CultureInfo.InvariantCulture);
  
      var searchResponse = client.Search&lt;RawDocument&gt;(s =&gt; s
                  .Size(5000)
                  .Scroll("2m")
                  .Query(q =&gt; q.DateRange(m =&gt; m.Field("var_time").GreaterThanOrEquals(maxExtractionTime.ToString("yyyy-MM-dd HH:mm:ss.fff")).TimeZone("+00:00")))                
                  );
  
  
      while (searchResponse.Documents.Any())
          {
  
              foreach (var document in searchResponse.Hits)
              {
              //do some business logic on the values
              MessageBox.Show("document.Source.Duration", document.Source.Duration);
              MessageBox.Show("document.Source.Vartime", document.Source.Vartime);
  
              }
              searchResponse = client.Scroll&lt;RawDocument&gt;("2m", searchResponse.ScrollId);
          }   
  
      var clearScrollResponse = client.ClearScroll(c =&gt; c.ScrollId(searchResponse.ScrollId));         
  }
  </code></pre>