Error: Timezone "gmt+0200" is not recognized
Error: Timezone "gmt+0200" is not recognized
我有问题。
我正在尝试通过 *.js 文件 "transfer" 将一些数据从一个 table 传递给彼此。一切顺利,除了一件事。这个函数告诉我:
Error: Timezone "gmt+0200" is not recognized
这是我的功能
async function submitCompletationCG(database, ulogin, idc) {
await connectToSpecificDatabase(database);
const AC_ID = `SELECT * FROM public.cg_actualcompletations WHERE UserLogin = '`+ulogin+`';`;
let AC_IDs = await client.query(AC_ID);
const ACC_ID = `SELECT * FROM public.cg_actualcompletationscondensed WHERE UserLogin = '`+ulogin+`';`;
let ACC_IDs = await client.query(ACC_ID);
const DEPOT = `SELECT * FROM public.cg_actualdepots WHERE UserLogin = '`+ulogin+`';`;
let DEPOTs = await client.query(DEPOT);
let depot_from, depot_to, code_from, code_to;
for(let Depot of DEPOTs.rows) {
depot_from = Depot.depot_from;
depot_to = Depot.depot_to;
code_from = Depot.code_from;
code_to = Depot.code_to;
}
for(let Completation of ACC_IDs.rows) { //Transfer all Completations Condensed
const ACC_Copy = `INSERT INTO public.cg_completationscondensed(
id_c, userlogin, barcode, quantity, adate)
VALUES ('`+idc+`', '`+ulogin+`', '`+Completation.barcode+`', '`+Completation.quantity+`', '`+Completation.adate+`');`;
await client.query(ACC_Copy);
const ACC_Delete = `DELETE FROM public.cg_actualcompletationscondensed
WHERE id = `+Completation.id+`;`;
await client.query(ACC_Delete);
}
for(let Completation of AC_IDs.rows) { //Transfer all Completations
const AC_Copy = `INSERT INTO public.cg_completations(
id_c, userlogin, barcode, quantity, adate)
VALUES ('`+idc+`', '`+ulogin+`', '`+Completation.barcode+`', '`+Completation.quantity+`', '`+Completation.adate+`');`;
await client.query(AC_Copy);
const AC_Delete = `DELETE FROM public.cg_actualcompletations
WHERE id = `+Completation.id+`;`;
await client.query(AC_Delete);
}
const SUB_UArch = `INSERT INTO public.cg_userarch(
userlogin, id_c, depot_from, depot_to, code_from, code_to)
VALUES ('`+ulogin+`', '`+idc+`', '`+depot_from+`', '`+depot_to+`', '`+code_from+`', '`+code_to+`');`;
await client.query(SUB_UArch);
const SUB_DKill = `DELETE FROM public.cg_actualdepots WHERE UserLogin = '`+ulogin+`';`;
await client.query(SUB_DKill);
return true;
}
我可以在 angular 文件的某处设置时区吗?还是数据库的问题?忘了说我正在使用 PostgreSQL。 ADate 列的类型是 "timestamp without time zone",之前是 "timestamp with time zone",但我认为它导致了问题,所以我更改了它。
我在这一行遇到了这个问题:
for(let Completation of ACC_IDs.rows) { //Transfer all Completations Condensed
const ACC_Copy = `INSERT INTO public.cg_completationscondensed(
id_c, userlogin, barcode, quantity, adate)
VALUES ('`+idc+`', '`+ulogin+`', '`+Completation.barcode+`', '`+Completation.quantity+`', '`+Completation.adate+`');`;
await client.query(ACC_Copy);
const ACC_Delete = `DELETE FROM public.cg_actualcompletationscondensed
WHERE id = `+Completation.id+`;`;
await client.query(ACC_Delete);
}
然后在下一个for循环中,因为还有date的操作
我解决了这个问题。我无法在互联网上的任何地方找到答案,所以我自己做。我在 for 循环的开头添加了这两行:
let date = new Date(Completation.adate);
date = date.toLocaleDateString() + " " + date.toLocaleTimeString();
然后将数据库查询更改为:
const ACC_Copy = `INSERT INTO public.cg_completationscondensed(
id_c, userlogin, barcode, quantity, adate)
VALUES ('`+idc+`', '`+ulogin+`', '`+Completation.barcode+`', '`+Completation.quantity+`', '`+date+`');`;
终于可以正常使用了!
我有问题。
我正在尝试通过 *.js 文件 "transfer" 将一些数据从一个 table 传递给彼此。一切顺利,除了一件事。这个函数告诉我:
Error: Timezone "gmt+0200" is not recognized
这是我的功能
async function submitCompletationCG(database, ulogin, idc) {
await connectToSpecificDatabase(database);
const AC_ID = `SELECT * FROM public.cg_actualcompletations WHERE UserLogin = '`+ulogin+`';`;
let AC_IDs = await client.query(AC_ID);
const ACC_ID = `SELECT * FROM public.cg_actualcompletationscondensed WHERE UserLogin = '`+ulogin+`';`;
let ACC_IDs = await client.query(ACC_ID);
const DEPOT = `SELECT * FROM public.cg_actualdepots WHERE UserLogin = '`+ulogin+`';`;
let DEPOTs = await client.query(DEPOT);
let depot_from, depot_to, code_from, code_to;
for(let Depot of DEPOTs.rows) {
depot_from = Depot.depot_from;
depot_to = Depot.depot_to;
code_from = Depot.code_from;
code_to = Depot.code_to;
}
for(let Completation of ACC_IDs.rows) { //Transfer all Completations Condensed
const ACC_Copy = `INSERT INTO public.cg_completationscondensed(
id_c, userlogin, barcode, quantity, adate)
VALUES ('`+idc+`', '`+ulogin+`', '`+Completation.barcode+`', '`+Completation.quantity+`', '`+Completation.adate+`');`;
await client.query(ACC_Copy);
const ACC_Delete = `DELETE FROM public.cg_actualcompletationscondensed
WHERE id = `+Completation.id+`;`;
await client.query(ACC_Delete);
}
for(let Completation of AC_IDs.rows) { //Transfer all Completations
const AC_Copy = `INSERT INTO public.cg_completations(
id_c, userlogin, barcode, quantity, adate)
VALUES ('`+idc+`', '`+ulogin+`', '`+Completation.barcode+`', '`+Completation.quantity+`', '`+Completation.adate+`');`;
await client.query(AC_Copy);
const AC_Delete = `DELETE FROM public.cg_actualcompletations
WHERE id = `+Completation.id+`;`;
await client.query(AC_Delete);
}
const SUB_UArch = `INSERT INTO public.cg_userarch(
userlogin, id_c, depot_from, depot_to, code_from, code_to)
VALUES ('`+ulogin+`', '`+idc+`', '`+depot_from+`', '`+depot_to+`', '`+code_from+`', '`+code_to+`');`;
await client.query(SUB_UArch);
const SUB_DKill = `DELETE FROM public.cg_actualdepots WHERE UserLogin = '`+ulogin+`';`;
await client.query(SUB_DKill);
return true;
}
我可以在 angular 文件的某处设置时区吗?还是数据库的问题?忘了说我正在使用 PostgreSQL。 ADate 列的类型是 "timestamp without time zone",之前是 "timestamp with time zone",但我认为它导致了问题,所以我更改了它。
我在这一行遇到了这个问题:
for(let Completation of ACC_IDs.rows) { //Transfer all Completations Condensed
const ACC_Copy = `INSERT INTO public.cg_completationscondensed(
id_c, userlogin, barcode, quantity, adate)
VALUES ('`+idc+`', '`+ulogin+`', '`+Completation.barcode+`', '`+Completation.quantity+`', '`+Completation.adate+`');`;
await client.query(ACC_Copy);
const ACC_Delete = `DELETE FROM public.cg_actualcompletationscondensed
WHERE id = `+Completation.id+`;`;
await client.query(ACC_Delete);
}
然后在下一个for循环中,因为还有date的操作
我解决了这个问题。我无法在互联网上的任何地方找到答案,所以我自己做。我在 for 循环的开头添加了这两行:
let date = new Date(Completation.adate);
date = date.toLocaleDateString() + " " + date.toLocaleTimeString();
然后将数据库查询更改为:
const ACC_Copy = `INSERT INTO public.cg_completationscondensed(
id_c, userlogin, barcode, quantity, adate)
VALUES ('`+idc+`', '`+ulogin+`', '`+Completation.barcode+`', '`+Completation.quantity+`', '`+date+`');`;
终于可以正常使用了!