mirror of
https://github.com/Redume/Kekkai.git
synced 2025-02-23 12:43:12 +03:00
Дата теперь увеличивается на один день для корректного отображения
This commit is contained in:
parent
f63730e87e
commit
fa18206d51
1 changed files with 9 additions and 1 deletions
|
@ -22,6 +22,9 @@ async function getDay(from_currency, conv_currency, date) {
|
||||||
|
|
||||||
if (!data) return new Error('Missing data');
|
if (!data) return new Error('Missing data');
|
||||||
|
|
||||||
|
let set_date = data['rows'][0]['date']
|
||||||
|
set_date = new Date(set_date.setDate(set_date.getDate() + 1));
|
||||||
|
|
||||||
return data['rows'][0];
|
return data['rows'][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +42,7 @@ async function getPeriod(from_currency, conv_currency, start_date, end_date) {
|
||||||
else if(!start_date || !end_date) return new Error('start_date and end_date are required')
|
else if(!start_date || !end_date) return new Error('start_date and end_date are required')
|
||||||
|
|
||||||
const data = await pool.query('SELECT * FROM currency WHERE ' +
|
const data = await pool.query('SELECT * FROM currency WHERE ' +
|
||||||
'(date BETWEEN $3 AND $4) AND from_currency = $1 AND conv_currency = $2', [
|
'(date BETWEEN $3 AND $4) AND from_currency = $1 AND conv_currency = $2 ORDER BY date', [
|
||||||
from_currency.toUpperCase(),
|
from_currency.toUpperCase(),
|
||||||
conv_currency.toUpperCase(),
|
conv_currency.toUpperCase(),
|
||||||
start_date,
|
start_date,
|
||||||
|
@ -48,6 +51,11 @@ async function getPeriod(from_currency, conv_currency, start_date, end_date) {
|
||||||
|
|
||||||
if (!data) return new Error('Missing data');
|
if (!data) return new Error('Missing data');
|
||||||
|
|
||||||
|
for (let i = 0; i < data['rows'].length; i++) {
|
||||||
|
let date = data['rows'][i]['date']
|
||||||
|
date = new Date(date.setDate(date.getDate() + 1));
|
||||||
|
}
|
||||||
|
|
||||||
return data['rows'];
|
return data['rows'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue