Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed string
Browse files Browse the repository at this point in the history
alvinwan committed Jan 17, 2025
1 parent aac2458 commit eb9a2dc
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion tests/test_e2e.py
Original file line number Diff line number Diff line change
@@ -79,9 +79,11 @@ 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)),
# date only
('July 2019', datetime.date(2019, 7, 1)),
# ('Monday July 1, 2019', datetime.date(2019, 7, 1)),
# date-only ranges
('7/17-7/18', (datetime.date(2018, 7, 17), datetime.date(2018, 7, 18))),
@@ -132,7 +134,7 @@ def test_no_inference(now, test_input, expected):
# (tfhConfig(infer_datetimes=True), '1p', datetime.datetime(2018, 8, 5, 13, 0)), # TODO tomorrow, since passed today (gh#12)
# TODO: add tests for 'next/last'
])
])
def test_custom_config(now, config, test_input, expected):
config.now = now
assert timefhuman(test_input, config=config) == expected
5 changes: 3 additions & 2 deletions timefhuman/main.py
Original file line number Diff line number Diff line change
@@ -320,11 +320,12 @@ def timefhuman(string, config: tfhConfig = tfhConfig(), raw=None):

# TODO: add option to return with the original unknown tokens?
# helps the user understand which tokens were not matched
# TODO: better way to filter
# NOTE: intentionally did not filter by hasattr(result, 'to_object') to
# catch any other objects that might be returned
results = list(filter(
lambda s: isinstance(s, (datetime, date, time, timedelta)),
[result.to_object(config) for result in results]
lambda s: not isinstance(s, str),
[result.to_object(config) for result in results if not isinstance(result, str)]
))

if len(results) == 1:

0 comments on commit eb9a2dc

Please sign in to comment.