chrono-node 1.3.5 → 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 (169) hide show
  1. package/README.md +107 -67
  2. package/bower.json +1 -1
  3. package/chrono.js +1249 -1076
  4. package/chrono.map.json +1 -1
  5. package/chrono.min.js +101 -101
  6. package/package.json +11 -15
  7. package/src/chrono.js +2 -3
  8. package/src/options.js +3 -3
  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 +0 -0
  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 +21 -23
  22. package/src/parsers/{EN → en}/ENMonthNameMiddleEndianParser.js +2 -2
  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 +0 -0
  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 -50
  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 +0 -0
  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 -130
  122. package/src/parsers/EN/ENTimeFromNowFormatParser.js +0 -119
  123. package/test/test_de.js +0 -62
  124. package/test/test_de_casual.js +0 -443
  125. package/test/test_de_dash.js +0 -17
  126. package/test/test_de_deadline.js +0 -255
  127. package/test/test_de_little_endian.js +0 -470
  128. package/test/test_de_time_ago.js +0 -324
  129. package/test/test_de_time_exp.js +0 -177
  130. package/test/test_de_weekday.js +0 -246
  131. package/test/test_en.js +0 -249
  132. package/test/test_en_casual.js +0 -448
  133. package/test/test_en_dash.js +0 -42
  134. package/test/test_en_deadline.js +0 -311
  135. package/test/test_en_inter_std.js +0 -272
  136. package/test/test_en_little_endian.js +0 -529
  137. package/test/test_en_middle_endian.js +0 -563
  138. package/test/test_en_month.js +0 -124
  139. package/test/test_en_option_forward.js +0 -167
  140. package/test/test_en_relative.js +0 -206
  141. package/test/test_en_slash.js +0 -370
  142. package/test/test_en_time_ago.js +0 -385
  143. package/test/test_en_time_exp.js +0 -663
  144. package/test/test_en_time_from_now.js +0 -345
  145. package/test/test_en_weekday.js +0 -312
  146. package/test/test_es_casual.js +0 -269
  147. package/test/test_es_dash.js +0 -24
  148. package/test/test_es_deadline.js +0 -96
  149. package/test/test_es_little_endian.js +0 -361
  150. package/test/test_es_slash.js +0 -35
  151. package/test/test_es_time_ago.js +0 -148
  152. package/test/test_es_time_exp.js +0 -251
  153. package/test/test_fr_casual.js +0 -465
  154. package/test/test_fr_dash.js +0 -37
  155. package/test/test_fr_deadline.js +0 -255
  156. package/test/test_fr_little_endian.js +0 -568
  157. package/test/test_fr_relative.js +0 -209
  158. package/test/test_fr_slash.js +0 -54
  159. package/test/test_fr_time_ago.js +0 -205
  160. package/test/test_fr_time_exp.js +0 -971
  161. package/test/test_fr_weekday.js +0 -211
  162. package/test/test_jp_casual.js +0 -62
  163. package/test/test_jp_standard.js +0 -181
  164. package/test/test_system.js +0 -178
  165. package/test/test_zh_hant_casual.js +0 -329
  166. package/test/test_zh_hant_date.js +0 -129
  167. package/test/test_zh_hant_deadline.js +0 -224
  168. package/test/test_zh_hant_time_exp.js +0 -210
  169. 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)
@@ -20,27 +20,29 @@ Chrono supports most date and time formats, such as :
20
20
  #### npm (recommended)
21
21
 
22
22
  Just run:
23
-
24
- $ npm i --save chrono-node
23
+ ```bash
24
+ $ npm i --save chrono-node
25
+ ```
25
26
 
26
27
  And start using chrono:
27
-
28
- var chrono = require('chrono-node')
29
- 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
+ ```
30
32
 
31
33
  #### Bower
32
34
 
33
35
  Prefer bower? You can do that, too:
34
36
 
35
37
  Just run:
36
-
37
- $ bower install chrono
38
-
38
+ ```bash
39
+ $ bower install chrono
40
+ ```
39
41
  And use:
40
42
 
41
43
  ```html
