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§
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