mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-17 23:45:59 +00:00
SYNC: month match
This commit is contained in:
committed by
Diflow
parent
6eb218db5e
commit
f14e4fe197
@@ -34,22 +34,53 @@ export function tryParseChartDate(dateInput: any): ChartDateParsed | null {
|
||||
}
|
||||
|
||||
if (typeof dateInput !== 'string') return null;
|
||||
const m = dateInput.match(
|
||||
const dateMatch = dateInput.match(
|
||||
/^(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(Z|[+-]\d{2}:\d{2})?)?$/
|
||||
);
|
||||
if (!m) return null;
|
||||
const monthMatch = dateInput.match(/^(\d{4})-(\d{2})$/);
|
||||
// const yearMatch = dateInput.match(/^(\d{4})$/);
|
||||
|
||||
const [_notUsed, year, month, day, hour, minute, second, fraction] = m;
|
||||
if (dateMatch) {
|
||||
const [_notUsed, year, month, day, hour, minute, second, fraction] = dateMatch;
|
||||
|
||||
return {
|
||||
year: parseInt(year, 10),
|
||||
month: parseInt(month, 10),
|
||||
day: parseInt(day, 10),
|
||||
hour: parseInt(hour, 10) || 0,
|
||||
minute: parseInt(minute, 10) || 0,
|
||||
second: parseInt(second, 10) || 0,
|
||||
fraction: fraction || undefined,
|
||||
};
|
||||
return {
|
||||
year: parseInt(year, 10),
|
||||
month: parseInt(month, 10),
|
||||
day: parseInt(day, 10),
|
||||
hour: parseInt(hour, 10) || 0,
|
||||
minute: parseInt(minute, 10) || 0,
|
||||
second: parseInt(second, 10) || 0,
|
||||
fraction: fraction || undefined,
|
||||
};
|
||||
}
|
||||
|
||||
if (monthMatch) {
|
||||
const [_notUsed, year, month] = monthMatch;
|
||||
return {
|
||||
year: parseInt(year, 10),
|
||||
month: parseInt(month, 10),
|
||||
day: 1,
|
||||
hour: 0,
|
||||
minute: 0,
|
||||
second: 0,
|
||||
fraction: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
// if (yearMatch) {
|
||||
// const [_notUsed, year] = yearMatch;
|
||||
// return {
|
||||
// year: parseInt(year, 10),
|
||||
// month: 1,
|
||||
// day: 1,
|
||||
// hour: 0,
|
||||
// minute: 0,
|
||||
// second: 0,
|
||||
// fraction: undefined,
|
||||
// };
|
||||
// }
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function pad2Digits(number) {
|
||||
|
||||
Reference in New Issue
Block a user