Commit Graph

58 Commits (cf246bb9d4d43fe5cdca4822205931b9e1859a80)

Author SHA1 Message Date
Rob Emery cf246bb9d4 DatesRole: Adding regex and failing tests for new proseque formats 2014-10-31 18:26:31 +02:00
Matt Miller ab20f6c8e0 DatesRole: add "this" week|month|year.
At this point,all of them are essentially aliases for "today", but the
logic is kept separate in case we want to move them to start of period
or similar.

Minor update on Chinese Zodiac to demonstrate it working through the
role instead of local triggering.
2014-10-31 18:26:31 +02:00
Matt Miller ffd257aa09 DatesRole: fix and expand relative dates.
- Add grouping to regex for proper |ing.
- Add 'year' to relative dates.  (See Chinese zodiac)
- Add more tests.
2014-10-31 18:26:31 +02:00
Rob Emery 98ef4b7899 DatesRole: Adding regex and failing tests for relative day parsig 2014-10-31 18:25:59 +02:00
Matt Miller 5b35a56dc5 ImageLoader: use more standard methods to get at package symbols.
This may allwo for some code-sharing later.
2014-10-29 12:48:33 +02:00
Matt Miller 15f905a61d ImageLoader: expand silly symbol table tricks for `html_enc`
This way we can get proper quoting in the tag attributes,instead ofmy
silly incorrect version.
2014-10-29 12:48:33 +02:00
Matt Miller c8eac15915 ImageLoader: add role to use images from share.
- Load images from the share as safely as possible.
- Craft <img> tag with data url as source, plus additional supplied
  attributes.
2014-10-29 12:48:33 +02:00
Matt Miller da70710f7d EOL: remove trailing whitespace. 2014-10-28 20:36:15 +02:00
Matt Miller 17fc1447c9 DatesRole: add RFC2822 support. 2014-09-07 18:36:48 -04:00
Matt Miller 97f737e0be DatesRole: support standard output of date(1).
- Convert to ISO-8601 for the parse.
- Support short month to number in service of above.
- Support TZ to UTC offset in service of above.

In cases where the TZ abbreviation was ambiguous I selected what I
deemed to be the most populous or most likely to be a DDG user's intent.
I may, of course, be wrong.

Fixes #621.
2014-09-07 17:42:03 -04:00
Matt Miller 73ccf7282e DatesRole: complete deprecation cycle.
- Deprecate 'parse_all_strings_to_date()' in favor of
  'parse_all_datestrings_to_date()' for consistency.
- Remove the deprecated functions.
- Update all calls.
2014-08-31 19:21:55 -04:00
Matt Miller 4af3339501 00-roles.t: Update test output message. 2014-08-31 16:36:40 -04:00
Rob Emery ab0fdb6b04 DatesRole: Switching tests to use new parse_datestring_to_date 2014-08-31 19:42:45 +01:00
Rob Emery ce0880b158 DatesRole: renaming and deprecating parse_string_to_date 2014-08-31 19:39:37 +01:00
Rob Emery 5701ac4322 DatesRole: Added failing tests to layout desired behaviour of parse_string_to_date 2014-08-31 19:31:39 +01:00
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