chrono-node 1.4.7 → 1.4.9

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 (69) hide show
  1. package/dist/chrono.js +711 -809
  2. package/dist/chrono.js.map +1 -1
  3. package/dist/chrono.min.js +1 -1
  4. package/dist/chrono.min.js.map +1 -1
  5. package/package.json +1 -1
  6. package/src/chrono.js +57 -59
  7. package/src/options.js +30 -29
  8. package/src/parsers/en/ENDeadlineFormatParser.js +9 -9
  9. package/src/result.js +119 -119
  10. package/test/de/de.test.js +36 -51
  11. package/test/de/de_casual.test.js +242 -141
  12. package/test/de/de_dash.test.js +5 -8
  13. package/test/de/de_deadline.test.js +151 -47
  14. package/test/de/de_little_endian.test.js +207 -58
  15. package/test/de/de_time_ago.test.js +167 -52
  16. package/test/de/de_time_exp.test.js +135 -121
  17. package/test/de/de_weekday.test.js +94 -31
  18. package/test/en/en.test.js +118 -89
  19. package/test/en/en_casual.test.js +149 -134
  20. package/test/en/en_dash.test.js +17 -11
  21. package/test/en/en_deadline.test.js +93 -69
  22. package/test/en/en_inter_std.test.js +28 -7
  23. package/test/en/en_little_endian.test.js +76 -26
  24. package/test/en/en_middle_endian.test.js +63 -21
  25. package/test/en/en_month.test.js +6 -2
  26. package/test/en/en_option_forward.test.js +120 -112
  27. package/test/en/en_relative.test.js +155 -172
  28. package/test/en/en_slash.test.js +156 -115
  29. package/test/en/en_time_ago.test.js +61 -21
  30. package/test/en/en_time_exp.test.js +228 -209
  31. package/test/en/en_time_from_now.test.js +70 -24
  32. package/test/en/en_time_later.test.js +16 -6
  33. package/test/en/en_weekday.test.js +39 -13
  34. package/test/es/es_casual.test.js +143 -120
  35. package/test/es/es_dash.test.js +7 -8
  36. package/test/es/es_deadline.test.js +69 -35
  37. package/test/es/es_little_endian.test.js +250 -145
  38. package/test/es/es_slash.test.js +17 -12
  39. package/test/es/es_time_ago.test.js +21 -7
  40. package/test/es/es_time_exp.test.js +154 -160
  41. package/test/fr/fr_casual.test.js +153 -124
  42. package/test/fr/fr_dash.test.js +13 -6
  43. package/test/fr/fr_deadline.test.js +163 -44
  44. package/test/fr/fr_little_endian.test.js +262 -81
  45. package/test/fr/fr_relative.test.js +188 -196
  46. package/test/fr/fr_slash.test.js +41 -14
  47. package/test/fr/fr_time_ago.test.js +30 -10
  48. package/test/fr/fr_time_exp.test.js +619 -567
  49. package/test/fr/fr_weekday.test.js +24 -8
  50. package/test/ja/ja_casual.test.js +41 -26
  51. package/test/ja/ja_standard.test.js +322 -207
  52. package/test/nl/nl.test.js +18 -20
  53. package/test/nl/nl_dash.test.js +26 -26
  54. package/test/nl/nl_little_endian.test.js +100 -51
  55. package/test/nl/nl_time_exp.test.js +37 -13
  56. package/test/nl/nl_weekday.test.js +39 -13
  57. package/test/pt/pt_casual.test.js +222 -156
  58. package/test/pt/pt_dash.test.js +7 -6
  59. package/test/pt/pt_deadline.test.js +51 -17
  60. package/test/pt/pt_little_endian.test.js +251 -144
  61. package/test/pt/pt_slash.test.js +38 -25
  62. package/test/pt/pt_time_ago.test.js +128 -80
  63. package/test/pt/pt_time_exp.test.js +191 -173
  64. package/test/test_util.js +1 -5
  65. package/test/zh/zh_hant_casual.test.js +184 -87
  66. package/test/zh/zh_hant_date.test.js +109 -75
  67. package/test/zh/zh_hant_deadline.test.js +131 -41
  68. package/test/zh/zh_hant_time_exp.test.js +184 -141
  69. package/test/zh/zh_hant_weekday.test.js +64 -22
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "testURL": "http://localhost/"
12
12
  },
