Module datetime

Module datetime 

Source
Expand description

DateTime operations for query builder.

This module provides datetime comparison and manipulation operations that can be used with the query builder. It supports both std::time::SystemTime and optionally chrono types when the datetime feature is enabled.

§Features

  • Date comparisons (before, after, between)
  • Time range queries
  • Date arithmetic (add/subtract days, hours, etc.)
  • Date extraction (year, month, day, hour, etc.)
  • Timezone-aware operations (with chrono)

§Example

use rust_queries_core::{Query, datetime::*};
use chrono::{DateTime, Utc};

#[derive(Keypath)]
struct Event {
    name: String,
    timestamp: DateTime<Utc>,
}

let events = vec![/* ... */];
let recent = Query::new(&events)
    .where_(Event::timestamp(), |ts| {
        is_after(ts, &Utc::now() - chrono::Duration::days(7))
    });

Re-exports§

pub use chrono;

Modules§

chrono_ops

Functions§

add_duration_systemtime
Add duration to SystemTime
is_after_systemtime
Check if a SystemTime is after another SystemTime
is_before_systemtime
Check if a SystemTime is before another SystemTime
is_between_systemtime
Check if a SystemTime is between two SystemTimes (inclusive)
is_within_duration_systemtime
Check if a SystemTime is within a duration from now
subtract_duration_systemtime
Subtract duration from SystemTime