Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/rtail-expressjs/node_modules/chrono-node/src/parsers/en/ drwxr-xr-x | |
| Viewing file: Select action/file-type: /*
ISO 8601
http://www.w3.org/TR/NOTE-datetime
- YYYY-MM-DD
- YYYY-MM-DDThh:mmTZD
- YYYY-MM-DDThh:mm:ssTZD
- YYYY-MM-DDThh:mm:ss.sTZD
- TZD = (Z or +hh:mm or -hh:mm)
*/
const dayjs = require('dayjs');
var Parser = require('../parser').Parser;
var ParsedResult = require('../../result').ParsedResult;
var PATTERN = new RegExp('(\\W|^)'
+ '([0-9]{4})\\-([0-9]{1,2})\\-([0-9]{1,2})'
+ '(?:T' //..
+ '([0-9]{1,2}):([0-9]{1,2})' // hh:mm
+ '(?::([0-9]{1,2})(?:\\.(\\d{1,4}))?)?' // :ss.s
+ '(?:Z|([+-]\\d{2}):?(\\d{2})?)?' // TZD (Z or ±hh:mm or ±hhmm or ±hh)
+ ')?' //..
+ '(?=\\W|$)', 'i');
var YEAR_NUMBER_GROUP = 2;
var MONTH_NUMBER_GROUP = 3;
var DATE_NUMBER_GROUP = 4;
var HOUR_NUMBER_GROUP = 5;
var MINUTE_NUMBER_GROUP = 6;
var SECOND_NUMBER_GROUP = 7;
var MILLISECOND_NUMBER_GROUP = 8;
var TZD_HOUR_OFFSET_GROUP = 9;
var TZD_MINUTE_OFFSET_GROUP = 10;
exports.Parser = function ENISOFormatParser(){
Parser.apply(this, arguments);
this.pattern = function() { return PATTERN; }
this.extract = function(text, ref, match, opt){
var text = match[0].substr(match[1].length);
var index = match.index + match[1].length;
var result = new ParsedResult({
text: text,
index: index,
ref: ref,
})
result.start.assign('year', parseInt(match[YEAR_NUMBER_GROUP]));
result.start.assign('month', parseInt(match[MONTH_NUMBER_GROUP]));
result.start.assign('day', parseInt(match[DATE_NUMBER_GROUP]));
if (dayjs(result.start.get('month')) > 12 || dayjs(result.start.get('month')) < 1 ||
dayjs(result.start.get('day')) > 31 || dayjs(result.start.get('day')) < 1) {
return null;
}
if (match[HOUR_NUMBER_GROUP] != null) {
result.start.assign('hour',
parseInt(match[HOUR_NUMBER_GROUP]));
result.start.assign('minute',
parseInt(match[MINUTE_NUMBER_GROUP]));
if (match[SECOND_NUMBER_GROUP] != null) {
result.start.assign('second',
parseInt(match[SECOND_NUMBER_GROUP]));
}
if (match[MILLISECOND_NUMBER_GROUP] != null) {
result.start.assign('millisecond',
parseInt(match[MILLISECOND_NUMBER_GROUP]));
}
if (match[TZD_HOUR_OFFSET_GROUP] == null) {
result.start.assign('timezoneOffset', 0);
} else {
var minuteOffset = 0;
var hourOffset = parseInt(match[TZD_HOUR_OFFSET_GROUP]);
if (match[TZD_MINUTE_OFFSET_GROUP] != null)
minuteOffset = parseInt(match[TZD_MINUTE_OFFSET_GROUP]);
var offset = hourOffset * 60;
if (offset < 0) {
offset -= minuteOffset;
} else {
offset += minuteOffset;
}
result.start.assign('timezoneOffset', offset);
}
}
result.tags['ENISOFormatParser'] = true;
return result;
};
}
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0051 ]-- |