release v1: 65 held-out tasks, 78 bootstrap records, r2e_local adapter, manifest ae94c40b (part 2)
559318d verified Download heldout/alvinwan__timefhuman-c0dec77bb5f7/solution/patch.diff from Benjamin-eecs/openrsi-commit-runtime-assets: direct link, hf CLI and curl.
- Browser
- Download file 1.69 kB
-
https://huggingface.co/datasets/Benjamin-eecs/openrsi-commit-runtime-assets/resolve/main/heldout/alvinwan__timefhuman-c0dec77bb5f7/solution/patch.diff
- Command line
-
hf download hf://datasets/Benjamin-eecs/openrsi-commit-runtime-assets/heldout/alvinwan__timefhuman-c0dec77bb5f7/solution/patch.diff
-
curl -L -o patch.diff https://huggingface.co/datasets/Benjamin-eecs/openrsi-commit-runtime-assets/resolve/main/heldout/alvinwan__timefhuman-c0dec77bb5f7/solution/patch.diff
1.69 kB
| diff --git a/timefhuman/main.py b/timefhuman/main.py | |
| index 448a4e2..58b7faa 100644 | |
| --- a/timefhuman/main.py | |
| +++ b/timefhuman/main.py | |
| -from datetime import timedelta | |
| -import datetime | |
| +from datetime import datetime, timedelta | |
| from pathlib import Path | |
| -from lark import Lark, Transformer, v_args, Token, Discard | |
| +from dataclasses import replace | |
| +from lark import Lark, Transformer, v_args | |
| import pytz | |
| from timefhuman.utils import generate_timezone_mapping, nodes_to_dict, nodes_to_multidict, get_month_mapping, tfhConfig, Direction, direction_to_offset | |
| from timefhuman.renderers import tfhDatetime, tfhDate, tfhTime, tfhRange, tfhList, tfhTimedelta, tfhAmbiguous, tfhUnknown, tfhDatelike, tfhMatchable | |
| def get_parser(): | |
| return parser | |
| -def timefhuman(string, config: tfhConfig = tfhConfig(), raw=None): | |
| +def timefhuman(string, config: tfhConfig = tfhConfig(), raw: bool=False, now: bool=False): | |
| parser = get_parser() | |
| tree = parser.parse(string) | |
| if raw: | |
| return tree | |
| + | |
| + config = replace(config, now=config.now or datetime.now()) | |
| + if now: | |
| + return config.now | |
| transformer = tfhTransformer(config=config) | |
| renderers = transformer.transform(tree) | |
| diff --git a/timefhuman/utils.py b/timefhuman/utils.py | |
| index 7f39218..c715513 100644 | |
| --- a/timefhuman/utils.py | |
| +++ b/timefhuman/utils.py | |
| class tfhConfig: | |
| infer_datetimes: bool = True | |
| # The 'current' datetime, used if infer_datetimes is True | |
| - now: datetime = datetime.now() | |
| + now: datetime | None = None | |
| # Return the matched text from the input string | |
| return_matched_text: bool = False | |