title: Idiomatic way to check if a chrono::DateTime<Utc> is within date and time range?
body: <p>I am curious if there is an idiomatic way to check if a <code>chrono::DateTime&lt;Utc&gt;</code> is within a time range. In my use case I just need to check if the <code>DateTime</code> falls within the next half hour, from current time.</p>
  <p>This is what I put together so far. Its using <code>timestamp()</code> attribute to get a raw (unix) timestamp I can work with.</p>
  <pre class="lang-rust prettyprint-override"><code>use chrono::prelude::*;
  use chrono::Duration;
  
  #[inline(always)]
  pub fn in_next_half_hour(input_dt: DateTime&lt;Utc&gt;) -&gt; bool {
      in_future_range(input_dt, 30 * 60)
  }
  
  /// Check if a `DateTime` occurs within the following X seconds from now.
  pub fn in_future_range(input_dt: DateTime&lt;Utc&gt;, range_seconds: i64) -&gt; bool {
      let utc_now_ts = Utc::now().timestamp();
      let input_ts = input_dt.timestamp();
  
      let within_range = input_ts &gt; utc_now_ts &amp;&amp; input_ts &lt;= utc_now_ts + range_seconds;
  
      within_range
  }
  </code></pre>
  <p>My test cases are something like this:</p>
  <pre><code>fn main() {
      let utc_now = Utc::now();
  
      let input_dt = utc_now - Duration::minutes(15);
      assert_eq!(false, in_next_half_hour(input_dt));
  
      let input_dt = utc_now + Duration::minutes(15);
      assert_eq!(true, in_next_half_hour(input_dt));
  
      let input_dt = utc_now + Duration::minutes(25);
      assert_eq!(true, in_next_half_hour(input_dt));
  
      let input_dt = utc_now + Duration::minutes(35);
      assert_eq!(false, in_next_half_hour(input_dt));
  
      let input_dt = utc_now - Duration::days(2);
      assert_eq!(false, in_next_half_hour(input_dt));
  
      let input_dt = utc_now + Duration::days(3);
      assert_eq!(false, in_next_half_hour(input_dt));
  }
  </code></pre>
  <p>I am curious if there is a more idiomatic approach to achieve the same result.</p>