Skip to content

A written date followed by a clock time reads as its day, so "2020年3月17日 14:30" becomes 2020-03-17 instead of no value - #1437

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

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

Conversation

@rudycelekli

Copy link
Copy Markdown
Contributor

Why

parse_time already has a rule for a clock time without a zone: "2020-03-17 14:30" is not an instant (whose 14:30?), so it keeps the date half and reads the day. written_date, the reader for dates not written in rule-3 form, has no such rule. Notices, minutes and announcements usually state the meeting or deadline with its time: "2020年3月17日 14:30", "2020/03/17 14:30", "March 17, 2020 14:30". parse_time rejects these because the date half is not ISO, and written_date rejects them because of the trailing clock, so the value is not read at all, while the same text without the time reads fine.

So a date attribute or interval endpoint quoted with its time is dropped, and literal_object treats "2020年3月17日 14:30" as a thing instead of a value.

What changes

At the start of written_date, a trailing whitespace-separated clock time (H:MM or H:MM:SS, checked by chrono) is set aside and the rest is read as before, at its own precision. That is the same reading parse_time gives "2020-03-17 14:30". A token that is not a valid clock ("25:00") is left in place, so the text stays unread, and text that is not a date ("Opens at 14:30") is still not a date.

How it was checked

  • A new test, a_written_date_followed_by_a_clock_time_reads_as_its_day, covers the Chinese, slashed and month-name forms with H:MM and H:MM:SS, read_time on "2020年3月17日 14:30", and the two cases that stay unread.
  • With the fix reverted the test fails: 2020年3月17日 14:30 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

…17日 14:30" becomes 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