Skip to content
Newer
Older
100644 139 lines (81 sloc) 3.15 KB
eba21fb @ChrisMissal Update Readme
authored Feb 7, 2015
1 # TempusReader
5e96b49 @ChrisMissal initial commit of proof of concept
authored Jun 11, 2012
2
3 ## What is this?
4
492e320 @ChrisMissal Update README.md
authored Dec 26, 2012
5 TempusReader is just a project that I thought could be useful for parsing durations of time in plain text English. Currently, this is just a fun example to try out [Parsley](https://github.com/plioi/parsley), but if anybody finds it useful, I'd love some feedback!
5e96b49 @ChrisMissal initial commit of proof of concept
authored Jun 12, 2012
6
c92070c @ChrisMissal Update README.md
authored Jan 10, 2013
7 [![Status of Dependencies](http://nugetstatus.com/tempusreader.png "Status of Dependencies")](http://nugetstatus.com/packages/tempusreader)
8
eba21fb @ChrisMissal Update Readme
authored Feb 7, 2015
9 ## Installation
10
11 Use [NuGet to install TempusReader](https://nuget.org/packages/TempusReader):
12
13 PM> Install-Package TempusReader
14
5e96b49 @ChrisMissal initial commit of proof of concept
authored Jun 12, 2012
15 ## Examples
16
17 Simply create a new `Time` instance by passing in a string of text.
18
9e8ddc6 @ChrisMissal cleaned up some code and added Date examples
authored Jun 19, 2012
19 <!--- TimeTests start -->
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
20 ### Single Values
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
21 ```csharp
22 new Time("1 minute") // 00:01:00
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
23
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
24 new Time("1 minutes") // 00:01:00
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
25
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
26 new Time("0 minutes") // 00:00:00
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
27
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
28 new Time("90 minutes") // 01:30:00
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
29
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
30 new Time("15 min") // 00:15:00
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
31
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
32 new Time("45 mins") // 00:45:00
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
33
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
34 new Time("8 seconds") // 00:00:08
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
35
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
36 new Time("1 second") // 00:00:01
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
37
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
38 new Time("123 second") // 00:02:03
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
39
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
40 new Time("4 s") // 00:00:04
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
41
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
42 new Time("82 sec") // 00:01:22
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
43
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
44 new Time("1 day") // 1.00:00:00
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
45
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
46 new Time("2 days") // 2.00:00:00
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
47
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
48 new Time("3 d") // 3.00:00:00
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
49
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
50 new Time("12 hours") // 12:00:00
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
51
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
52 new Time("3 hour") // 03:00:00
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
53
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
54 new Time("9 hr") // 09:00:00
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
55
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
56 new Time("21 milliseconds") // 00:00:00.0210000
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
57
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
58 new Time("500 ms") // 00:00:00.5000000
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
59
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
60 ```
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
61 ### Multiple Values
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
62 ```csharp
63 new Time("2 days, 7 hours, 12 mins and 52 seconds") // 2.07:12:52
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
64
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
65 new Time("4 days and 21 minutes") // 4.00:21:00
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
66
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
67 ```
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
68 ### Fractional Values
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
69 ```csharp
70 new Time("4:15 hrs") // 04:15:00
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
71
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
72 new Time("2.18 seconds") // 00:00:02.1800000
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
73
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
74 new Time("6.5 minutes") // 00:06:30
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
75
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
76 ```
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
77 ### Multiple and Fractional Values
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
78 ```csharp
79 new Time("3:45 hours and 2.5 mins") // 03:47:30
fea116c @ChrisMissal updated examples in README.md
authored Jun 15, 2012
80
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
81 new Time("2.25 days, 4 hours, 90 mins") // 2.11:30:00
5e96b49 @ChrisMissal initial commit of proof of concept
authored Jun 12, 2012
82
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
83 ```
4d32029 @ChrisMissal upgraded to Parsley 0.0.4 and added case insensitivity
authored Dec 27, 2012
84 ### Mixed Case (upper/lower) Values
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
85 ```csharp
86 new Time("13 Hours and 14 MINs") // 13:14:00
4d32029 @ChrisMissal upgraded to Parsley 0.0.4 and added case insensitivity
authored Dec 28, 2012
87
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
88 new Time("45 SECONDS and 50 miLLiseconds") // 00:00:45.0500000
4d32029 @ChrisMissal upgraded to Parsley 0.0.4 and added case insensitivity
authored Dec 28, 2012
89
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
90 ```
077b7c3 @ChrisMissal added words for digits 'one' through 'ten'
authored Dec 29, 2012
91 ### English Words to Values
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
92 ```csharp
93 new Time("one hour") // 01:00:00
077b7c3 @ChrisMissal added words for digits 'one' through 'ten'
authored Dec 29, 2012
94
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
95 new Time("two minutes") // 00:02:00
077b7c3 @ChrisMissal added words for digits 'one' through 'ten'
authored Dec 29, 2012
96
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
97 new Time("three seconds") // 00:00:03
077b7c3 @ChrisMissal added words for digits 'one' through 'ten'
authored Dec 29, 2012
98
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
99 new Time("four ms") // 00:00:00.0040000
077b7c3 @ChrisMissal added words for digits 'one' through 'ten'
authored Dec 29, 2012
100
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
101 new Time("five hrs") // 05:00:00
077b7c3 @ChrisMissal added words for digits 'one' through 'ten'
authored Dec 29, 2012
102
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
103 new Time("six mins") // 00:06:00
077b7c3 @ChrisMissal added words for digits 'one' through 'ten'
authored Dec 29, 2012
104
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
105 new Time("seven sec") // 00:00:07
077b7c3 @ChrisMissal added words for digits 'one' through 'ten'
authored Dec 29, 2012
106
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
107 new Time("eight milliseconds") // 00:00:00.0080000
077b7c3 @ChrisMissal added words for digits 'one' through 'ten'
authored Dec 29, 2012
108
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
109 new Time("nine hours") // 09:00:00
077b7c3 @ChrisMissal added words for digits 'one' through 'ten'
authored Dec 29, 2012
110
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
111 new Time("ten minutes") // 00:10:00
077b7c3 @ChrisMissal added words for digits 'one' through 'ten'
authored Dec 29, 2012
112
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
113 ```
9e8ddc6 @ChrisMissal cleaned up some code and added Date examples
authored Jun 19, 2012
114 <!--- TimeTests end -->
5e96b49 @ChrisMissal initial commit of proof of concept
authored Jun 12, 2012
115
116 A `Time` instance can be created from text and cast to a `TimeSpan` instance.
9e8ddc6 @ChrisMissal cleaned up some code and added Date examples
authored Jun 19, 2012
117
118 ## Adding/Subtracting from a Date
119
120 <!--- DateTests start -->
121 ### Relative Date Values
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
122 ```csharp
123 var BaseDate = new DateTime(1982, 10, 21, 23, 40, 0);
9e8ddc6 @ChrisMissal cleaned up some code and added Date examples
authored Jun 19, 2012
124
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
125 new Date(BaseDate, "in 10 minutes") // 10/21/1982 11:50:00 PM
9e8ddc6 @ChrisMissal cleaned up some code and added Date examples
authored Jun 19, 2012
126
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
127 new Date(BaseDate, "4 hrs from now") // 10/22/1982 3:40:00 AM
9e8ddc6 @ChrisMissal cleaned up some code and added Date examples
authored Jun 19, 2012
128
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
129 new Date(BaseDate, "45 seconds ago") // 10/21/1982 11:39:15 PM
9e8ddc6 @ChrisMissal cleaned up some code and added Date examples
authored Jun 19, 2012
130
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
131 new Date(BaseDate, "yesterday") // 10/20/1982 11:40:00 PM
9be5761 @scichelli support Yesterday as a keyword
scichelli authored Dec 26, 2012
132
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
133 new Date(BaseDate, "tomorrow") // 10/22/1982 11:40:00 PM
017900d @scichelli support Tomorrow as a keyword
scichelli authored Dec 26, 2012
134
06932bc @ChrisMissal Regenerate readme with new formatting
authored Feb 7, 2015
135 ```
9e8ddc6 @ChrisMissal cleaned up some code and added Date examples
authored Jun 19, 2012
136 <!--- DateTests end -->
137
138 A `Date` instance can be created from text and added/subtracted to a `DateTime` instance.
Something went wrong with that request. Please try again.