Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Parser/Plugins/ArithmeticTimePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ArithmeticTimePlugin : IParseTimeStrings, IApplyTimeTokens
** Properties
*********/
/// <summary>The regular expression that matches the date tokens in the input expression.</summary>
protected readonly Regex ParsePattern = new Regex(@"^(?<expression>\s*((?<sign>[\+\-]{0,1})\s*(?<value>\d*))?\s*\b(?<unit>\w+)\b(?<negate>(\s*\bago\b)?)\s*)+", RegexOptions.Compiled | RegexOptions.ExplicitCapture);
protected readonly Regex ParsePattern = new Regex(@"^(?<expression>\s*((?<sign>[\+\-and]{0,3})\s*(?<value>\d*))?\s*\b(?<unit>\w+)\b(?<negate>(\s*\bago\b)?)\s*)+", RegexOptions.Compiled | RegexOptions.ExplicitCapture);


/*********
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ You can also chain relative units:
* `1 year 2 months` (14 months from now)
* `1 year -2 fortnights` (almost 11 months from now)
* `1 year ago 1 year` (today; equivalent to `-1 year +1 year`)
* `1 year ago and 5 days ago` (5 days ago last year; equivalent to `-1 year -5 days`)

### Integrated with template engines
##### DotLiquid
Expand Down
1 change: 1 addition & 0 deletions Tests/Plugins/ArithmeticTimePluginTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public string Tokenize_IsCaseInsensitive(string format)
[TestCase("15 years 3 months 2 hours", Result = "[Years:15][Months:3][Hours:2]")]
[TestCase("15 years -12 months 2 fortnights 3 weeks -17 days ago -hours 2 minutes secs", Result = "[Years:15][Months:-12][Fortnights:2][Weeks:3][Days:17][Hours:-1][Minutes:2][Seconds:1]")]
[TestCase("15 years -months +months ago -2 fortnights 3 weeks -17 days ago -hours 2 minutes secs", Result = "[Years:15][Months:-1][Months:-1][Fortnights:-2][Weeks:3][Days:17][Hours:-1][Minutes:2][Seconds:1]")]
[TestCase("1 year ago and 5 days ago", Result = "[Years:-1][Days:-5]")]
public string Tokenize_CanChainUnits(string format)
{
return this.Tokenize(new ArithmeticTimePlugin(), format);
Expand Down