Skip to content

Commit

Permalink
Restore forward-bias for timespan parsing
Browse files Browse the repository at this point in the history
This broke as a result of updating the Chrono version in e1b7b1b.
It’s too bad because it wasn’t a major version change! Other
parsing bugs remain but it addresses this one:
#68 (comment)
  • Loading branch information
backspace committed Oct 13, 2019
1 parent ec56813 commit 78db1c1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/utils/parse-timespan.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ chronoInstance.refiners.push(assumePM);

export default function parseTimespan(value) {
const [parsed] = chronoInstance.parse(value, new Date(), {
forwardDatesOnly: true,
forwardDate: true,
});
return parsed;
}
19 changes: 19 additions & 0 deletions tests/unit/utils/parse-timespan-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,23 @@ module('Unit | Utility | parse timespan', function(hooks) {
);
assert.notOk(parsed.end);
});

test('it assumes future dates unless fully specified', function(assert) {
window.chronokinesis.travel(new Date(1570925744254));
// Saturday 2019-10-12 19:15

assertParsing(
assert,
'thursday from 7 to 9',
'2019-10-17 19:00',
'2019-10-17 21:00'
);

assertParsing(
assert,
'oct 10 2019 from 1 to 4',
'2019-10-10 13:00',
'2019-10-10 16:00'
);
});
});

0 comments on commit 78db1c1

Please sign in to comment.