Matt Miller
b4565b12b6
DatesRole: introduce date_output_string.
...
Takes a DateTime or a string we can turn into one and gives a
standardized output string for it. I'm not convinced this is entirely
the right way to do this.. or that it's named exactly correctly, but
it's probably better than specifying formats everywhere.
2014-08-11 22:05:56 -04:00
Matt Miller
e61e4cdb1e
DatesRole: use named captures in single date version, as well.
...
I don't know how much benefit this brings, but it unifies the
implementation somewhat in case of later changes.
2014-08-11 20:40:37 -04:00
Matt Miller
0557ebdb74
DatesRole: clarify how we determine the flip.
...
I think this is vaguely easier to read (and it may return a bit earlier,
if that's important which it is probably not). I may, of course, be
wrong.
Add named captures for the ambiguous formats to make it easier to know
what we "expect" the order to be unless it is flipped.
Also includes some minor formatting changes, due to my incessant use of
`perltidy`, and some test case arrangement changes to satisfy my desire
for order.
2014-08-11 20:26:05 -04:00
Matt Miller
683d89d7fc
00-roles.t: more testing output improvements.
...
- Properly note the role is applied to a class not an object.
- Add a few more cases for invalid multi-format date parsing.
- Do more subtext separation as this suite is growing quite large.
2014-08-11 19:39:19 -04:00
Matt Miller
b1a564e5e8
00-roles.t: increased verbosity of test output.
...
This should make it easier to look at the testing output and know where
things went awry, when and if they do.
2014-08-11 18:26:15 -04:00
Rob Emery
801dbf022d
DaysBetween: Layout fixes
2014-08-11 23:10:16 +01:00
Rob Emery
1daf678973
DaysBetween: Switching to new parse_all_strings_to_date
2014-08-11 23:08:05 +01:00
Rob Emery
4a25a8d697
WorkdaysBetween: Switching output format for consistency
2014-08-11 23:03:32 +01:00
Rob Emery
6b4b09399b
DatesRole & DateMath: switching to use DateRole
2014-08-11 22:58:28 +01:00
Rob Emery
afed344b1a
DatesRole & WorkdaysBetween: Switching to use DatesRole
2014-08-11 22:29:43 +01:00
Rob Emery
e38cd256b3
DatesRole: Adding test coverage for a mixture of formats
2014-08-11 22:19:02 +01:00
Rob Emery
b16ef96159
DatesRole: Tidying up tests a little
2014-08-11 22:06:07 +01:00
Rob Emery
57eca91a30
DateRole: Adding parse_all_strings_to_date; which will treat all ambiguous dates the same
2014-08-11 21:56:09 +01:00
Rob Emery
dca5c09d9c
WeekdaysBetween: Minor bit of tidying up
2014-08-10 22:31:54 +01:00
Rob Emery
634431f036
Merge branch 'mintsoft/date_role' of github.com:duckduckgo/zeroclickinfo-goodies into mintsoft/date_role
2014-08-10 22:26:57 +01:00
Rob Emery
030a2f6ec4
WeekdaysBetween: Converting to use DatesRole
2014-08-10 22:26:27 +01:00
Matt Miller
a9ed413e29
DaysBetween.t: demonstrate expanded date triggers.
...
Now that it's using the role, there are more options for how to enter
the dates between. Including using erratic mixed formats!
2014-08-10 17:14:25 -04:00
Rob Emery
9acd9819b2
DaysBetween: Cleanup as suggested by @mwmiller
2014-08-10 22:13:53 +01:00
Rob Emery
67d698ee51
Merge branch 'mintsoft/date_role' of github.com:duckduckgo/zeroclickinfo-goodies into mintsoft/date_role
2014-08-10 22:09:28 +01:00
Rob Emery
5cc924278f
DatesRole: Adding support and tests for: jan 6, 2014; 6, jan 2014; 6 jan, 2014
2014-08-10 22:08:44 +01:00
Matt Miller
365962e301
00-roles.t: make tests more deterministic.
...
We'd like to fail in the same place every time if we're going to fail,
so pick a consistent order for pulling out hash keys.
2014-08-10 16:53:24 -04:00
Rob Emery
0b3696a03c
Merge branch 'mintsoft/date_role' of github.com:duckduckgo/zeroclickinfo-goodies into mintsoft/date_role
2014-08-10 21:50:32 +01:00
Matt Miller
627cb50a33
DatesRole: improve testing on regex/parse mismatch.
...
Some added tests for places where the string passes the regex "maybe it
looks like a date" test, but is not, in fact able to be parsed by the
engine.
Plus, a bit more diagnostic info output for provers.
2014-08-10 16:49:26 -04:00
Rob Emery
e963ff0b1b
DaysBetween: Minor tidyup
2014-08-10 21:49:22 +01:00
Rob Emery
40e760fd2e
DatesRole/DaysBetween: Switching to use the new DatesRole
2014-08-10 21:45:19 +01:00
Rob Emery
185a99548f
DatesRole: Needs to be able to match in mid-line when embedded within someone else's regex
2014-08-10 21:26:54 +01:00
Rob Emery
f620117e78
DatesRole: Removing test using
2014-08-10 20:30:21 +01:00
Rob Emery
95e62a2c42
DatesRole: Adding test for submatches within the regex
2014-08-10 20:28:36 +01:00
Rob Emery
6562ddec4f
DatesRoles: More capturing groups
2014-08-10 20:23:12 +01:00
Rob Emery
73cdd668d1
GoodieRole: Switching all captures to non-capturing
2014-08-10 20:06:05 +01:00
Rob Emery
1ce7f089d5
Merge branch 'mintsoft/date_role' of github.com:duckduckgo/zeroclickinfo-goodies into mintsoft/date_role
2014-08-10 20:03:06 +01:00
Matt Miller
280a5c404d
DatesRole: be more resilient in the face of adversity.
...
- Settle on `undef` as a signal for failure.
- Maintain regex in a `state` variable.
- Return undef if it doesn't match our regex.
- Don't die if its still unparseable.
Also, add Test::Most and Try::Tiny to `dist.ini` just to give
@jagtalon something to do this week. :D
2014-08-10 14:52:59 -04:00
Matt Miller
56d75336b6
Uppercase: switch triggers to "start"-only.
...
Since these act like a command, it makes sense to have it at the start
only. This is also in line with the triggers for the very similar
lowercase IA.
Attempt to address issue #578 .
2014-08-10 14:23:48 -04:00
Rob Emery
18fe932b7d
AltCalendars: moving hash out of the sub
2014-08-10 19:05:53 +01:00
Matt Miller
577cc763de
DatesRole: expand allowing single-digit day numbers.
...
Also, fix-up weird-cased short months.
2014-08-10 11:08:22 -04:00
Matt Miller
7fdb44dd5e
dist.ini: version syntax fix.
2014-08-10 10:43:18 -04:00
Rob Emery
f883a17f2e
DatesRole: Adding test for feb/01/2010 style
2014-08-10 15:34:49 +01:00
Rob Emery
8123384efa
DatesRole: Adding support for Feb-01-2010 format
2014-08-10 15:32:47 +01:00
Matt Miller
27aa2b6d5b
DatesRole: settle on a standard set of date delimiters.
...
These don't necessarily make sense in all combinations, but they should
cover the vast majority of human-entered formats in the wild, somehow.
2014-08-10 09:33:03 -04:00
Matt Miller
df28204b42
DatesRole: reorganize parsing slightly.
...
This reorganizes and clarifies some things to make adding extra
cases in later easier (hopefully).
2014-08-10 08:58:07 -04:00
Rob Emery
5d790228c8
DatesRole: Adding more mangled formats
2014-08-10 11:04:30 +01:00
Rob Emery
7b9b774e07
DatesRole: Adding support for 13/7/2010 style
2014-08-10 10:55:45 +01:00
Rob Emery
a57c690ba4
DatesRole: Adding logic to the parse for ambiguous date formats with unambiguous values
2014-08-10 10:50:28 +01:00
Matt Miller
4d62528abf
DatesRole: pre-parse for common natural formats.
...
- Switch long month names to short.
- Strip oridinal text from days.
- Allow American ordinals, as well.
2014-08-09 20:14:59 -04:00
Matt Miller
aae3de5cf4
00-roles: more parse_string_to_date testing.
...
- Make sure we get an object.
- Make sure that object represents the moment in time of interest.
2014-08-09 19:12:31 -04:00
Rob Emery
cd28907ecd
GoodieRole: Fixing parse
2014-08-09 23:27:55 +01:00
Rob Emery
deea1c8016
DatesRole: minor cleanup
2014-08-09 22:59:35 +01:00
Rob Emery
95d9ddfbc5
DateRole: Making matches full-line and adding timezones where required
2014-08-09 22:50:12 +01:00
Rob Emery
4009403969
DateRole: Adding support for "1st June 2015"
2014-08-09 22:30:01 +01:00
Rob Emery
53a58afec6
DatesRole: Adding DateTime::Format::HTTP to dist.ini
2014-08-09 22:16:46 +01:00