date_filter_search 0.1.0

A Rust library for parsing and filtering dates using relative and absolute time intervals. Useful for log filtering, search tools, and automation.
Documentation
  • Coverage
  • 0%
    0 out of 13 items documented0 out of 5 items with examples
  • Size
  • Source code size: 64.46 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 808.83 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 24s Average build duration of successful builds.
  • all releases: 28s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • IMprojtech/Date_Filter_Search
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • IMprojtech

date_filter_search

date_filter_search is a Rust library for filtering and searching dates, designed to be integrated into applications.
The library supports parsing both absolute and relative date formats:

  • Relative (time interval) – available keys: Y, M, D, h, m, s
    • Examples:
      • "10m": 10 minutes from now.
      • "2Y": 2 years from now.
      • "6M": 6 months from now.
  • Absolute (a specific date or a date range or part thereof) – allowed separators: /, -, _, , :, ;, ., ,
    • 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.

Main Features

  • Flexible Parsing:
    Supports both absolute and relative formats to specify date intervals.
  • Conversion and Calculation:
    Converts dates to seconds and allows arithmetic operations to calculate intervals and comparisons.
  • Error Handling:
    Provides a robust error handling system with clear messages through the DateError enum.
  • Ease of Integration:
    Designed for use in both graphical applications and command-line tools (for example, to filter logs or operation records).

Installation

Add the library to your Cargo.toml file:

[dependencies]
date_filter_search = "0.1.0"

Make sure to update the version according to the current release.

Usage

A practical example is available in the examples/ folder, demonstrating how to use date_filter_search in a command-line tool. To run the example:

cargo run --example demo -- 1Y

Replace 1Y with the query you wish to test (e.g., 2021to2023).

API Reference

Main Functions

parsing_search(input: &str) -> Result<(u64, u64), DateError>
Parses the input—interpreting it as an absolute or relative interval—and returns a pair of timestamps (start and end).

search_generic(target: u64, lower_bound: u64, upper_bound: u64) -> bool
Checks whether the target timestamp falls between lower_bound and upper_bound (inclusive).

string_to_date_seconds(input: &str) -> Result<u64, DateError>
Converts a string representing a date into the number of seconds since a defined epoch.

Error Handling

The library uses the DateError enum to represent various errors that can occur during parsing or date conversion. Common errors include:

EmptyInput: The provided input is empty.
InvalidDateFormat: The date format does not match the expected specification.
InvalidRegex: The regex used for parsing is invalid.
OutOfRange(String): The specified value is out of the allowed range.
ParsingError(String): Error during value parsing.
IncorrectUnit(String): The unit for relative dates is not recognized.

Contributing

Contributions are welcome! If you’d like to improve the library:

Fork the repository.
Implement your changes.
Open a pull request describing your proposed changes.

License

This project is distributed under the terms of the GNU General Public License (GPL), which guarantees the freedom to redistribute and modify the software in accordance with free software standards

Author

Written by Catoni Mirko (IMprojtech)

Contacts and Resources

GitHub Repository: https://github.com/IMprojtech/Date_Filter_Search
Issue Tracker: Use the GitHub repository to report issues or request new features.