Rob Emery
03632703fb
DatesRole: Switching invalid string tests from parse_string_to_date to parse_formatted_datestring_to_date
2014-08-31 19:15:46 +01:00
Rob Emery
fbc38176b3
DatesRole: Adding tests for the formatted_datestring_regex and switching existing tests to use it versus the date_regex()
2014-08-31 19:08:50 +01:00
Rob Emery
35137b382c
DatesRole: Adding tests for new datestring_regex methods and renaming existing regex
2014-08-31 19:04:43 +01:00
Rob Emery
2f1f6e1b85
DatesRole: Adding support for "jan 1st" "13 march" to vague
2014-08-30 20:48:45 +01:00
Matt Miller
9b45531bfb
00-roles.t: use MockTime for relative time testing.
...
In order to maintain clean code for actual use, we're not doing time
injection here.
2014-08-15 08:37:05 -04:00
Matt Miller
dcb3c69643
00-roles.t: show far out dates working.
...
Showing dates outside of the 32-bit UNIX epoch being properly parsed and
objectified.
Also, better test for year in the short month + year case.
2014-08-14 11:43:09 -04:00
Matt Miller
eecc0dc963
00-roles.t: show leap-year handling.
...
Unlike previous iterations which used Time::Piece, we will only actually
return objects for valid dates.. even if the day/month combination was
valid for some other year.
2014-08-14 11:07:46 -04:00
Matt Miller
f040e34f1e
00-roles.t: remove time-dependence in vague string tests.
...
Unfortunately, this also means that we don't currenyl know for sure that
it is picking the right direction. Hopefully, a stop-gap measure.
2014-08-14 10:43:11 -04:00
Matt Miller
13d9de46be
parse_vague_string_to_date: simplify named captures slightly.
...
In each case, we have a month match, so name them all the same.
Then, figure out how each different part of the specific match effects
the resultant date calculation.
2014-08-14 09:52:18 -04:00
Rob Emery
5e119d6869
DatesRole: Implementing and hacking in tests for Vague Strings (these *need* to be updated to more datadriven as they depend on the current clock)
2014-08-13 13:18:40 +01:00
Rob Emery
53705d1ad5
DatesRole: Fleshing out "next month" and "last month"; tests need actually writing and implementation needs checking
2014-08-13 00:12:58 +01:00
Rob Emery
702451fade
DatesRole: Adding parse_vague_string_to_date; needs fleshing out
2014-08-12 23:59:57 +01:00
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
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
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
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
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
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
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
577cc763de
DatesRole: expand allowing single-digit day numbers.
...
Also, fix-up weird-cased short months.
2014-08-10 11:08:22 -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
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
2330a9c9d6
DatesRole: Fixing tests and regexes for 01 June 2014 format
2014-08-09 22:16:20 +01:00
Rob Emery
6babd30249
DatesRole: New centralised role for matching and parsing dates
2014-08-09 19:36:46 +01:00
Matt Miller
a9548a2c31
00-roles.t: switch Test::Most to Test::More.
...
Test::More is guaranteed to be installed everywhere already.. and we
don't need anything extra from Test::Most, so just switch it back.
2014-08-07 11:29:50 -04:00
Matt Miller
9e14be1a87
NumberStyler: add testing.
...
This is a port of the previous tests for these functions, updated for
its new status as a role. I can be convinced that this is not the best
way to do this, but it seems well-enough to me.
2014-08-06 21:14:33 -04:00