42
- <script src="bower_components/chrono/chrono.min.js"></script>
43
- <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>
44
46
  ```
45
47
 
46
48
 
@@ -50,7 +52,7 @@ Doing something else? No worries. Try these:
50
52
 
51
53
  Platform | Installation
52
54
  ---------|----
53
- 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>`
54
56
  Rails | Install from [Rails Assets] by adding this to your Gemfile:<br> `gem 'rails-assets-chrono', source: 'https://rails-assets.org'`
55
57
  Swift | Try using the community-made [chrono-swift] wrapper.
56
58
 
@@ -62,22 +64,22 @@ Swift | Try using the community-made [chrono-swift] wrapper.
62
64
 
63
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.
64
66
 
65
- ```
66
- browserify src/chrono.js --s chrono -o chrono.js
67
+ ```bash
68
+ $ browserify src/chrono.js --s chrono -o chrono.js
67
69
  ```
68
70
 
69
71
  ## Usage
70
72
 
71
73
  Simply pass a string to function `chrono.parseDate` or `chrono.parse`.
72
74
 
73
- ```javascript
74
- > var chrono = require('chrono-node')
75
+ ```js
76
+ var chrono = require('chrono-node');
75
77
 
76
- > chrono.parseDate('An appointment on Sep 12-13')
77
- 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)
78
80
 
79
- > chrono.parse('An appointment on Sep 12-13');
80
- [ { index: 18,
81
+ chrono.parse('An appointment on Sep 12-13');
82
+ /* [ { index: 18,
81
83
  text: 'Sep 12-13',
82
84
  tags: { ENMonthNameMiddleEndianParser: true },
83
85
  start:
@@ -85,7 +87,7 @@ Fri Sep 12 2014 12:00:00 GMT-0500 (CDT)
85
87
  impliedValues: [Object] },
86
88
  end:
87
89
  { knownValues: [Object],
88
- impliedValues: [Object] } } ]
90
+ impliedValues: [Object] } } ] */
89
91
  ```
90
92
 
91
93
  ### Reference Date
@@ -94,28 +96,52 @@ Today's "Friday" is different from last month's "Friday".
94
96
  The meaning of the referenced dates depends on when they are mentioned.
95
97
  Chrono lets you define a reference date using `chrono.parse(text, ref)` and `chrono.parseDate(text, ref)`.
96
98
 
97
- ```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).
98
123
 
99
- > chrono.parseDate('Friday', new Date(2012,7,23));
100
- 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)
101
127
 
102
- > chrono.parseDate('Friday', new Date(2012,7,1));
103
- 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)
104
130
  ```
105
131
 
106
132
  ### Detailed Parsed Results
107
133
 
108
134
  The function `chrono.parse` returns detailed parsing results as objects of class `chrono.ParsedResult`.
109
135
 
110
- ```javascript
111
- 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');
112
138
 
113
- results[0].index // 15
114
- results[0].text // 'tomorrow from 10 to 11 AM'
115
- 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)
116
142
 
117
- results[0].start.date() // Sun Dec 14 2014 10:00:00 GMT-0600 (CST)
118
- 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)
119
145
  ```
120
146
 
121
147
  #### ParsedResult
@@ -136,20 +162,20 @@ A group of found date and time components (year, month, hour, etc). ParsedCompon
136
162
  * `isCertain(component)` return true if the value of the component is known.
137
163
  * `date()` Create a javascript Date
138
164
 
139
- ```javascript
165
+ ```js
140
166
  // Remove the timezone offset of a parsed date and then create the Date object
141
- > var results = new chrono.parse('2016-03-08T01:16:07+02:00'); // Create new ParsedResult Object
142
- > results[0].start.assign('timezoneOffset', 0); // Change value in ParsedComponents Object 'start'
143
- > var d = results[0].start.date(); // Create a Date object
144
- > d.toString(); // Display resulting Date object
145
- '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)'
146
172
  ```
147
173
 
148
174
  ### Strict vs Casual
149
175
 
150
176
  Chrono comes with `strict` mode that parse only formal date patterns.
151
177
 
152
- ```javascript
178
+ ```js
153
179
  // 'strict' mode
154
180
  chrono.strict.parseDate('Today'); // null
155
181
  chrono.strict.parseDate('Friday'); // null
@@ -159,10 +185,27 @@ chrono.strict.parseDate('Jul 01 2016'); // Fri Jul 01 2016 12:00:00 ...
159
185
  // 'casual' mode (default)
160
186
  chrono.parseDate('Today'); // Thu Jun 30 2016 12:00:00 ...
161
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 ...
162
189
  chrono.casual.parseDate('Jul 01 2016'); // Fri Jul 01 2016 12:00:00 ...
163
- chrono.casual.parseDate('Friday'); // Fri Jul 01 2016 12:00:00 ...
164
190
  ```
