gitlab-chronic 0.10.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.gitlab-ci.yml +14 -0
- data/.travis.yml +10 -0
- data/Gemfile +3 -0
- data/HISTORY.md +252 -0
- data/LICENSE +21 -0
- data/README.md +188 -0
- data/Rakefile +68 -0
- data/chronic.gemspec +25 -0
- data/lib/chronic.rb +155 -0
- data/lib/chronic/date.rb +81 -0
- data/lib/chronic/definition.rb +128 -0
- data/lib/chronic/dictionary.rb +36 -0
- data/lib/chronic/handler.rb +97 -0
- data/lib/chronic/handlers.rb +672 -0
- data/lib/chronic/mini_date.rb +38 -0
- data/lib/chronic/parser.rb +222 -0
- data/lib/chronic/repeaters/repeater_day.rb +54 -0
- data/lib/chronic/repeaters/repeater_day_name.rb +53 -0
- data/lib/chronic/repeaters/repeater_day_portion.rb +109 -0
- data/lib/chronic/repeaters/repeater_fortnight.rb +72 -0
- data/lib/chronic/repeaters/repeater_hour.rb +59 -0
- data/lib/chronic/repeaters/repeater_minute.rb +59 -0
- data/lib/chronic/repeaters/repeater_month.rb +80 -0
- data/lib/chronic/repeaters/repeater_month_name.rb +95 -0
- data/lib/chronic/repeaters/repeater_quarter.rb +59 -0
- data/lib/chronic/repeaters/repeater_quarter_name.rb +40 -0
- data/lib/chronic/repeaters/repeater_season.rb +111 -0
- data/lib/chronic/repeaters/repeater_season_name.rb +43 -0
- data/lib/chronic/repeaters/repeater_second.rb +43 -0
- data/lib/chronic/repeaters/repeater_time.rb +159 -0
- data/lib/chronic/repeaters/repeater_week.rb +76 -0
- data/lib/chronic/repeaters/repeater_weekday.rb +86 -0
- data/lib/chronic/repeaters/repeater_weekend.rb +67 -0
- data/lib/chronic/repeaters/repeater_year.rb +78 -0
- data/lib/chronic/season.rb +26 -0
- data/lib/chronic/span.rb +31 -0
- data/lib/chronic/tag.rb +89 -0
- data/lib/chronic/tags/grabber.rb +29 -0
- data/lib/chronic/tags/ordinal.rb +52 -0
- data/lib/chronic/tags/pointer.rb +28 -0
- data/lib/chronic/tags/repeater.rb +160 -0
- data/lib/chronic/tags/scalar.rb +89 -0
- data/lib/chronic/tags/separator.rb +123 -0
- data/lib/chronic/tags/sign.rb +35 -0
- data/lib/chronic/tags/time_zone.rb +32 -0
- data/lib/chronic/time.rb +40 -0
- data/lib/chronic/token.rb +61 -0
- data/lib/chronic/tokenizer.rb +38 -0
- data/lib/chronic/version.rb +3 -0
- data/test/helper.rb +12 -0
- data/test/test_chronic.rb +203 -0
- data/test/test_daylight_savings.rb +122 -0
- data/test/test_handler.rb +128 -0
- data/test/test_mini_date.rb +32 -0
- data/test/test_parsing.rb +1537 -0
- data/test/test_repeater_day_name.rb +51 -0
- data/test/test_repeater_day_portion.rb +254 -0
- data/test/test_repeater_fortnight.rb +62 -0
- data/test/test_repeater_hour.rb +68 -0
- data/test/test_repeater_minute.rb +34 -0
- data/test/test_repeater_month.rb +50 -0
- data/test/test_repeater_month_name.rb +56 -0
- data/test/test_repeater_quarter.rb +70 -0
- data/test/test_repeater_quarter_name.rb +198 -0
- data/test/test_repeater_season.rb +40 -0
- data/test/test_repeater_time.rb +88 -0
- data/test/test_repeater_week.rb +115 -0
- data/test/test_repeater_weekday.rb +55 -0
- data/test/test_repeater_weekend.rb +74 -0
- data/test/test_repeater_year.rb +69 -0
- data/test/test_span.rb +23 -0
- data/test/test_token.rb +31 -0
- metadata +215 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 92fc84f7462613e5b2ce67558d43d87f9a280526ddae7b02d5e9a2aeb56cace3
|
4
|
+
data.tar.gz: 411c1b9c6f2fb5d09657d1a1b971ad53c9d7ba3856898bde79ba82f9306a424b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: af07bbe9c23cd8f2ddb54fcfc2a1713291ea5b3cd48e880e498eb38f60d385544f23fd6861bcf98f88a1f7d94634d5a65cf09a2b6d356b4e55af53259dcd5bf6
|
7
|
+
data.tar.gz: bf5bcf7e44f77c801e3c358da2b4c89b869a8e12c1acbf89022b24a10e200056549c004775f284c0dd014ab8883b6f015466d16410bf11cf7d4aaabb1cea9edd
|
data/.gitignore
ADDED
data/.gitlab-ci.yml
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/HISTORY.md
ADDED
@@ -0,0 +1,252 @@
|
|
1
|
+
# --- Begin gitlab-chronic changes ---
|
2
|
+
|
3
|
+
# 0.10.3 / 2019-11-23
|
4
|
+
|
5
|
+
* Fix Daylight Savings parsing (https://gitlab.com/gitlab-org/gitlab-chronic/merge_requests/3)
|
6
|
+
* Add .gitlab-ci.yml (https://gitlab.com/gitlab-org/gitlab-chronic/merge_requests/1)
|
7
|
+
|
8
|
+
# --- End gitlab-chronic changes ---
|
9
|
+
|
10
|
+
# 0.10.2 / 2013-09-09
|
11
|
+
|
12
|
+
* Fix 1.8.7 support (due to be dropped in 0.11.0)
|
13
|
+
* Bugfix for times with negative zones
|
14
|
+
|
15
|
+
# 0.10.1 / 2013-08-27
|
16
|
+
|
17
|
+
* Support `ActiveSupport::TimeZone` (#209, #208)
|
18
|
+
|
19
|
+
# 0.10.0 / 2013-08-25
|
20
|
+
|
21
|
+
* Chronic will parse subseconds correctly
|
22
|
+
for all supported date/time formats (#195, #198 and #200)
|
23
|
+
* Support for date format: dd.mm.yyyy (#197)
|
24
|
+
* Option `:hours24` to parse as 24 hour clock (#201 and #202)
|
25
|
+
* `:guess` option allows to specify which part of Span to return.
|
26
|
+
(accepted values `false`,`true`,`:begin`, `:middle`, `:end`)
|
27
|
+
* Replace `rcov` with `SimpleCov` for coverage generation
|
28
|
+
* Add more tests
|
29
|
+
* Various changes in codebase (#202 and #206)
|
30
|
+
|
31
|
+
# 0.9.1 / 2013-02-25
|
32
|
+
|
33
|
+
* Ensure Chronic strips periods from day portions (#173)
|
34
|
+
* Properly numerize "twelfth", "twentieth" etc. (#172, James McKinney)
|
35
|
+
* Ensure Chronic is compatible with Ruby 2.0.0 (#165, Ravil Bayramgalin)
|
36
|
+
|
37
|
+
# 0.9.0 / 2012-12-21
|
38
|
+
|
39
|
+
* Implement Chronic::Parser class and create an instance of this class
|
40
|
+
instead of leaving all data in the class level of Chronic
|
41
|
+
* Various bug fixes
|
42
|
+
* Add support for excel date formats (#149, @jmondo)
|
43
|
+
* Added support for time expressions such as '10 till' or 'half
|
44
|
+
past two' (#146, @chicagogrooves)
|
45
|
+
* Add support for RepeaterDayName, RepeaterMonthName,
|
46
|
+
Ordinal/ScalarDay and Time (#153, @kareemk)
|
47
|
+
|
48
|
+
# 0.8.0 / 2012-09-16
|
49
|
+
|
50
|
+
* Support parsing "<ordinal> of this month" (#109)
|
51
|
+
* Support parsing ISO 8601 format (#115)
|
52
|
+
* Support parsing "on <day>" without a timestamp (#117)
|
53
|
+
* Fix time parsing regexp (#125)
|
54
|
+
* Support time when parsing dd-mm-yyy <time> (#126)
|
55
|
+
* Allow anchor handler to accept any separators (at, on) (#128)
|
56
|
+
* Support parsing EXIF date format (#112)
|
57
|
+
* Start using minitest for testing
|
58
|
+
* Ensure periods are interpreted as colons (#81).
|
59
|
+
* Support month/day and day/month parsing (#59).
|
60
|
+
* Support day(scalar)-month(name)-year(scalar) (#99).
|
61
|
+
* Handle text starting with 'a' or 'an' (#101, @steveburkett).
|
62
|
+
* Ensure post medium timestamps are correctly formatted (#89)
|
63
|
+
|
64
|
+
# 0.6.7 / 2012-01-31
|
65
|
+
|
66
|
+
* Handle day, month names with scalar day and year (Joe Fiorini)
|
67
|
+
* Ensure 31st parses correctly with day names (Joe Fiorini)
|
68
|
+
|
69
|
+
# 0.6.6 / 2011-11-23
|
70
|
+
|
71
|
+
* `Chronic.parse('thur')` no longer returns `nil` (@harold)
|
72
|
+
|
73
|
+
# 0.6.5 / 2011-11-04
|
74
|
+
|
75
|
+
* Fix bug when parsing ordinal repeaters (#73)
|
76
|
+
* Added handler support for day_name month_name (@imme5150)
|
77
|
+
* Fix bug when parsing strings prefixed with PM
|
78
|
+
|
79
|
+
# 0.6.4 / 2011-08-08
|
80
|
+
|
81
|
+
* Fixed bug where 'noon' was parsed as 00:00 rather than 12:00
|
82
|
+
with :ambiguous_time_range => :none (Vladimir Chernis)
|
83
|
+
* Add support for handling '2009 May 22nd'
|
84
|
+
* Add the ability to handle scalar-day/repeater-month-name as well as ordinals
|
85
|
+
|
86
|
+
# 0.6.3 / 2011-08-01
|
87
|
+
|
88
|
+
* Ensure 'thu' is parsed as Thursday for 1.8.7 generic timestamp
|
89
|
+
|
90
|
+
# 0.6.2 / 2011-07-28
|
91
|
+
|
92
|
+
* Ensure specific endian handlers are prioritised over normal date handlers
|
93
|
+
* Recognize UTC as timezone and accept HH::MM timezone offset (Jason Dusek)
|
94
|
+
|
95
|
+
# 0.6.1 / 2011-07-21
|
96
|
+
|
97
|
+
* Ensure Handler definitions are executed in the correct order
|
98
|
+
|
99
|
+
# 0.6.0 / 2011-07-19
|
100
|
+
|
101
|
+
* Attempting to parse strings with days past the last day of a month will
|
102
|
+
now return nil. ex: `Chronic.parse("30th February") #=> nil`
|
103
|
+
* All deprecated methods are marked for removal in Chronic 0.7.0
|
104
|
+
* Deprecated `Chronic.numericize_numbers` instead use
|
105
|
+
`Chronic::Numerizer.numerize`
|
106
|
+
* Deprecated `Chronic::InvalidArgumentException` and instead use
|
107
|
+
`ArgumentError`
|
108
|
+
* Deprecated `Time.construct` and use `Chronic.construct` in place of this
|
109
|
+
* Deprecated `Time#to_minidate`, instead use `Chronic::MiniDate.from_time(time)`
|
110
|
+
* Add support for handling generic timestamp for Ruby 1.9+
|
111
|
+
|
112
|
+
# 0.5.0 / 2011-07-01
|
113
|
+
|
114
|
+
* Replace commas with spaces instead of removing the char (Thomas Walpole)
|
115
|
+
* Added tests for RepeaterSeason
|
116
|
+
* Re-factored tests. Now rather than having a test_parsing method for testing
|
117
|
+
all handlers, break them down independent of handler method. For example
|
118
|
+
with handler `handle_sm_sd_sy` the subsequent test would be
|
119
|
+
`test_handle_sm_sd_sy`
|
120
|
+
* Added support for parsing ordinal-dates/month-names/year, ie:
|
121
|
+
`2nd of May 1995`
|
122
|
+
* Added support for parsing ordinal-dates and month names, ie:
|
123
|
+
`22nd of February at 6:30pm`
|
124
|
+
* Fix `Time.construct` leap year checking. Instead use `Date.leap?(year)`
|
125
|
+
|
126
|
+
# 0.4.4 / 2011-06-12
|
127
|
+
|
128
|
+
* Fix RepeaterYear for fetching past year offsets when the current day is
|
129
|
+
later than the last day of the same month in a past year (leap years) ie
|
130
|
+
on 29th/feb (leap year) `last year` should (and now does) return 28th/feb
|
131
|
+
instead of 1st/march
|
132
|
+
* Opt in for gem testing http://test.rubygems.org/
|
133
|
+
|
134
|
+
# 0.4.3 / 2011-06-08
|
135
|
+
|
136
|
+
* Fix issue with parsing 1:xxPM -- Ensure 1 is treated as ambiguous, not
|
137
|
+
just >1
|
138
|
+
|
139
|
+
# 0.4.2 / 2011-06-07
|
140
|
+
|
141
|
+
* Fix MonthRepeater for fetching past month offsets when current day is
|
142
|
+
later than the last day of a past month (ie on 29th of March when parsing
|
143
|
+
`last month` Chronic would return March instead of February. Now Chronic
|
144
|
+
returns the last day of the past month)
|
145
|
+
|
146
|
+
# 0.4.1 / 2011-06-05
|
147
|
+
|
148
|
+
* Fix MiniDate ranges for parsing seasons (Thomas Walpole)
|
149
|
+
|
150
|
+
# 0.4.0 / 2011-06-04
|
151
|
+
|
152
|
+
* Ensure context is being passed through grabbers. Now "Sunday at 2:18pm"
|
153
|
+
with `:context => :past` will return the correct date
|
154
|
+
* Support parsing ordinal strings (eg first, twenty third => 1st, 23rd)
|
155
|
+
* Seasons now ignore DST and return 00 as an hour
|
156
|
+
* Support parsing 2 digit years and added `ambiguous_year_future_bias` option
|
157
|
+
* Support parsing 'thurs' for Thursday
|
158
|
+
* Fix pre_normalize() to remove periods before numerizing
|
159
|
+
* Fix RepeaterDays to not add an extra hour in future tense. This meant
|
160
|
+
when parsing 'yesterday' after 11PM, Chronic would return today
|
161
|
+
* Discard any prefixed 0 for time strings when using post noon portion
|
162
|
+
* Gemspec updates for RubyGems deprecations
|
163
|
+
* Ensure 0:10 is treated like 00:10
|
164
|
+
* Ensure we load classes after setting Chronic class instance variables
|
165
|
+
so we can debug initialization and do assignments at compile time
|
166
|
+
* Added a Tag.scan_for method for DRYing up some scanning code
|
167
|
+
* Move some classes into their own files for maintainability
|
168
|
+
* Numerizer.andition should be a private class method, make it so
|
169
|
+
* Namespaced Numerizer, Season and MiniDate (Sascha Teske)
|
170
|
+
* Support for Ruby 1.9 (Dave Lee, Aaron Hurley)
|
171
|
+
* Fix `:context => :past` where parsed date is in current month (Marc Hedlund)
|
172
|
+
* Fix undefined variable in RepeaterHour (Ryan Garver)
|
173
|
+
* Added support for parsing 'Fourty' as another mis-spelling (Lee Reilly)
|
174
|
+
* Added ordinal format support: ie 'February 14th, 2004' (Jeff Felchner)
|
175
|
+
* Fix dates when working with daylight saving times (Mike Mangino)
|
176
|
+
|
177
|
+
# 0.3.0 / 2010-10-22
|
178
|
+
|
179
|
+
* Fix numerizer number combination bug (27 Oct 2006 7:30pm works now)
|
180
|
+
* Allow numeric timezone offset (e.g -0500)
|
181
|
+
* Disregard commas (so as to not return nil)
|
182
|
+
* Fix parse of (am|pm|oclock) separation to handle "Ham sandwich" properly
|
183
|
+
* Handle 'on' e.g. 5pm on Monday
|
184
|
+
* Support seasons
|
185
|
+
* Support weekend/weekday
|
186
|
+
* Add endianness option
|
187
|
+
* Update version number in the module
|
188
|
+
* Fix/improve logic checks in Ordinal, and Scalar
|
189
|
+
* Parse 'a' or 'p' as 'am' and 'pm' google-calendar style
|
190
|
+
* Dates < 1 are not valid
|
191
|
+
* Fix bugs related to timezone offset
|
192
|
+
* Use RakeGem for build management
|
193
|
+
* Reformat README and HISTORY to use Markdown
|
194
|
+
* Global whitespace removal
|
195
|
+
|
196
|
+
# 0.2.3
|
197
|
+
|
198
|
+
* Fix 12am/12pm
|
199
|
+
|
200
|
+
# 0.2.2
|
201
|
+
|
202
|
+
* Add missing files (damn you manifest)
|
203
|
+
|
204
|
+
# 0.2.1
|
205
|
+
|
206
|
+
* Fix time overflow issue
|
207
|
+
* Implement "next" for minute repeater
|
208
|
+
* Generalize time dealiasing to dealias regardless of day portion and
|
209
|
+
time position
|
210
|
+
* Add additional token match for cases like "friday evening at 7" and
|
211
|
+
"tomorrow evening at 7"
|
212
|
+
* Add support for Time#to_s output format: "Mon Apr 02 17:00:00 PDT 2007"
|
213
|
+
|
214
|
+
# 0.2.0 2007-03-20
|
215
|
+
|
216
|
+
* Implement numerizer, allowing the use of number words (e.g. five weeks ago)
|
217
|
+
|
218
|
+
# 0.1.6 2006-01-15
|
219
|
+
|
220
|
+
* Add 'weekend' support
|
221
|
+
|
222
|
+
# 0.1.5 2006-12-20
|
223
|
+
|
224
|
+
* Fix 'aug 20' returning next year if current month is august
|
225
|
+
* Modify behavior of 'from now'
|
226
|
+
* Add support for seconds on times, and thus db timestamp format:
|
227
|
+
"2006-12-20 18:04:23"
|
228
|
+
* Make Hoe compliant
|
229
|
+
|
230
|
+
# 0.1.4
|
231
|
+
|
232
|
+
* Remove verbose error checking code. oops. :-/
|
233
|
+
|
234
|
+
# 0.1.3
|
235
|
+
|
236
|
+
* improved regexes for word variations
|
237
|
+
* Fix a bug that caused "today at 3am" to return nil if current time is
|
238
|
+
after 3am
|
239
|
+
|
240
|
+
# 0.1.2
|
241
|
+
|
242
|
+
* Remove Date dependency (now works on windows properly without fiddling)
|
243
|
+
|
244
|
+
# 0.1.1
|
245
|
+
|
246
|
+
* Run to_s on incoming object
|
247
|
+
* Fix loop loading of repeaters files (out of order on some machines)
|
248
|
+
* Fix find_within to use this instead of next (was breaking "today at 6pm")
|
249
|
+
|
250
|
+
# 0.1.0
|
251
|
+
|
252
|
+
* Initial release
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) Tom Preston-Werner
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,188 @@
|
|
1
|
+
Chronic
|
2
|
+
=======
|
3
|
+
|
4
|
+
This is a fork of https://github.com/mojombo/chronic since that project
|
5
|
+
does not appear to be maintained.
|
6
|
+
|
7
|
+
Chronic is a natural language date/time parser written in pure Ruby. See below
|
8
|
+
for the wide variety of formats Chronic will parse.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
```
|
13
|
+
$ gem install chronic
|
14
|
+
```
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
require 'chronic'
|
20
|
+
|
21
|
+
Time.now #=> Sun Aug 27 23:18:25 PDT 2006
|
22
|
+
|
23
|
+
Chronic.parse('tomorrow')
|
24
|
+
#=> Mon Aug 28 12:00:00 PDT 2006
|
25
|
+
|
26
|
+
Chronic.parse('monday', :context => :past)
|
27
|
+
#=> Mon Aug 21 12:00:00 PDT 2006
|
28
|
+
|
29
|
+
Chronic.parse('this tuesday 5:00')
|
30
|
+
#=> Tue Aug 29 17:00:00 PDT 2006
|
31
|
+
|
32
|
+
Chronic.parse('this tuesday 5:00', :ambiguous_time_range => :none)
|
33
|
+
#=> Tue Aug 29 05:00:00 PDT 2006
|
34
|
+
|
35
|
+
Chronic.parse('may 27th', :now => Time.local(2000, 1, 1))
|
36
|
+
#=> Sat May 27 12:00:00 PDT 2000
|
37
|
+
|
38
|
+
Chronic.parse('may 27th', :guess => false)
|
39
|
+
#=> Sun May 27 00:00:00 PDT 2007..Mon May 28 00:00:00 PDT 2007
|
40
|
+
|
41
|
+
Chronic.parse('6/4/2012', :endian_precedence => :little)
|
42
|
+
#=> Fri Apr 06 00:00:00 PDT 2012
|
43
|
+
|
44
|
+
Chronic.parse('INVALID DATE')
|
45
|
+
#=> nil
|
46
|
+
```
|
47
|
+
|
48
|
+
If the parser can find a date or time, either a Time or Chronic::Span
|
49
|
+
will be returned (depending on the value of `:guess`). If no
|
50
|
+
date or time can be found, `nil` will be returned.
|
51
|
+
|
52
|
+
See `Chronic.parse` for detailed usage instructions.
|
53
|
+
|
54
|
+
## Examples
|
55
|
+
|
56
|
+
Chronic can parse a huge variety of date and time formats. Following is a
|
57
|
+
small sample of strings that will be properly parsed. Parsing is case
|
58
|
+
insensitive and will handle common abbreviations and misspellings.
|
59
|
+
|
60
|
+
#### Simple
|
61
|
+
|
62
|
+
* thursday
|
63
|
+
* november
|
64
|
+
* summer
|
65
|
+
* friday 13:00
|
66
|
+
* mon 2:35
|
67
|
+
* 4pm
|
68
|
+
* 10 to 8
|
69
|
+
* 10 past 2
|
70
|
+
* half past 2
|
71
|
+
* 6 in the morning
|
72
|
+
* friday 1pm
|
73
|
+
* sat 7 in the evening
|
74
|
+
* yesterday
|
75
|
+
* today
|
76
|
+
* tomorrow
|
77
|
+
* last week
|
78
|
+
* next week
|
79
|
+
* this tuesday
|
80
|
+
* next month
|
81
|
+
* last winter
|
82
|
+
* this morning
|
83
|
+
* last night
|
84
|
+
* this second
|
85
|
+
* yesterday at 4:00
|
86
|
+
* last friday at 20:00
|
87
|
+
* last week tuesday
|
88
|
+
* tomorrow at 6:45pm
|
89
|
+
* afternoon yesterday
|
90
|
+
* thursday last week
|
91
|
+
|
92
|
+
#### Complex
|
93
|
+
|
94
|
+
* 3 years ago
|
95
|
+
* a year ago
|
96
|
+
* 5 months before now
|
97
|
+
* 7 hours ago
|
98
|
+
* 7 days from now
|
99
|
+
* 1 week hence
|
100
|
+
* in 3 hours
|
101
|
+
* 1 year ago tomorrow
|
102
|
+
* 3 months ago saturday at 5:00 pm
|
103
|
+
* 7 hours before tomorrow at noon
|
104
|
+
* 3rd wednesday in november
|
105
|
+
* 3rd month next year
|
106
|
+
* 3rd thursday this september
|
107
|
+
* 4th day last week
|
108
|
+
* fourteenth of june 2010 at eleven o'clock in the evening
|
109
|
+
* may seventh '97 at three in the morning
|
110
|
+
|
111
|
+
#### Specific Dates
|
112
|
+
|
113
|
+
* January 5
|
114
|
+
* 22nd of june
|
115
|
+
* 5th may 2017
|
116
|
+
* February twenty first
|
117
|
+
* dec 25
|
118
|
+
* may 27th
|
119
|
+
* October 2006
|
120
|
+
* oct 06
|
121
|
+
* jan 3 2010
|
122
|
+
* february 14, 2004
|
123
|
+
* february 14th, 2004
|
124
|
+
* 3 jan 2000
|
125
|
+
* 17 april 85
|
126
|
+
* 5/27/1979
|
127
|
+
* 27/5/1979
|
128
|
+
* 05/06
|
129
|
+
* 1979-05-27
|
130
|
+
* Friday
|
131
|
+
* 5
|
132
|
+
* 4:00
|
133
|
+
* 17:00
|
134
|
+
* 0800
|
135
|
+
|
136
|
+
#### Specific Times (many of the above with an added time)
|
137
|
+
|
138
|
+
* January 5 at 7pm
|
139
|
+
* 22nd of june at 8am
|
140
|
+
* 1979-05-27 05:00:00
|
141
|
+
* 03/01/2012 07:25:09.234567
|
142
|
+
* 2013-08-01T19:30:00.345-07:00
|
143
|
+
* 2013-08-01T19:30:00.34-07:00
|
144
|
+
* etc
|
145
|
+
|
146
|
+
|
147
|
+
## Time Zones
|
148
|
+
|
149
|
+
Chronic allows you to set which Time class to use when constructing times. By
|
150
|
+
default, the built in Ruby time class creates times in your system's local
|
151
|
+
time zone. You can set this to something like ActiveSupport's
|
152
|
+
[TimeZone](http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html)
|
153
|
+
class to get full time zone support.
|
154
|
+
|
155
|
+
```
|
156
|
+
>> Time.zone = "UTC"
|
157
|
+
>> Chronic.time_class = Time.zone
|
158
|
+
>> Chronic.parse("June 15 2006 at 5:45 AM")
|
159
|
+
=> Thu, 15 Jun 2006 05:45:00 UTC +00:00
|
160
|
+
```
|
161
|
+
|
162
|
+
## Limitations
|
163
|
+
|
164
|
+
Chronic uses Ruby's built in Time class for all time storage and computation.
|
165
|
+
Because of this, only times that the Time class can handle will be properly
|
166
|
+
parsed. Parsing for times outside of this range will simply return `nil`.
|
167
|
+
Support for a wider range of times is planned for a future release.
|
168
|
+
|
169
|
+
|
170
|
+
## Contribute
|
171
|
+
|
172
|
+
If you'd like to hack on Chronic, start by forking the repo on GitHub:
|
173
|
+
|
174
|
+
https://github.com/mojombo/chronic
|
175
|
+
|
176
|
+
The best way to get your changes merged back into core is as follows:
|
177
|
+
|
178
|
+
1. Clone down your fork
|
179
|
+
1. Create a thoughtfully named topic branch to contain your change
|
180
|
+
1. Install the development dependencies by running `bundle install`
|
181
|
+
1. Hack away
|
182
|
+
1. Add tests and make sure everything still passes by running `bundle exec rake`
|
183
|
+
1. Ensure your tests pass in multiple timezones. ie `TZ=utc bundle exec rake` `TZ=BST bundle exec rake`
|
184
|
+
1. If you are adding new functionality, document it in the README
|
185
|
+
1. Do not change the version number, we will do that on our end
|
186
|
+
1. If necessary, rebase your commits into logical chunks, without errors
|
187
|
+
1. Push the branch up to GitHub
|
188
|
+
1. Send a pull request for your branch
|