Skip to content

A date that names its weekday is read, so "Tuesday, March 17, 2020" becomes 2020-03-17 instead of no value - #1439

Open
rudycelekli wants to merge 1 commit into
deeplethe:devfrom
rudycelekli:extract-weekday-date
Open

rudycelekli wants to merge 1 commit into
deeplethe:devfrom
rudycelekli:extract-weekday-date

Conversation

@rudycelekli

Copy link
Copy Markdown
Contributor

Why

written_date reads a month-name date only when it is exactly two or three words: month, day and year in either order, or month and year. Press releases, letters, court filings and email headers usually put the weekday first: "Tuesday, March 17, 2020", "Tue, 17 Mar 2020". That is four words, so the date is not read, although the weekday only restates the day. The same text without the weekday works.

So a date attribute or interval endpoint quoted with its weekday is dropped, and literal_object lets it through as a thing instead of a value.

What changes

If the first word is a weekday name (chrono's Weekday parser: full name or three-letter abbreviation, any case), it is set aside and the rest is read as before. The weekday then has to agree with the date it introduces: "Monday, March 17, 2020" (a Tuesday) is a contradiction and stays unread, as does a weekday in front of a month-only date ("Tuesday, March 2020").

How it was checked

  • A new test, a_date_that_names_its_weekday_is_read, covers "Tuesday, March 17, 2020", "Tue, 17 Mar 2020", "tuesday March 17th 2020", read_time("Monday, September 30, 2024"), a weekday that does not match, and a weekday before a month.
  • With the fix reverted the test fails: Tuesday, March 17, 2020 left: None right: Some(String("2020-03-17")).
  • cargo test -p utopia-extract --lib: 113 passed.
  • cargo fmt -p utopia-extract --check and cargo clippy -p utopia-extract --all-targets -- -D warnings pass.

Before review

  • Every commit is signed off (git commit -s)
  • cargo fmt --all --check, cargo clippy and cargo test pass for the touched crate

…ecomes 2020-03-17 instead of no value

Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
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.

1 participant