Expand description
DateTime abstraction for unified time handling DateTime abstraction for unified time handling.
This module provides a unified API for datetime operations in the SQL backends,
abstracting over the differences between the chrono and time crates.
§Feature Flags
The datetime implementation is selected based on enabled features:
timefeature enabled: Usestime::OffsetDateTimeas the underlying type. This takes precedence even ifchronois also enabled.chronofeature enabled (withouttime): Useschrono::DateTime<Utc>.
§Why This Abstraction?
Different SQL database drivers have varying levels of support for datetime crates.
Some work better with chrono, others with time. This module allows users to
choose the datetime crate that best fits their database driver and application
needs, while the rest of the codebase uses a consistent API through the
DateTimeExt trait.
§Usage
use apalis_sql::{DateTime, DateTimeExt};
// Get current time (works with either feature)
let now = DateTime::now();
// Convert to Unix timestamp
let timestamp = now.to_unix_timestamp();
// Create from Unix timestamp
let dt = DateTime::from_unix_timestamp(timestamp);Traits§
- Date
Time Ext - Extension trait for SQL datetime operations.
Type Aliases§
- Date
Time - DateTime type alias that uses either chrono or time depending on enabled features.