165
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`
166
209
 
167
210
  ## Customize Chrono
168
211
 
@@ -172,11 +215,11 @@ Chrono’s extraction pipeline are mainly separated into 'parse' and ‘refine
172
215
 
173
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.
174
217
 
175
- ```javascript
218
+ ```js
176
219
  var christmasParser = new chrono.Parser();
177
220
 
178
221
  // Provide search pattern
179
- christmasParser.pattern = function () { return /Christmas/i }
222
+ christmasParser.pattern = function () { return /Christmas/i; };
180
223
 
181
224
  // This function will be called when matched pattern is found
182
225
  christmasParser.extract = function(text, ref, match, opt) {
@@ -191,7 +234,7 @@ christmasParser.extract = function(text, ref, match, opt) {
191
234
  month: 12,
192
235
  }
193
236
  });
194
- }
237
+ };
195
238
 
196
239
  // Create a new custom Chrono. The initial pipeline 'option' can also be specified as
197
240
  // - new chrono.Chrono(exports.options.strictOption())
@@ -199,7 +242,7 @@ christmasParser.extract = function(text, ref, match, opt) {
199
242
  var custom = new chrono.Chrono();
200
243
  custom.parsers.push(christmasParser);
201
244
 
202
- custom.parseDate("I'll arrive at 2.30AM on Christmas night")
245
+ custom.parseDate("I'll arrive at 2.30AM on Christmas night");
203
246
  // Wed Dec 25 2013 02:30:00 GMT+0900 (JST)
204
247
 
205
248
  ```
@@ -213,21 +256,21 @@ To create a custom parser, override `pattern` and `extract` methods on an object
213
256
 
214
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.
215
258
 
216
- ```javascript
259
+ ```js
217
260
  var guessPMRefiner = new chrono.Refiner();
218
261
  guessPMRefiner.refine = function(text, results, opt) {
219
262
  // If there is no AM/PM (meridiem) specified,
220
263
  // let all time between 1:00 - 4:00 be PM (13.00 - 16.00)
221
264
  results.forEach(function (result) {
222
- if (!result.start.isCertain('meridiem')
223
- && 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) {
224
267
 
225
268
  result.start.assign('meridiem', 1);
226
269
  result.start.assign('hour', result.start.get('hour') + 12);
227
270
  }
228
271
  });
229
272
  return results;
230
- }
273
+ };
231
274
 
232
275
  // Create a new custom Chrono. The initial pipeline 'option' can also be specified as
233
276
  // - new chrono.Chrono(exports.options.strictOption())
@@ -253,30 +296,27 @@ This guide explains how to setup chrono project for prospective contributors.
253
296
 
254
297
  ```bash
255
298
  # Clone and install library
256
- git clone https://github.com/wanasit/chrono.git chrono
257
- cd chrono
258
- npm install
299
+ $ git clone https://github.com/wanasit/chrono.git chrono
300
+ $ cd chrono
301
+ $ npm install
259
302
 
260
- # Try running the test
261
- npm run test
262
- ```
263
-
264
- 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
265
-
266
- ```
267
- npm run make
268
303
  ```
269
304
 
270
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.
271
306
 
272
- 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/).
273
308
 
274
- ```
275
- # Start karma
276
- npm run karma
309
+ ```bash
310
+ # Run the test
311
+ $ npm run test
277
312
 
278
- # Start watch (run on a different terminal)
279
- npm run watch
313
+ # Run the test in watch mode
314
+ $ npm run watch
280
315
  ```
281
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
+ ```
282
322
 
package/bower.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "chrono",
3
3
  "main": "chrono.js",
4
- "version": "1.3.5",
4
+ "version": "1.3.10",
5
5
  "homepage": "https://github.com/wanasit/chrono",
6
6
  "authors": [
7
7
  "Wanasit Tanakitrungruang <berrysboy@gmail.com>"