ncbi / datasets

NCBI Datasets is a new resource that lets you easily gather data from across NCBI databases.
https://www.ncbi.nlm.nih.gov/datasets
Other
355 stars 39 forks source link

Use ISO date formatting for date input #366

Closed ammaraziz closed 4 months ago

ammaraziz commented 4 months ago

Hi NCBI folks,

Thanks for the amazing datasets tool.

Describe the bug

datasets tool uses the American date notation for date input MM/DD/YYYY. This is unfortunately not standard in CLI tools and does not follow ISO format of YYYY/MM/DD.

To Reproduce

eg

datasets summary virus genome taxon --help
...
      --released-after string   Limit to genomes released on or after a specified date (MM/DD/YYYY)
      --updated-after string    Limit to genomes updated on or after a specified date (MM/DD/YYYY)

Suggested Solution:

Include addition flags that expect ISO format:

      --released-after string   Limit to genomes released on or after a specified date (YYYY/MM/DD)
      --updated-after string    Limit to genomes updated on or after a specified date (YYYY/MM/DD)

Or alternative include a date format flag:

    --date-format "%Y-%m-%d"

Thanks!

ericcox1 commented 4 months ago

Hi @ammaraziz,

Thanks for opening this issue.

We are using dateparse.ParseAny, which should be able to parse ISO format dates. Would you mind giving it a try and reporting what you see?

I'll make a note to update the flag description, which incorrectly implies that only the American date format is accepted.

Best, Eric

Eric Cox, PhD [Contractor] (he/him/his) NCBI Datasets NIH/NLM/NCBI eric.cox@nih.gov

ammaraziz commented 4 months ago

Thanks for the quick response Erin. Great to hear other formats are accepted.

Confirming that YYYY/MM/DD works.

How are ambiguous dates handled eg 01/03/2024? It seems that any date in this format XX/XX/YYYY is always parsed as MM/DD/YYYY. If so it would be worth nothing this alongside the different date input formats.

Updating the help would be a great.

Thanks again. Feel free to close this as complete :)

ericcox1 commented 4 months ago

It seems that any date in this format XX/XX/YYYY is always parsed as MM/DD/YYYY.

That is correct. We are using dateparse.ParseAny, and that is the expected behavior.

Best, Eric