Skip to content

Commit

Permalink
support o'clock - fixes #12 (second half)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvinwan committed Jan 17, 2025
1 parent eb9a2dc commit 3ee0833
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions tests/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_default(now, test_input, expected):
@pytest.mark.parametrize("test_input, expected", [
# time only
('5p', datetime.time(hour=17, minute=0)),
# ("3 o'clock", datetime.time(hour=3, minute=0)),
("3 o'clock pm", datetime.time(hour=15, minute=0)), # fixes gh#12
# date only
('July 2019', datetime.date(2019, 7, 1)),
Expand Down Expand Up @@ -112,7 +112,6 @@ def test_default(now, test_input, expected):
('30-40 mins', (datetime.timedelta(minutes=30), datetime.timedelta(minutes=40))),
('1 or 2 days', [datetime.timedelta(days=1), datetime.timedelta(days=2)]),
# TODO: support "3 o'clock"
# TODO: support "quarter to 3"
# TODO: support "one and a half hours"
Expand Down
2 changes: 1 addition & 1 deletion timefhuman/grammar.lark
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ date: month "/" day "/" year
// However, that means to support single-integer (e.g., hour) times, we need
// to manually add them to the `datetime` rule above.
time: hour ":" minute meridiem?
| hour meridiem
| hour ("o'clock")? meridiem
| timename

duration: ("in"|"for")? duration_part (("and"|",")? duration_part)* ("ago")?
Expand Down

0 comments on commit 3ee0833

Please sign in to comment.