| Crates.io | date_filter_search |
| lib.rs | date_filter_search |
| version | 0.1.1 |
| created_at | 2025-04-06 15:55:43.562726+00 |
| updated_at | 2025-04-08 19:34:06.951648+00 |
| description | Date Filter Search is a Rust library that makes working with dates a breeze. It seamlessly converts dates to Unix seconds and Unix seconds back to dates, validates and completes partial date inputs, supports a configurable time zone (Local or UTC), and features robust parsing of both absolute and relative search strings for powerful date filtering. |
| homepage | |
| repository | https://github.com/IMprojtech/Date_Filter_Search |
| max_upload_size | |
| id | 1623014 |
| size | 487,733 |
date_filter_search is a Rust library that streamlines working with dates. It provides robust functionality for converting dates to Unix seconds and Unix seconds back into dates, validating and auto-completing incomplete date inputs, configuring the active time zone, and parsing both absolute and relative date search queries for powerful date filtering.
Y, M, D, h, m, s for time intervals.
Examples:
"10m": 10 minutes from now."2Y": 2 years from now."6M": 6 months from now./, -, _, space, :, ;, ., or ,.
Examples:
"2023-04-05 10:20:30": an exact date."2022-12": the entire month of December 2022."2021-3 to 2021-6": from March 2021 to June 2021.DateTime structures and Unix seconds.Add the following to your Cargo.toml file:
[dependencies]
date_filter_search = "0.1.1"
Be sure to update the version as necessary.
A practical example is available in the examples/ folder that demonstrates how to use date_filter_search in a command-line application.
To run the example:
cargo run --example demo -- 1Y
Replace 1Y with the search query you wish to test (e.g., 10m, 2021-3 to 2021-6, etc.).
Below is a screenshot of the terminal output from the demo:

parsing_search(input: &str) -> Result<(u64, u64), DateError> Parses the input as either an absolute or relative date search query and returns a tuple of Unix seconds representing the start and end of the interval.
search_generic(target: u64, lower_bound: u64, upper_bound: u64) -> bool Determines whether the target Unix seconds timestamp falls within the specified interval.
string_to_date_seconds(input: &str) -> Result<u64, DateError> Converts a date string into Unix seconds from the defined epoch.
date_to_seconds(dt: DateTime) -> u64 Converts a DateTime structure into Unix seconds.
seconds_to_date(seconds: u64) -> DateTime Converts Unix seconds back into a DateTime structure.
validate_datetime(input: &str, default: bool) -> Result<DateTime, DateError> Validates and auto-completes a date string, returning a complete DateTime structure.
The library uses a custom DateError enum for error handling.
Common error variants include:
Contributions are welcome! To contribute:
This project is distributed under the GNU General Public License (GPL), ensuring the freedom to modify and redistribute the software in accordance with free software standards.
Written by Catoni Mirko (IMprojtech)