Repository navigation
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
Conversation
…17日 14:30" becomes 2020-03-17 instead of no value Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
parse_timealready 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_timerejects these because the date half is not ISO, andwritten_daterejects 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_objecttreats "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:MMorH:MM:SS, checked by chrono) is set aside and the rest is read as before, at its own precision. That is the same readingparse_timegives "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_written_date_followed_by_a_clock_time_reads_as_its_day, covers the Chinese, slashed and month-name forms withH:MMandH:MM:SS,read_timeon "2020年3月17日 14:30", and the two cases that stay unread.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 --checkandcargo clippy -p utopia-extract --all-targets -- -D warningspass.Before review
git commit -s)cargo fmt --all --check,cargo clippyandcargo testpass for the touched crate