Skip to content
Permalink
Browse files

Update rules to allow more variation for MonthDDDD intervals. (#271)

Summary:
Fixes [#218](#218)

**Note:** This is still a work in progress. But, I'm new to both Haskell and this repo and I seem to be stuck. Would appreciate feedback on what I've done so far. Thank you!
Pull Request resolved: #271

Reviewed By: chinmay87

Differential Revision: D13087476

Pulled By: patapizza

fbshipit-source-id: 2dee0d023794265bd791ae0bbc0e2e2b89ea1959
  • Loading branch information...
MorrisLaw authored and facebook-github-bot committed Nov 17, 2018
1 parent 39a6a4c commit 4bee26851e60c17cf4909bc252ab7c51fc59b105

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -955,9 +955,29 @@ allExamples = concat
, "July 13 thru 15"
, "July 13 through 15"
, "July 13 - July 15"
, "from July 13-15"
]
, examples (datetimeInterval ((2013, 7, 13, 0, 0, 0), (2013, 7, 16, 0, 0, 0)) Day)
[ "from July 13-15"
, "from 13 to 15 July"
, "from 13th to 15th July"
, "from the 13 to 15 July"
, "from the 13th to 15th July"
, "from the 13th to the 15th July"
, "from the 13 to the 15 July"
]
, examples (datetimeInterval ((2013, 7, 13, 0, 0, 0), (2013, 7, 16, 0, 0, 0)) Day)
[ "from 13 to 15 of July"
, "from 13th to 15 of July"
, "from 13 to 15th of July"
, "from 13th to 15th of July"
, "from 13 to the 15 of July"
, "from 13th to the 15 of July"
, "from 13 to the 15th of July"
, "from 13th to the 15th of July"
, "from the 13 to the 15 of July"
, "from the 13th to the 15 of July"
, "from the 13 to the 15th of July"
, "from the 13th to the 15th of July"
]
, examples (datetimeInterval ((2013, 8, 8, 0, 0, 0), (2013, 8, 13, 0, 0, 0)) Day)
[ "Aug 8 - Aug 12"
@@ -1097,19 +1097,44 @@ ruleIntervalFromMonthDDDD = Rule

ruleIntervalFromDDDDMonth :: Rule
ruleIntervalFromDDDDMonth = Rule
{ name = "from <day-of-month> (ordinal or number) to <day-of-month> (ordinal or number) <named-month> (interval)"
{ name = "from the <day-of-month> (ordinal or number) to the <day-of-month> (ordinal or number) <named-month> (interval)"
, pattern =
[ regex "from"
[ regex "from( the)?"
, Predicate isDOMValue
, regex "\\-|to|th?ru|through|(un)?til(l)?"
, regex "\\-|to( the)?|th?ru|through|(un)?til(l)?"
, Predicate isDOMValue
, Predicate isAMonth
]
, prod = \tokens -> case tokens of
(_:
token1:
_:
token2:
Token Time td:
_) -> do
dom1 <- intersectDOM td token1
dom2 <- intersectDOM td token2
Token Time <$> interval TTime.Closed dom1 dom2
_ -> Nothing
}

ruleIntervalFromDDDDOfMonth :: Rule
ruleIntervalFromDDDDOfMonth = Rule
{ name = "from the <day-of-month> (ordinal or number) to the <day-of-month> (ordinal or number) of <named-month> (interval)"
, pattern =
[ regex "from( the)?"
, Predicate isDOMValue
, regex "\\-|to( the)?|th?ru|through|(un)?til(l)?"
, Predicate isDOMValue
, regex "of"
, Predicate isAMonth
]
, prod = \tokens -> case tokens of
(_:
token1:
_:
token2:
_:
Token Time td:
_) -> do
dom1 <- intersectDOM td token1
@@ -2404,6 +2429,7 @@ rules =
, rulePrecisionTOD
, ruleIntervalFromMonthDDDD
, ruleIntervalFromDDDDMonth
, ruleIntervalFromDDDDOfMonth
, ruleIntervalMonthDDDD
, ruleIntervalDDDDMonth
, ruleIntervalDash

0 comments on commit 4bee268

Please sign in to comment.
You can’t perform that action at this time.