13
13
  "license": "MIT",
14
- "version": "1.4.7",
14
+ "version": "1.4.9",
15
15
  "directories": {
16
16
  "source": "./src",
17
17
  "test": "./test"
package/src/chrono.js CHANGED
@@ -1,95 +1,93 @@
1
- export class Chrono {
2
1
 
3
- constructor(option) {
4
- option = option || exports.options.casualOption();
5
- this.parsers = new Object(option.parsers);
6
- this.refiners = new Object(option.refiners);
7
- }
2
+ var options = exports.options = require('./options');
8
3
 
9
- parse(text, refDate, opt) {
4
+ exports.parser = require('./parsers/parser');
5
+ exports.refiner = require('./refiners/refiner');
10
6
 
11
- refDate = refDate || new Date();
12
- opt = opt || {};
13
- opt.forwardDate = opt.forwardDate || opt.forwardDate;
7
+ exports.Parser = exports.parser.Parser;
8
+ exports.Refiner = exports.refiner.Refiner;
9
+ exports.Filter = exports.refiner.Filter;
14
10
 
15
- var allResults = [];
11
+ exports.ParsedResult = require('./result').ParsedResult;
12
+ exports.ParsedComponents = require('./result').ParsedComponents;
16
13
 
17
- this.parsers.forEach(function (parser) {
18
- var results = parser.execute(text, refDate, opt);
19
- allResults = allResults.concat(results);
20
- });
14
+ var Chrono = function(option) {
21
15
 
22
- allResults.sort(function(a, b) {
23
- return a.index - b.index;
24
- });
16
+ option = option || exports.options.casualOption();
17
+ this.parsers = new Object(option.parsers);
18
+ this.refiners = new Object(option.refiners);
19
+ };
25
20
 
26
- this.refiners.forEach(function (refiner) {
27
- allResults = refiner.refine(text, allResults, opt);
28
- });
29
21
 
30
- return allResults;
31
- }
22
+ Chrono.prototype.parse = function(text, refDate, opt) {
32
23
 
33
- parseDate(text, refDate, opt) {
34
- var results = this.parse(text, refDate, opt);
35
- if (results.length > 0) {
36
- return results[0].start.date();
37
- }
38
- return null;
39
- }
40
- }
24
+ refDate = refDate || new Date();
25
+ opt = opt || {};
26
+ opt.forwardDate = opt.forwardDate || opt.forwardDate;
27
+
28
+ var allResults = [];
41
29
 
42
- import * as _options from './options';
43
- import * as _parser from './parsers/parser';
44
- import * as _refiner from './refiners/refiner';
45
- import * as _result from './result';
30
+ this.parsers.forEach(function (parser) {
31
+ var results = parser.execute(text, refDate, opt);
32
+ allResults = allResults.concat(results);
33
+ });
46
34
 
47
- export const options = _options;
48
- export const parser = _parser;
49
- export const refiner = _refiner;
35
+ allResults.sort(function(a, b) {
36
+ return a.index - b.index;
37
+ });
50
38
 
51
- export const Parser = parser.Parser;
52
- export const Refiner = refiner.Refiner;
53
- export const Filter = refiner.Filter;
39
+ this.refiners.forEach(function (refiner) {
40
+ allResults = refiner.refine(text, allResults, opt);
41
+ });
42
+
43
+ return allResults;
44
+ };
54
45
 
55
- export const ParsedResult = _result.ParsedResult;
56
- export const ParsedComponents = _result.ParsedComponents;
57
46
 
58
- export const strict = new Chrono( options.strictOption() );
59
- export const casual = new Chrono( options.casualOption() );
47
+ Chrono.prototype.parseDate = function(text, refDate, opt) {
48
+ var results = this.parse(text, refDate, opt);
49
+ if (results.length > 0) {
50
+ return results[0].start.date();
51
+ }
52
+ return null;
53
+ };
54
+
55
+ exports.Chrono = Chrono;
56
+ exports.strict = new Chrono( options.strictOption() );
57
+ exports.casual = new Chrono( options.casualOption() );
60
58
 
61
- export const en = new Chrono( options.mergeOptions([
59
+ exports.en = new Chrono( options.mergeOptions([
62
60
  options.en.casual, options.commonPostProcessing]));
63
61
 
64
- export const en_GB = new Chrono( options.mergeOptions([
62
+ exports.en_GB = new Chrono( options.mergeOptions([
65
63
  options.en_GB.casual, options.commonPostProcessing]));
66
64
 
67
- export const de = new Chrono( options.mergeOptions([
65
+ exports.de = new Chrono( options.mergeOptions([
68
66
  options.de.casual, options.en, options.commonPostProcessing]));
69
67
 
70
- export const nl = new Chrono( options.mergeOptions([
68
+ exports.nl = new Chrono( options.mergeOptions([
71
69
  options.nl.casual, options.en, options.commonPostProcessing]));
72
70
 
73
- export const pt = new Chrono( options.mergeOptions([
71
+ exports.pt = new Chrono( options.mergeOptions([
74
72
  options.pt.casual, options.en, options.commonPostProcessing]));
75
73
 
76
- export const es = new Chrono( options.mergeOptions([
74
+ exports.es = new Chrono( options.mergeOptions([
77
75
  options.es.casual, options.en, options.commonPostProcessing]));
78
76
 
79
- export const fr = new Chrono( options.mergeOptions([
77
+ exports.fr = new Chrono( options.mergeOptions([
80
78
  options.fr.casual, options.en, options.commonPostProcessing]));
81
79
 
82
- export const ja = new Chrono( options.mergeOptions([
80
+ exports.ja = new Chrono( options.mergeOptions([
83
81
  options.ja.casual, options.en, options.commonPostProcessing]));
84
82
 
85
83
 
86
- export function parse () {
87
- return casual.parse.apply(casual, arguments);
88
- }
84
+ exports.parse = function () {
85
+ return exports.casual.parse.apply(exports.casual, arguments);
86
+ };
89
87
 
90
- export function parseDate() {
91
- return casual.parseDate.apply(casual, arguments);
92
- }
88
+ exports.parseDate = function () {
89
+ return exports.casual.parseDate.apply(exports.casual, arguments);
90
+ };
93
91
 
94
92
 
95
93
 
package/src/options.js CHANGED
@@ -1,7 +1,8 @@
1
- import * as parser from './parsers/parser';
2
- import * as refiner from './refiners/refiner';
1
+ var parser = require('./parsers/parser');
2
+ var refiner = require('./refiners/refiner');
3
3
 
4
- export function mergeOptions(options) {
4
+
5
+ exports.mergeOptions = function(options) {
5
6
 
6
7
  var addedTypes = {};
7
8
  var mergedOption = {
@@ -35,10 +36,10 @@ export function mergeOptions(options) {
35
36
  });
36
37
 
37
38
  return mergedOption;
38
- }
39
+ };
39
40
 
40
41
 
41
- export function commonPostProcessing() {
42
+ exports.commonPostProcessing = function() {
42
43
  return {
43
44
  refiners: [
44
45
  // These should be after all other refiners
@@ -47,12 +48,12 @@ export function commonPostProcessing() {
47
48
  new refiner.UnlikelyFormatFilter()
48
49
  ]
49
50
  }
50
- }
51
+ };
51
52
 
52
53
 
53
54
  // -------------------------------------------------------------
54
55
 
55
- export function strictOption() {
56
+ exports.strictOption = function () {
56
57
  var strictConfig = {
57
58
  strict: true
58
59
  };
@@ -68,9 +69,9 @@ export function strictOption() {
68
69
  exports.zh,
69
70
  exports.commonPostProcessing
70
71
  ]);
71
- }
72
+ };
72
73
 
73
- export function casualOption() {
74
+ exports.casualOption = function () {
74
75
  return exports.mergeOptions([
75
76
  exports.en.casual,
76
77
  // Some German abbriviate overlap with common English
@@ -83,11 +84,11 @@ export function casualOption() {
83
84
  exports.zh,
84
85
  exports.commonPostProcessing
85
86
  ]);
86
- }
87
+ };
87
88
 
88
89
  // -------------------------------------------------------------
89
90
 
90
- export const de = function(config) {
91
+ exports.de = function(config) {
91
92
  return {
92
93
  parsers: [
93
94
  new parser.DEDeadlineFormatParser(config),
@@ -106,7 +107,7 @@ export const de = function(config) {
106
107
  }
107
108
  };
108
109
 
109
- de.casual = function() {
110
+ exports.de.casual = function() {
110
111
  var option = exports.de({
111
112
  strict: false
112
113
  });
@@ -119,7 +120,7 @@ de.casual = function() {
119
120
 
120
121
  // -------------------------------------------------------------
121
122
 
122
- export const nl = function(config) {
123
+ exports.nl = function(config) {
123
124
  return {
124
125
  parsers: [
125
126
  new parser.NLMonthNameLittleEndianParser(config),
@@ -136,7 +137,7 @@ export const nl = function(config) {
136
137
  }
137
138
  };
138
139
 
139
- nl.casual = function() {
140
+ exports.nl.casual = function() {
140
141
  var option = exports.nl({
141
142
  strict: false
142
143
  });
@@ -151,7 +152,7 @@ nl.casual = function() {
151
152
  // -------------------------------------------------------------
152
153
 
153
154
 
154
- export const en = function(config) {
155
+ exports.en = function(config) {
155
156
  return {
156
157
  parsers: [
157
158
  new parser.ENISOFormatParser(config),
@@ -178,7 +179,7 @@ export const en = function(config) {
178
179
  }
179
180
  };
180
181
 
181
- en.casual = function(config) {
182
+ exports.en.casual = function(config) {
182
183
  config = config || {};
183
184
  config.strict = false;
184
185
  var option = exports.en(config);
@@ -192,21 +193,21 @@ en.casual = function(config) {
192
193
  };
193
194
 
194
195
 
195
- export const en_GB = function(config) {
196
+ exports.en_GB = function(config) {
196
197
  config = config || {};
197
198
  config.littleEndian = true;
198
199
  return exports.en(config);
199
- };
200
+ }
200
201
 
201
- en_GB.casual = function(config) {
202
+ exports.en_GB.casual = function(config) {
202
203
  config = config || {};
203
204
  config.littleEndian = true;
204
205
  return exports.en.casual(config);
205
- };
206
+ }
206
207
 
207
208
  // -------------------------------------------------------------
208
209
 
209
- export const ja = function() {
210
+ exports.ja = function() {
210
211
  return {
211
212
  parsers: [
212
213
  new parser.JPStandardParser()
@@ -219,7 +220,7 @@ export const ja = function() {
219
220
  }
220
221
  };
221
222
 
222
- ja.casual = function() {
223
+ exports.ja.casual = function() {
223
224
  var option = exports.ja();
224
225
  option.parsers.unshift(new parser.JPCasualDateParser());
225
226
  return option;
@@ -228,7 +229,7 @@ ja.casual = function() {
228
229
  // -------------------------------------------------------------
229
230
 
230
231
 
231
- export const pt = function(config) {
232
+ exports.pt = function(config) {
232
233
  return {
233
234
  parsers: [
234
235
  new parser.PTTimeAgoFormatParser(config),
@@ -244,7 +245,7 @@ export const pt = function(config) {
244
245
  }
245
246
  };
246
247
 
247
- pt.casual = function() {
248
+ exports.pt.casual = function() {
248
249
  var option = exports.pt({
249
250
  strict: false
250
251
  });
@@ -257,7 +258,7 @@ pt.casual = function() {
257
258
  // -------------------------------------------------------------
258
259
 
259
260
 
260
- export const es = function(config) {
261
+ exports.es = function(config) {
261
262
  return {
262
263
  parsers: [
263
264
  new parser.ESTimeAgoFormatParser(config),
@@ -273,7 +274,7 @@ export const es = function(config) {
273
274
  }
274
275
  };
275
276
 
276
- es.casual = function() {
277
+ exports.es.casual = function() {
277
278
  var option = exports.es({
278
279
  strict: false
279
280
  });
@@ -286,7 +287,7 @@ es.casual = function() {
286
287
 
287
288
  // -------------------------------------------------------------
288
289
 
289
- export const fr = function(config) {
290
+ exports.fr = function(config) {
290
291
  return {
291
292
  parsers: [
292
293
  new parser.FRDeadlineFormatParser(config),
@@ -304,7 +305,7 @@ export const fr = function(config) {
304
305
  }
305
306
  };
306
307
 
307
- fr.casual = function() {
308
+ exports.fr.casual = function() {
308
309
  var option = exports.fr({
309
310
  strict: false
310
311
  });
@@ -318,7 +319,7 @@ fr.casual = function() {
318
319
 
319
320
  // -------------------------------------------------------------
320
321
 
321
- export const zh = function() {
322
+ exports.zh = function() {
322
323
  return {
323
324
  parsers: [
324
325
  new parser.ZHHantDateParser(),
@@ -62,9 +62,9 @@ exports.Parser = function ENDeadlineFormatParser(){
62
62
  date = date.add(num, 'year');
63
63
  }
64
64
 
65
- result.start.imply('year', date.year());
66
- result.start.imply('month', date.month() + 1);
67
- result.start.imply('day', date.date());
65
+ result.start.assign('year', date.year());
66
+ result.start.assign('month', date.month() + 1);
67
+ result.start.assign('day', date.date());
68
68
  return result;
69
69
  }
70
70
 
@@ -81,12 +81,12 @@ exports.Parser = function ENDeadlineFormatParser(){
81
81
  date = date.add(num, 'second');
82
82
  }
83
83
 
84
- result.start.imply('year', date.year());
85
- result.start.imply('month', date.month() + 1);
86
- result.start.imply('day', date.date());
87
- result.start.imply('hour', date.hour());
88
- result.start.imply('minute', date.minute());
89
- result.start.imply('second', date.second());
84
+ result.start.assign('year', date.year());
85
+ result.start.assign('month', date.month() + 1);
86
+ result.start.assign('day', date.date());
87
+ result.start.assign('hour', date.hour());
88
+ result.start.assign('minute', date.minute());
89
+ result.start.assign('second', date.second());
90
90
  result.tags['ENDeadlineFormatParser'] = true;
91
91
  return result;
92
92
  };
package/src/result.js CHANGED
@@ -1,155 +1,155 @@
1
- import dayjs from 'dayjs';
1
+ const dayjs = require('dayjs');
2
2
 
3
- export class ParsedResult {
3
+ function ParsedResult(result){
4
+ result = result || {};
4
5
 
5
- constructor(result) {
6
- result = result || {};
6
+ this.ref = result.ref;
7
+ this.index = result.index;
8
+ this.text = result.text;
9
+ this.tags = result.tags || {};
7
10
 
8
- this.ref = result.ref;
9
- this.index = result.index;
10
- this.text = result.text;
11
- this.tags = result.tags || {};
12
-
13
- this.start = new ParsedComponents(result.start, result.ref);
14
-
15
- if(result.end){
16
- this.end = new ParsedComponents(result.end, result.ref);
17
- }
11
+ this.start = new ParsedComponents(result.start, result.ref)
12
+ if(result.end){
13
+ this.end = new ParsedComponents(result.end, result.ref)
18
14
  }
15
+ }
19
16
 
20
- clone() {
21
- var result = new ParsedResult(this);
22
- result.tags = JSON.parse(JSON.stringify(this.tags));
23
- result.start = this.start.clone();
24
- if (this.end) {
25
- result.end = this.end.clone();
26
- }
27
-
28
- return result
17
+ ParsedResult.prototype.clone = function() {
18
+ var result = new ParsedResult(this);
19
+ result.tags = JSON.parse(JSON.stringify(this.tags));
20
+ result.start = this.start.clone();
21
+ if (this.end) {
22
+ result.end = this.end.clone();
29
23
  }
30
24
 
31
- date() {
32
- return this.start.date();
33
- }
25
+ return result
26
+ }
34
27
 
35
- hasPossibleDates() {
36
- return this.start.isPossibleDate() && (!this.end || this.end.isPossibleDate());
37
- }
28
+ ParsedResult.prototype.date = function() {
29
+ return this.start.date();
30
+ }
38
31
 
39
- isOnlyWeekday() {
40
- return this.start.isOnlyWeekdayComponent();
41
- }
32
+ ParsedResult.prototype.hasPossibleDates = function() {
33
+ return this.start.isPossibleDate() && (!this.end || this.end.isPossibleDate());
34
+ }
42
35
 
43
- isOnlyDayMonth() {
44
- return this.start.isOnlyDayMonthComponent();
45
- }
36
+ ParsedResult.prototype.isOnlyWeekday = function() {
37
+ return this.start.isOnlyWeekdayComponent();
46
38
  }
47
39
 
48
- export class ParsedComponents {
40
+ ParsedResult.prototype.isOnlyDayMonth = function() {
41
+ return this.start.isOnlyDayMonthComponent();
42
+ }
49
43
 
50
- constructor(components, ref) {
51
- this.knownValues = {};
52
- this.impliedValues = {};
44
+ function ParsedComponents (components, ref){
53
45
 
54
- if (components) {
55
- for (let key in components) {
56
- this.knownValues[key] = components[key];
57
- }
58
- }
46
+ this.knownValues = {};
47
+ this.impliedValues = {};
59
48
 
60
- if (ref) {
61
- ref = dayjs(ref);
62
- this.imply('day', ref.date());
63
- this.imply('month', ref.month() + 1);
64
- this.imply('year', ref.year())
49
+ if (components) {
50
+ for (let key in components) {
51
+ this.knownValues[key] = components[key];
65
52
  }
66
-
67
-
68
- this.imply('hour', 12);
69
- this.imply('minute', 0);
70
- this.imply('second', 0);
71
- this.imply('millisecond', 0);
72
53
  }
73
54
 
74
- get(component) {
75
- if (component in this.knownValues) return this.knownValues[component];
76
- if (component in this.impliedValues) return this.impliedValues[component];
55
+ if (ref) {
56
+ ref = dayjs(ref);
57
+ this.imply('day', ref.date())
58
+ this.imply('month', ref.month() + 1)
59
+ this.imply('year', ref.year())
77
60
  }
61
+
78
62
 
79
- isCertain(component) {
80
- return component in this.knownValues;
81
- }
63
+ this.imply('hour', 12);
64
+ this.imply('minute', 0);
65
+ this.imply('second', 0);
66
+ this.imply('millisecond', 0);
67
+ }
82
68
 
83
- imply(component, value) {
84
- if (component in this.knownValues) return;
85
- this.impliedValues[component] = value;
86
- }
69
+ ParsedComponents.prototype.clone = function () {
70
+ var component = new ParsedComponents();
71
+ component.knownValues = JSON.parse(JSON.stringify(this.knownValues));
72
+ component.impliedValues = JSON.parse(JSON.stringify(this.impliedValues));
73
+ return component;
74
+ };
87
75
 
88
- assign(component, value) {
89
- this.knownValues[component] = value;
90
- delete this.impliedValues[component];
91
- }
76
+ ParsedComponents.prototype.get = function(component, value) {
77
+ if (component in this.knownValues) return this.knownValues[component];
78
+ if (component in this.impliedValues) return this.impliedValues[component];
79
+ };
92
80
 
93
- clone() {
94
- const component = new ParsedComponents();
95
- component.knownValues = JSON.parse(JSON.stringify(this.knownValues));
96
- component.impliedValues = JSON.parse(JSON.stringify(this.impliedValues));
97
- return component;
98
- }
81
+ ParsedComponents.prototype.assign = function(component, value) {
82
+ this.knownValues[component] = value;
83
+ delete this.impliedValues[component];
84
+ };
99
85
 
100
- isOnlyWeekdayComponent() {
101
- return this.isCertain('weekday') && !this.isCertain('day') && !this.isCertain('month');
102
- }
86
+ ParsedComponents.prototype.imply = function(component, value) {
87
+ if (component in this.knownValues) return;
88
+ this.impliedValues[component] = value;
89
+ };
103
90
 
104
- isOnlyDayMonthComponent() {
105
- return this.isCertain('day') && this.isCertain('month') && !this.isCertain('year');
106
- }
91
+ ParsedComponents.prototype.isCertain = function(component) {
92
+ return component in this.knownValues;
93
+ };
107
94
 
108
- isPossibleDate() {
109
- var dateMoment = this.dayjs();
110
- if (this.isCertain('timezoneOffset')) {
111
- const adjustTimezoneOffset = this.get('timezoneOffset') - dateMoment.utcOffset();
112
- dateMoment = dateMoment.add(adjustTimezoneOffset, 'minutes');
113
- }
95
+ ParsedComponents.prototype.isOnlyWeekdayComponent = function() {
96
+ return this.isCertain('weekday') && !this.isCertain('day') && !this.isCertain('month');
97
+ };
114
98
 
115
- if (dateMoment.get('year') != this.get('year')) return false;
116
- if (dateMoment.get('month') != this.get('month')-1) return false;
117
- if (dateMoment.get('date') != this.get('day')) return false;
118
- if (dateMoment.get('hour') != this.get('hour')) return false;
119
- if (dateMoment.get('minute') != this.get('minute')) return false;
99
+ ParsedComponents.prototype.isOnlyDayMonthComponent = function() {
100
+ return this.isCertain('day') && this.isCertain('month') && !this.isCertain('year');
101
+ };
120
102
 
121
- return true;
103
+ ParsedComponents.prototype.isPossibleDate = function() {
104
+ var dateMoment = this.dayjs();
105
+ if (this.isCertain('timezoneOffset')) {
106
+ const adjustTimezoneOffset = this.get('timezoneOffset') - dateMoment.utcOffset();
107
+ dateMoment = dateMoment.add(adjustTimezoneOffset, 'minutes');
122
108
  }
123
109
 
124
- date() {
125
- const result = this.dayjs();
126
- return result.toDate();
127
- }
110
+ if (dateMoment.get('year') != this.get('year')) return false;
111
+ if (dateMoment.get('month') != this.get('month')-1) return false;
112
+ if (dateMoment.get('date') != this.get('day')) return false;
113
+ if (dateMoment.get('hour') != this.get('hour')) return false;
114
+ if (dateMoment.get('minute') != this.get('minute')) return false;
128
115
 
129
- dayjs() {
130
- var result = dayjs();
116
+ return true;
117
+ };
131
118
 
132
- result = result.year(this.get('year'));
133
- result = result.month(this.get('month') - 1);
134
- result = result.date(this.get('day'));
135
- result = result.hour(this.get('hour'));
136
- result = result.minute(this.get('minute'));
137
- result = result.second(this.get('second'));
138
- result = result.millisecond(this.get('millisecond'));
119
+ ParsedComponents.prototype.date = function() {
120
+ var result = this.dayjs();
121
+ return result.toDate();
122
+ };
139
123
 
140
- // Javascript Date Object return minus timezone offset
141
- var currentTimezoneOffset = result.utcOffset();
142
- var targetTimezoneOffset = this.get('timezoneOffset') !== undefined ?
143
- this.get('timezoneOffset') : currentTimezoneOffset;
144
124
 
145
- var adjustTimezoneOffset = targetTimezoneOffset - currentTimezoneOffset;
146
- result = result.add(-adjustTimezoneOffset, 'minute');
125
+ ParsedComponents.prototype.dayjs = function() {
126
+ var result = dayjs();
147
127
 
148
- return result;
149
- }
128
+ result = result.year(this.get('year'));
129
+ result = result.month(this.get('month') - 1);
130
+ result = result.date(this.get('day'));
131
+ result = result.hour(this.get('hour'));
132
+ result = result.minute(this.get('minute'));
133
+ result = result.second(this.get('second'));
134
+ result = result.millisecond(this.get('millisecond'));
150
135
 
151
- moment() {
152
- // Keep for compatibility
153
- return this.dayjs();
154
- }
155
- }
136
+ // Javascript Date Object return minus timezone offset
137
+ var currentTimezoneOffset = result.utcOffset();
138
+ var targetTimezoneOffset = this.get('timezoneOffset') !== undefined ?
139
+ this.get('timezoneOffset') : currentTimezoneOffset;
140
+
141
+ var adjustTimezoneOffset = targetTimezoneOffset - currentTimezoneOffset;
142
+ result = result.add(-adjustTimezoneOffset, 'minute');
143
+
144
+ return result;
145
+ };
146
+
147
+ ParsedComponents.prototype.moment = function() {
148
+ // Keep for compatibility
149
+ return this.dayjs();
150
+ };
151
+
152
+
153
+
154
+ exports.ParsedComponents = ParsedComponents;
155
+ exports.ParsedResult = ParsedResult;