Skip to content

Conversation

@jjcfrancisco
Copy link
Contributor

@jjcfrancisco jjcfrancisco commented Dec 21, 2025

Description

Adds support for abbreviated datetime formats (year, year-month, date) via a new Search::normalize_datetimes() method. This allows users to opt-in to expanding partial dates to full RFC 3339 datetime ranges - follows similar functionality to pystac.

Key changes:

  • Implemented expand_datetime_to_start() and expand_datetime_to_end() helper functions to convert abbreviated dates to full datetime ranges
  • Added Search::normalize_datetimes() method for opt-in datetime normalization
  • Added two new error variants: InvalidYear and UnrecognizedDateFormat for better error handling
  • Comprehensive documentation and test coverage

Sidecar changes:
Bumped assert_cmd from 2.0 to 2.1 in workspace dependencies. The locked version (2.0.14) was missing the cargo_bin_cmd!() macro (see docs), causing compilation failures in test code that relied on it

Related issues

Checklist

  • Unit tests
  • Documentation, including doctests
  • Pull request title follows conventional commits
  • Pre-commit hooks pass (prek run --all-files)

@jjcfrancisco jjcfrancisco marked this pull request as draft December 21, 2025 16:41
Copy link
Member

@gadomski gadomski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! This will be a really helpful addition.

As demonstrated by the tests, I don't think we should add this functionality to Items::valid, since that's used in our servers as well, which need to be strict about datetime format. I think we want this only for search, so probably on stac::api::Search. Maybe something like:

impl Search {
    pub fn normalize_datetimes(mut self) -> Result<Search> {
        todo!();
    }
}

@jjcfrancisco jjcfrancisco marked this pull request as ready for review December 29, 2025 07:47
@jjcfrancisco
Copy link
Contributor Author

Thanks for this! This will be a really helpful addition.

As demonstrated by the tests, I don't think we should add this functionality to Items::valid, since that's used in our servers as well, which need to be strict about datetime format. I think we want this only for search, so probably on stac::api::Search. Maybe something like:

impl Search {
    pub fn normalize_datetimes(mut self) -> Result<Search> {
        todo!();
    }
}

I realised my approach had an issue after the CI ran, hopefully this fixes it. I've moved the datetime expansion to Search::normalize_datetimes() as you suggested and reverted items.rs to original. Let me know if you'd like any adjustments!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Searching by datetime doesn't work when specifying simple dates like 2023 or 2023-01-01/2023-12-31

2 participants