@zentered/issue-forms-body-parser 1.1.3 → 1.1.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/dist/index.js +3 -2
- package/package.json +1 -1
- package/src/parse.js +3 -2
- package/test/parse-issue.test.js +1 -1
package/dist/index.js
CHANGED
|
@@ -53201,17 +53201,18 @@ const commonDateFormats = [
|
|
|
53201
53201
|
'dd.MM.yy'
|
|
53202
53202
|
]
|
|
53203
53203
|
|
|
53204
|
-
const commonTimeFormats = ['HH:mm', 'hh:mm a', 'hh:mm A']
|
|
53204
|
+
const commonTimeFormats = ['HH:mm', 'HH.mm', 'hh:mm a', 'hh:mm A']
|
|
53205
53205
|
|
|
53206
53206
|
function parse_parseDate(text) {
|
|
53207
53207
|
const match = commonDateFormats.map((format) => {
|
|
53208
53208
|
return (0,date_fns.isMatch)(text, format)
|
|
53209
53209
|
})
|
|
53210
53210
|
if (match.indexOf(true) > -1) {
|
|
53211
|
-
|
|
53211
|
+
const date = zonedTimeToUtc(
|
|
53212
53212
|
(0,date_fns.parse)(text, commonDateFormats[match.indexOf(true)], new Date()),
|
|
53213
53213
|
loc
|
|
53214
53214
|
).toJSON()
|
|
53215
|
+
return date.split('T')[0]
|
|
53215
53216
|
} else {
|
|
53216
53217
|
return null
|
|
53217
53218
|
}
|
package/package.json
CHANGED
package/src/parse.js
CHANGED
|
@@ -20,17 +20,18 @@ const commonDateFormats = [
|
|
|
20
20
|
'dd.MM.yy'
|
|
21
21
|
]
|
|
22
22
|
|
|
23
|
-
const commonTimeFormats = ['HH:mm', 'hh:mm a', 'hh:mm A']
|
|
23
|
+
const commonTimeFormats = ['HH:mm', 'HH.mm', 'hh:mm a', 'hh:mm A']
|
|
24
24
|
|
|
25
25
|
function parseDate(text) {
|
|
26
26
|
const match = commonDateFormats.map((format) => {
|
|
27
27
|
return isMatch(text, format)
|
|
28
28
|
})
|
|
29
29
|
if (match.indexOf(true) > -1) {
|
|
30
|
-
|
|
30
|
+
const date = zonedTimeToUtc(
|
|
31
31
|
parse(text, commonDateFormats[match.indexOf(true)], new Date()),
|
|
32
32
|
loc
|
|
33
33
|
).toJSON()
|
|
34
|
+
return date.split('T')[0]
|
|
34
35
|
} else {
|
|
35
36
|
return null
|
|
36
37
|
}
|
package/test/parse-issue.test.js
CHANGED
|
@@ -23,7 +23,7 @@ test('parse(md) should parse GitHub Issue Form data into useful, structured data
|
|
|
23
23
|
id: 'date',
|
|
24
24
|
title: 'Date',
|
|
25
25
|
text: '11.03.2022\n',
|
|
26
|
-
date: '2022-03-
|
|
26
|
+
date: '2022-03-11'
|
|
27
27
|
},
|
|
28
28
|
{ id: 'time', title: 'Time', text: '16:00\n', time: '16:00' },
|
|
29
29
|
{ id: 'duration', title: 'Duration', text: '2h\n' },
|