MCPcopy Create free account
hub / github.com/zxlie/FeHelper / parseEventDateTime

Function parseEventDateTime

apps/qr-code/fh.qr-content-utils.js:296–312  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

294}
295
296function parseEventDateTime(value) {
297 const text = cleanFieldValue(value);
298 let match = text.match(/^(\d{4})(\d{2})(\d{2})(?:T(\d{2})(\d{2})(\d{2})?)?$/);
299 if (match) {
300 return match[4]
301 ? {value: `${match[1]}${match[2]}${match[3]}T${match[4]}${match[5]}${match[6] || '00'}`, type: 'date-time'}
302 : {value: `${match[1]}${match[2]}${match[3]}`, type: 'date'};
303 }
304 match = text.match(/^(\d{4})[-/.年](\d{1,2})[-/.月](\d{1,2})日?(?:\s+(\d{1,2})(?::|点)(\d{1,2})?(?::(\d{1,2}))?)?$/);
305 if (!match) return null;
306 const date = `${match[1]}${pad2(match[2])}${pad2(match[3])}`;
307 if (!match[4]) return {value: date, type: 'date'};
308 return {
309 value: `${date}T${pad2(match[4])}${pad2(match[5] || '0')}${pad2(match[6] || '0')}`,
310 type: 'date-time'
311 };
312}
313
314function formatDateStamp(date = new Date()) {
315 return `${date.getUTCFullYear()}${pad2(date.getUTCMonth() + 1)}${pad2(date.getUTCDate())}T${pad2(date.getUTCHours())}${pad2(date.getUTCMinutes())}${pad2(date.getUTCSeconds())}Z`;

Callers 2

formatEventQrContentFunction · 0.85

Calls 2

cleanFieldValueFunction · 0.85
pad2Function · 0.85

Tested by

no test coverage detected