vis-chronicle 1.2.3 → 1.2.4
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.
- package/package.json +1 -1
- package/src/relativeDates.js +18 -2
- package/src/wikidata.js +1 -1
package/package.json
CHANGED
package/src/relativeDates.js
CHANGED
|
@@ -56,6 +56,23 @@ module.exports = function flattenRelativeDate(wikidataCache, dateString)
|
|
|
56
56
|
const cacheEntry = wikidataCache[relSplit[0]]
|
|
57
57
|
if (relSplit.length > 1)
|
|
58
58
|
{
|
|
59
|
+
// break up operators
|
|
60
|
+
const dateOperators = []
|
|
61
|
+
var opStartIndex = 0
|
|
62
|
+
const operatorString = relSplit[1]
|
|
63
|
+
if (operatorString.length > 0)
|
|
64
|
+
{
|
|
65
|
+
for (var i = 1; i < operatorString.length; i++)
|
|
66
|
+
{
|
|
67
|
+
if (operatorString[i] == '+' || operatorString[i] == '>')
|
|
68
|
+
{
|
|
69
|
+
dateOperators.push(operatorString.substring(opStartIndex, i))
|
|
70
|
+
opStartIndex = i
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
dateOperators.push(operatorString.substring(opStartIndex, i))
|
|
74
|
+
}
|
|
75
|
+
|
|
59
76
|
// handle relative segments of date
|
|
60
77
|
// About precision:
|
|
61
78
|
// - The actual value is assumed to lie in a range the size of the precision
|
|
@@ -64,9 +81,8 @@ module.exports = function flattenRelativeDate(wikidataCache, dateString)
|
|
|
64
81
|
var momentDate = moment(cacheEntry.value, 'YYYYYY-MM-DDThh:mm:ss')
|
|
65
82
|
var precision = cacheEntry.precision
|
|
66
83
|
//console.log(momentDate)
|
|
67
|
-
for (
|
|
84
|
+
for (const component of dateOperators)
|
|
68
85
|
{
|
|
69
|
-
const component = relSplit[i]
|
|
70
86
|
if (!component)
|
|
71
87
|
{
|
|
72
88
|
// empty group from regex
|
package/src/wikidata.js
CHANGED
|
@@ -41,7 +41,7 @@ const wikidata = module.exports = {
|
|
|
41
41
|
rankNormal: "http://wikiba.se/ontology#NormalRank",
|
|
42
42
|
rankPreferred: "http://wikiba.se/ontology#PreferredRank",
|
|
43
43
|
|
|
44
|
-
pathQueryRegex: /^(Q[0-9]+(?::P[0-9]+)?(?::Q[0-9]+:P[0-9]+)?)([\+>](?:[A-Za-z]+(?:![0-9]+)?|P\-?[0-9A-Z]+)+)
|
|
44
|
+
pathQueryRegex: /^(Q[0-9]+(?::P[0-9]+)?(?::Q[0-9]+:P[0-9]+)?)((?:[\+>](?:[A-Za-z]+(?:![0-9]+)?|P\-?[0-9A-Z]+)+)*)$/,
|
|
45
45
|
|
|
46
46
|
initialize: function()
|
|
47
47
|
{
|