chrono-node 1.3.2 → 1.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/README.md +108 -67
  2. package/bower.json +1 -1
  3. package/chrono.js +1340 -1003
  4. package/chrono.map.json +1 -1
  5. package/chrono.min.js +108 -106
  6. package/package.json +11 -15
  7. package/src/chrono.js +2 -3
  8. package/src/options.js +3 -2
  9. package/src/parsers/{DE → de}/DECasualDateParser.js +0 -0
  10. package/src/parsers/{DE → de}/DEDeadlineFormatParser.js +0 -0
  11. package/src/parsers/{DE → de}/DEMonthNameLittleEndianParser.js +0 -0
  12. package/src/parsers/{DE → de}/DEMonthNameParser.js +0 -0
  13. package/src/parsers/{DE → de}/DESlashDateFormatParser.js +0 -0
  14. package/src/parsers/{DE → de}/DETimeAgoFormatParser.js +0 -0
  15. package/src/parsers/{DE → de}/DETimeExpressionParser.js +0 -0
  16. package/src/parsers/{DE → de}/DEWeekdayParser.js +4 -4
  17. package/src/parsers/{EN → en}/ENCasualDateParser.js +4 -4
  18. package/src/parsers/en/ENCasualTimeParser.js +60 -0
  19. package/src/parsers/{EN → en}/ENDeadlineFormatParser.js +6 -6
  20. package/src/parsers/{EN → en}/ENISOFormatParser.js +0 -0
  21. package/src/parsers/{EN → en}/ENMonthNameLittleEndianParser.js +24 -24
  22. package/src/parsers/{EN → en}/ENMonthNameMiddleEndianParser.js +5 -4
  23. package/src/parsers/{EN → en}/ENMonthNameParser.js +1 -1
  24. package/src/parsers/{EN → en}/ENRelativeDateFormatParser.js +40 -2
  25. package/src/parsers/{EN → en}/ENSlashDateFormatParser.js +5 -1
  26. package/src/parsers/{EN → en}/ENSlashDateFormatStartWithYearParser.js +8 -2
  27. package/src/parsers/{EN → en}/ENSlashMonthFormatParser.js +0 -0
  28. package/src/parsers/en/ENTimeAgoFormatParser.js +69 -0
  29. package/src/parsers/{EN → en}/ENTimeExpressionParser.js +24 -11
  30. package/src/parsers/en/ENTimeLaterFormatParser.js +77 -0
  31. package/src/parsers/{EN → en}/ENWeekdayParser.js +0 -0
  32. package/src/parsers/{ES → es}/ESCasualDateParser.js +0 -0
  33. package/src/parsers/{ES → es}/ESDeadlineFormatParser.js +0 -0
  34. package/src/parsers/{ES → es}/ESMonthNameLittleEndianParser.js +2 -2
  35. package/src/parsers/{ES → es}/ESSlashDateFormatParser.js +0 -0
  36. package/src/parsers/{ES → es}/ESTimeAgoFormatParser.js +0 -0
  37. package/src/parsers/{ES → es}/ESTimeExpressionParser.js +0 -0
  38. package/src/parsers/{ES → es}/ESWeekdayParser.js +1 -1
  39. package/src/parsers/{FR → fr}/FRCasualDateParser.js +0 -0
  40. package/src/parsers/{FR → fr}/FRDeadlineFormatParser.js +0 -0
  41. package/src/parsers/{FR → fr}/FRMonthNameLittleEndianParser.js +0 -0
  42. package/src/parsers/{FR → fr}/FRRelativeDateFormatParser.js +5 -1
  43. package/src/parsers/{FR → fr}/FRSlashDateFormatParser.js +41 -11
  44. package/src/parsers/{FR → fr}/FRTimeAgoFormatParser.js +0 -0
  45. package/src/parsers/{FR → fr}/FRTimeExpressionParser.js +0 -0
  46. package/src/parsers/{FR → fr}/FRWeekdayParser.js +1 -1
  47. package/src/parsers/{JP → ja}/JPCasualDateParser.js +0 -0
  48. package/src/parsers/{JP → ja}/JPStandardParser.js +0 -0
  49. package/src/parsers/parser.js +50 -49
  50. package/src/parsers/{ZH-Hant → zh-Hant}/ZHHantCasualDateParser.js +18 -2
  51. package/src/parsers/{ZH-Hant → zh-Hant}/ZHHantDateParser.js +0 -0
  52. package/src/parsers/{ZH-Hant → zh-Hant}/ZHHantDeadlineFormatParser.js +0 -0
  53. package/src/parsers/{ZH-Hant → zh-Hant}/ZHHantTimeExpressionParser.js +36 -4
  54. package/src/parsers/{ZH-Hant → zh-Hant}/ZHHantWeekdayParser.js +1 -1
  55. package/src/refiners/ExtractTimezoneAbbrRefiner.js +19 -10
  56. package/src/refiners/ForwardDateRefiner.js +1 -1
  57. package/src/refiners/{DE → de}/DEMergeDateRangeRefiner.js +1 -1
  58. package/src/refiners/{DE → de}/DEMergeDateTimeRefiner.js +3 -3
  59. package/src/refiners/{EN → en}/ENMergeDateRangeRefiner.js +21 -3
  60. package/src/refiners/{EN → en}/ENMergeDateTimeRefiner.js +15 -2
  61. package/src/refiners/{EN → en}/ENMergeWeekdayRefiner.js +0 -0
  62. package/src/refiners/{EN → en}/ENPrioritizeSpecificDateRefiner.js +0 -0
  63. package/src/refiners/{FR → fr}/FRMergeDateRangeRefiner.js +0 -0
  64. package/src/refiners/{FR → fr}/FRMergeDateTimeRefiner.js +1 -1
  65. package/src/refiners/{JP → ja}/JPMergeDateRangeRefiner.js +1 -1
  66. package/src/refiners/refiner.js +12 -12
  67. package/src/result.js +3 -1
  68. package/src/timezone.js +2 -0
  69. package/src/utils/EN.js +68 -2
  70. package/test/de/de.test.js +51 -0
  71. package/test/de/de_casual.test.js +432 -0
  72. package/test/de/de_dash.test.js +6 -0
  73. package/test/de/de_deadline.test.js +244 -0
  74. package/test/de/de_little_endian.test.js +459 -0
  75. package/test/de/de_time_ago.test.js +313 -0
  76. package/test/de/de_time_exp.test.js +166 -0
  77. package/test/de/de_weekday.test.js +235 -0
  78. package/test/en/en.test.js +250 -0
  79. package/test/en/en_casual.test.js +461 -0
  80. package/test/en/en_dash.test.js +31 -0
  81. package/test/en/en_deadline.test.js +366 -0
  82. package/test/{test_example.js → en/en_example.test.js} +7 -18
  83. package/test/en/en_inter_std.test.js +269 -0
  84. package/test/en/en_little_endian.test.js +566 -0
  85. package/test/en/en_middle_endian.test.js +552 -0
  86. package/test/en/en_month.test.js +113 -0
  87. package/test/en/en_option_forward.test.js +156 -0
  88. package/test/en/en_relative.test.js +228 -0
  89. package/test/en/en_slash.test.js +450 -0
  90. package/test/en/en_time_ago.test.js +374 -0
  91. package/test/en/en_time_exp.test.js +722 -0
  92. package/test/en/en_time_from_now.test.js +371 -0
  93. package/test/en/en_time_later.test.js +95 -0
  94. package/test/en/en_weekday.test.js +301 -0
  95. package/test/es/es_casual.test.js +258 -0
  96. package/test/es/es_dash.test.js +13 -0
  97. package/test/es/es_deadline.test.js +85 -0
  98. package/test/es/es_little_endian.test.js +350 -0
  99. package/test/es/es_slash.test.js +24 -0
  100. package/test/es/es_time_ago.test.js +137 -0
  101. package/test/es/es_time_exp.test.js +240 -0
  102. package/test/fr/fr_casual.test.js +454 -0
  103. package/test/fr/fr_dash.test.js +26 -0
  104. package/test/fr/fr_deadline.test.js +244 -0
  105. package/test/fr/fr_little_endian.test.js +576 -0
  106. package/test/fr/fr_relative.test.js +198 -0
  107. package/test/fr/fr_slash.test.js +62 -0
  108. package/test/fr/fr_time_ago.test.js +194 -0
  109. package/test/fr/fr_time_exp.test.js +960 -0
  110. package/test/fr/fr_weekday.test.js +200 -0
  111. package/test/ja/ja_casual.test.js +51 -0
  112. package/test/ja/ja_standard.test.js +170 -0
  113. package/test/system.test.js +207 -0
  114. package/test/zh/zh_hant_casual.test.js +340 -0
  115. package/test/zh/zh_hant_date.test.js +118 -0
  116. package/test/zh/zh_hant_deadline.test.js +213 -0
  117. package/test/zh/zh_hant_time_exp.test.js +226 -0
  118. package/test/zh/zh_hant_weekday.test.js +160 -0
  119. package/.npmignore +0 -11
  120. package/src/parsers/EN/ENCasualTimeParser.js +0 -53
  121. package/src/parsers/EN/ENTimeAgoFormatParser.js +0 -114
  122. package/test/test_de.js +0 -62
  123. package/test/test_de_casual.js +0 -443
  124. package/test/test_de_dash.js +0 -17
  125. package/test/test_de_deadline.js +0 -255
  126. package/test/test_de_little_endian.js +0 -470
  127. package/test/test_de_time_ago.js +0 -324
  128. package/test/test_de_time_exp.js +0 -177
  129. package/test/test_de_weekday.js +0 -246
  130. package/test/test_en.js +0 -217
  131. package/test/test_en_casual.js +0 -448
  132. package/test/test_en_dash.js +0 -42
  133. package/test/test_en_deadline.js +0 -311
  134. package/test/test_en_inter_std.js +0 -272
  135. package/test/test_en_little_endian.js +0 -505
  136. package/test/test_en_middle_endian.js +0 -524
  137. package/test/test_en_month.js +0 -124
  138. package/test/test_en_option_forward.js +0 -167
  139. package/test/test_en_relative.js +0 -206
  140. package/test/test_en_slash.js +0 -370
  141. package/test/test_en_time_ago.js +0 -356
  142. package/test/test_en_time_exp.js +0 -663
  143. package/test/test_en_weekday.js +0 -312
  144. package/test/test_es_casual.js +0 -269
  145. package/test/test_es_dash.js +0 -24
  146. package/test/test_es_deadline.js +0 -96
  147. package/test/test_es_little_endian.js +0 -361
  148. package/test/test_es_slash.js +0 -35
  149. package/test/test_es_time_ago.js +0 -148
  150. package/test/test_es_time_exp.js +0 -251
  151. package/test/test_fr_casual.js +0 -465
  152. package/test/test_fr_dash.js +0 -37
  153. package/test/test_fr_deadline.js +0 -255
  154. package/test/test_fr_little_endian.js +0 -568
  155. package/test/test_fr_relative.js +0 -209
  156. package/test/test_fr_slash.js +0 -54
  157. package/test/test_fr_time_ago.js +0 -205
  158. package/test/test_fr_time_exp.js +0 -971
  159. package/test/test_fr_weekday.js +0 -211
  160. package/test/test_jp_casual.js +0 -62
  161. package/test/test_jp_standard.js +0 -181
  162. package/test/test_system.js +0 -178
  163. package/test/test_zh_hant_casual.js +0 -329
  164. package/test/test_zh_hant_date.js +0 -129
  165. package/test/test_zh_hant_deadline.js +0 -224
  166. package/test/test_zh_hant_time_exp.js +0 -210
  167. package/test/test_zh_hant_weekday.js +0 -171
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
- Chrono
2
- ======
1
+ # Chrono
2
+
3
3
  A natural language date parser in Javascript, designed for extracting date information from any given text. (Java version is also available [here](https://github.com/wanasit/chrono-java))
4
4
 
5
5
  [![Build Status](https://travis-ci.org/wanasit/chrono.svg?branch=master)](https://travis-ci.org/wanasit/chrono)
@@ -11,6 +11,7 @@ Chrono supports most date and time formats, such as :
11
11
  * 17 August 2013 - 19 August 2013
12
12
  * This Friday from 13:00 - 16.00
13
13
  * 5 days ago
14
+ * 2 weeks from now
14
15
  * Sat Aug 17 2013 18:40:39 GMT+0900 (JST)
15
16
  * 2014-11-30T08:15:30-05:30
16
17
 
@@ -19,27 +20,29 @@ Chrono supports most date and time formats, such as :
19
20
  #### npm (recommended)
20
21
 
21
22
  Just run:
22
-
23
- $ npm i --save chrono-node
23
+ ```bash
24
+ $ npm i --save chrono-node
25
+ ```
24
26
 
25
27
  And start using chrono:
26
-
27
- var chrono = require('chrono-node')
28
- chrono.parseDate('An appointment on Sep 12-13')
28
+ ```js
29
+ var chrono = require('chrono-node');
30
+ chrono.parseDate('An appointment on Sep 12-13');
31
+ ```
29
32
 
30
33
  #### Bower
31
34
 
32
35
  Prefer bower? You can do that, too:
33
36
 
34
37
  Just run:
35
-
36
- $ bower install chrono
37
-
38
+ ```bash
39
+ $ bower install chrono
40
+ ```
38
41
  And use:
39
42
 
40
43
  ```html
41
- <script src="bower_components/chrono/chrono.min.js"></script>
42
- <script>chrono.parseDate('An appointment on Sep 12-13')</script>
44
+ <script src="bower_components/chrono/chrono.min.js"></script>
45
+ <script>chrono.parseDate('An appointment on Sep 12-13')</script>
43
46
  ```
44
47
 
45
48
 
@@ -49,7 +52,7 @@ Doing something else? No worries. Try these:
49
52
 
50
53
  Platform | Installation
51
54
  ---------|----
52
- CDN | Via [jsDelivr]:<br> `<script src="https://cdn.jsdelivr.net/chrono/VERSION/chrono.min.js"></script>`
55
+ CDN | Via [jsDelivr]:<br> `<script src="https://cdn.jsdelivr.net/npm/chrono-node@VERSION/chrono.min.js"></script>`
53
56
  Rails | Install from [Rails Assets] by adding this to your Gemfile:<br> `gem 'rails-assets-chrono', source: 'https://rails-assets.org'`
54
57
  Swift | Try using the community-made [chrono-swift] wrapper.
55
58
 
@@ -61,22 +64,22 @@ Swift | Try using the community-made [chrono-swift] wrapper.
61
64
 
62
65
  Chrono's modules are linked and packaged using [Browserify](http://browserify.org) on `src/chrono.js`. By default, `chrono.js` file exports `chrono` object as a window global.
63
66
 
64
- ```
65
- browserify src/chrono.js --s chrono -o chrono.js
67
+ ```bash
68
+ $ browserify src/chrono.js --s chrono -o chrono.js
66
69
  ```
67
70
 
68
71
  ## Usage
69
72
 
70
73
  Simply pass a string to function `chrono.parseDate` or `chrono.parse`.
71
74
 
72
- ```javascript
73
- > var chrono = require('chrono-node')
75
+ ```js
76
+ var chrono = require('chrono-node');
74
77
 
75
- > chrono.parseDate('An appointment on Sep 12-13')
76
- Fri Sep 12 2014 12:00:00 GMT-0500 (CDT)
78
+ chrono.parseDate('An appointment on Sep 12-13');
79
+ // Fri Sep 12 2014 12:00:00 GMT-0500 (CDT)
77
80
 
78
- > chrono.parse('An appointment on Sep 12-13');
79
- [ { index: 18,
81
+ chrono.parse('An appointment on Sep 12-13');
82
+ /* [ { index: 18,
80
83
  text: 'Sep 12-13',
81
84
  tags: { ENMonthNameMiddleEndianParser: true },
82
85
  start:
@@ -84,7 +87,7 @@ Fri Sep 12 2014 12:00:00 GMT-0500 (CDT)
84
87
  impliedValues: [Object] },
85
88
  end:
86
89
  { knownValues: [Object],
87
- impliedValues: [Object] } } ]
90
+ impliedValues: [Object] } } ] */
88
91
  ```
89
92
 
90
93
  ### Reference Date
@@ -93,28 +96,52 @@ Today's "Friday" is different from last month's "Friday".
93
96
  The meaning of the referenced dates depends on when they are mentioned.
94
97
  Chrono lets you define a reference date using `chrono.parse(text, ref)` and `chrono.parseDate(text, ref)`.
95
98
 
96
- ```javascript
99
+ ```js
100
+ chrono.parseDate('Friday', new Date(2012, 7, 23));
101
+ // Fri Aug 24 2012 12:00:00 GMT+0700 (ICT)
102
+
103
+ chrono.parseDate('Friday', new Date(2012, 7, 1));
104
+ // Fri Aug 03 2012 12:00:00 GMT+0700 (ICT)
105
+ ```
106
+
107
+ ### Parsing Options
108
+
109
+ * `forwardDate` (boolean) to assume the results should happen after the reference date (forward into the future)
110
+
111
+ ```js
112
+ var referenceDate = new Date(2012, 7, 25);
113
+ // Sat Aug 25 2012 00:00:00 GMT+0900 -- The reference date was Saturday
114
+
115
+ chrono.parseDate('Friday', referenceDate);
116
+ // Fri Aug 24 2012 12:00:00 GMT+0900 (JST) -- The day before was Friday
117
+
118
+ chrono.parseDate('Friday', referenceDate, { forwardDate: true });
119
+ // Fri Aug 31 2012 12:00:00 GMT+0900 (JST) -- The following Friday
120
+ ```
121
+
122
+ * `timezones` (Map) to override Chrono's default timezone abbriviation mapping. The value should be the timezone offset in minutes (between -720 to 720).
97
123
 
98
- > chrono.parseDate('Friday', new Date(2012,7,23));
99
- Fri Aug 24 2012 12:00:00 GMT+0700 (ICT)
124
+ ```js
125
+ chrono.parse('Friday at 2 pm IST', refDate, { 'IST': 330 })[0].start.get('timezoneOffset');
126
+ // 330 (IST – India Standard Time +0530)
100
127
 
101
- > chrono.parseDate('Friday', new Date(2012,7,1));
102
- Fri Aug 03 2012 12:00:00 GMT+0700 (ICT)
128
+ chrono.parse('Friday at 2 pm IST', refDate, { 'IST': 60 })[0].start.get('timezoneOffset');
129
+ // 60 (IST - Irish Standard Time +0100)
103
130
  ```
104
131
 
105
132
  ### Detailed Parsed Results
106
133
 
107
134
  The function `chrono.parse` returns detailed parsing results as objects of class `chrono.ParsedResult`.
108
135
 
109
- ```javascript
110
- var results = chrono.parse('I have an appointment tomorrow from 10 to 11 AM')
136
+ ```js
137
+ var results = chrono.parse('I have an appointment tomorrow from 10 to 11 AM');
111
138
 
112
- results[0].index // 15
113
- results[0].text // 'tomorrow from 10 to 11 AM'
114
- results[0].ref // Sat Dec 13 2014 21:50:14 GMT-0600 (CST)
139
+ results[0].index; // 15
140
+ results[0].text; // 'tomorrow from 10 to 11 AM'
141
+ results[0].ref; // Sat Dec 13 2014 21:50:14 GMT-0600 (CST)
115
142
 
116
- results[0].start.date() // Sun Dec 14 2014 10:00:00 GMT-0600 (CST)
117
- results[0].end.date() // Sun Dec 14 2014 11:00:00 GMT-0600 (CST)
143
+ results[0].start.date(); // Sun Dec 14 2014 10:00:00 GMT-0600 (CST)
144
+ results[0].end.date(); // Sun Dec 14 2014 11:00:00 GMT-0600 (CST)
118
145
  ```
119
146
 
120
147
  #### ParsedResult
@@ -135,20 +162,20 @@ A group of found date and time components (year, month, hour, etc). ParsedCompon
135
162
  * `isCertain(component)` return true if the value of the component is known.
136
163
  * `date()` Create a javascript Date
137
164
 
138
- ```javascript
165
+ ```js
139
166
  // Remove the timezone offset of a parsed date and then create the Date object
140
- > var results = new chrono.parse('2016-03-08T01:16:07+02:00'); // Create new ParsedResult Object
141
- > results[0].start.assign('timezoneOffset', 0); // Change value in ParsedComponents Object 'start'
142
- > var d = results[0].start.date(); // Create a Date object
143
- > d.toString(); // Display resulting Date object
144
- 'Tue Mar 08 2016 01:16:07 GMT+0000 (GMT)'
167
+ var results = new chrono.parse('2016-03-08T01:16:07+02:00'); // Create new ParsedResult Object
168
+ results[0].start.assign('timezoneOffset', 0); // Change value in ParsedComponents Object 'start'
169
+
170
+ var d = results[0].start.date(); // Create a Date object
171
+ d.toString(); // 'Tue Mar 08 2016 01:16:07 GMT+0000 (GMT)'
145
172
  ```
146
173
 
147
174
  ### Strict vs Casual
148
175
 
149
176
  Chrono comes with `strict` mode that parse only formal date patterns.
150
177
 
151
- ```javascript
178
+ ```js
152
179
  // 'strict' mode
153
180
  chrono.strict.parseDate('Today'); // null
154
181
  chrono.strict.parseDate('Friday'); // null
@@ -158,10 +185,27 @@ chrono.strict.parseDate('Jul 01 2016'); // Fri Jul 01 2016 12:00:00 ...
158
185
  // 'casual' mode (default)
159
186
  chrono.parseDate('Today'); // Thu Jun 30 2016 12:00:00 ...
160
187
  chrono.casual.parseDate('Friday'); // Fri Jul 01 2016 12:00:00 ...
188
+ chrono.casual.parseDate('2016-07-01'); // Fri Jul 01 2016 12:00:00 ...
161
189
  chrono.casual.parseDate('Jul 01 2016'); // Fri Jul 01 2016 12:00:00 ...
162
- chrono.casual.parseDate('Friday'); // Fri Jul 01 2016 12:00:00 ...
163
190
  ```
164
191
 
192
+ ### Choosing Locale
193
+
194
+ By default, Chrono is configurated to parse different date formats from muliple languages out-off-box. However, by using predefined locale options, you can increase parsing accuracy.
195
+
196
+ Handling different date format for UK / US is a good example.
197
+
198
+ ```js
199
+ // default English (US)
200
+ chrono.parseDate('6/10/2018'); // Sun Jun 10 2018 12:00:00 ...
201
+ chrono.en.parseDate('6/10/2018'); // Sun Jun 10 2018 12:00:00 ...
202
+
203
+ // UK English or German
204
+ chrono.en_GB.parseDate('6/10/2018'); // Sat Oct 06 2018 12:00:00 ...
205
+ chrono.de.parseDate('6/10/2018'); // Sat Oct 06 2018 12:00:00 ...
206
+ ```
207
+
208
+ Current supported locale options are: `en`, `en_GB`, `de`, `es`, `fr`, `ja`
165
209
 
166
210
  ## Customize Chrono
167
211
 
@@ -171,11 +215,11 @@ Chrono’s extraction pipeline are mainly separated into 'parse' and ‘refine
171
215
 
172
216
  Parser is a module for low-level pattern-based parsing. Ideally, each parser should be designed to handle a single specific date format. User can add new type of parsers for supporting new date formats or languages.
173
217
 
174
- ```javascript
218
+ ```js
175
219
  var christmasParser = new chrono.Parser();
176
220
 
177
221
  // Provide search pattern
178
- christmasParser.pattern = function () { return /Christmas/i }
222
+ christmasParser.pattern = function () { return /Christmas/i; };
179
223
 
180
224
  // This function will be called when matched pattern is found
181
225
  christmasParser.extract = function(text, ref, match, opt) {
@@ -190,7 +234,7 @@ christmasParser.extract = function(text, ref, match, opt) {
190
234
  month: 12,
191
235
  }
192
236
  });
193
- }
237
+ };
194
238
 
195
239
  // Create a new custom Chrono. The initial pipeline 'option' can also be specified as
196
240
  // - new chrono.Chrono(exports.options.strictOption())
@@ -198,7 +242,7 @@ christmasParser.extract = function(text, ref, match, opt) {
198
242
  var custom = new chrono.Chrono();
199
243
  custom.parsers.push(christmasParser);
200
244
 
201
- custom.parseDate("I'll arrive at 2.30AM on Christmas night")
245
+ custom.parseDate("I'll arrive at 2.30AM on Christmas night");
202
246
  // Wed Dec 25 2013 02:30:00 GMT+0900 (JST)
203
247
 
204
248
  ```
@@ -212,21 +256,21 @@ To create a custom parser, override `pattern` and `extract` methods on an object
212
256
 
213
257
  Refiner is a higher level module for improving or manipulating the results. User can add a new type of refiner to customize Chrono's results or to add some custom logic to Chrono.
214
258
 
215
- ```javascript
259
+ ```js
216
260
  var guessPMRefiner = new chrono.Refiner();
217
261
  guessPMRefiner.refine = function(text, results, opt) {
218
262
  // If there is no AM/PM (meridiem) specified,
219
263
  // let all time between 1:00 - 4:00 be PM (13.00 - 16.00)
220
264
  results.forEach(function (result) {
221
- if (!result.start.isCertain('meridiem')
222
- && result.start.get('hour') >= 1 && result.start.get('hour') < 4) {
265
+ if (!result.start.isCertain('meridiem') &&
266
+ result.start.get('hour') >= 1 && result.start.get('hour') < 4) {
223
267
 
224
268
  result.start.assign('meridiem', 1);
225
269
  result.start.assign('hour', result.start.get('hour') + 12);
226
270
  }
227
271
  });
228
272
  return results;
229
- }
273
+ };
230
274
 
231
275
  // Create a new custom Chrono. The initial pipeline 'option' can also be specified as
232
276
  // - new chrono.Chrono(exports.options.strictOption())
@@ -252,30 +296,27 @@ This guide explains how to setup chrono project for prospective contributors.
252
296
 
253
297
  ```bash
254
298
  # Clone and install library
255
- git clone https://github.com/wanasit/chrono.git chrono
256
- cd chrono
257
- npm install
299
+ $ git clone https://github.com/wanasit/chrono.git chrono
300
+ $ cd chrono
301
+ $ npm install
258
302
 
259
- # Try running the test
260
- npm run test
261
- ```
262
-
263
- Chrono's source files is in `src` directory. The built bundle (`chrono.js` and `chrono.min.js`) can be built by [Browserify](http://browserify.org) on `src/chrono.js` using the following command
264
-
265
- ```
266
- npm run make
267
303
  ```
268
304
 
269
305
  Parsing date from text is complicated. Sometimes, a small change can have effects on unexpected places. So, Chrono is a heavily tested library. Commits that break a test shouldn't be allowed in any condition.
270
306
 
271
- Chrono's unit testing is based-on [Qunit](https://qunitjs.com/) and [Karma](https://github.com/karma-runner/karma). During the developement, I recommend running Karma test together with watchify.
307
+ Chrono's unit testing is based-on [Jest](https://facebook.github.io/jest/).
272
308
 
273
- ```
274
- # Start karma
275
- npm run karma
309
+ ```bash
310
+ # Run the test
311
+ $ npm run test
276
312
 
277
- # Start watch (run on a different terminal)
278
- npm run watch
313
+ # Run the test in watch mode
314
+ $ npm run watch
279
315
  ```
280
316
 
317
+ Chrono's source files is in `src` directory. The built bundle (`chrono.js` and `chrono.min.js`) can be built by [Browserify](http://browserify.org) on `src/chrono.js` using the following command
318
+
319
+ ```bash
320
+ $ npm run make
321
+ ```
281
322
 
package/bower.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "chrono",
3
3
  "main": "chrono.js",
4
- "version": "1.3.2",
4
+ "version": "1.3.10",
5
5
  "homepage": "https://github.com/wanasit/chrono",
6
6
  "authors": [
7
7
  "Wanasit Tanakitrungruang <berrysboy@gmail.com>"