convert dates to web format

This commit is contained in:
Andrzej Stepien 2023-09-06 23:27:14 +02:00
parent d4f4d16dc4
commit 87d041e28a
4 changed files with 27 additions and 0 deletions

17
convertDatesForWeb.mjs Normal file
View File

@ -0,0 +1,17 @@
import { DateTime } from "luxon";
import { db } from "./db.mjs";
const table = await db('subs').select('*')
const ddmmyyyyToyyyymmdd = (str) =>{
return DateTime.fromFormat(str,'dd/MM/yyyy').toFormat('yyyy-MM-dd').toString()
}
for (const row of table) {
await db('subs')
.where('id',row.id)
.update({
date_submitted: ddmmyyyyToyyyymmdd(row.date_submitted),
date_responded: ddmmyyyyToyyyymmdd(row.date_responded)
})
}

9
package-lock.json generated
View File

@ -15,6 +15,7 @@
"cors": "^2.8.5",
"express": "^4.18.2",
"knex": "^2.5.1",
"luxon": "^3.4.3",
"mocha": "^10.2.0",
"pino": "^8.15.0",
"pino-http": "^8.5.0",
@ -1740,6 +1741,14 @@
"node": ">=10"
}
},
"node_modules/luxon": {
"version": "3.4.3",
"resolved": "https://registry.npmjs.org/luxon/-/luxon-3.4.3.tgz",
"integrity": "sha512-tFWBiv3h7z+T/tDaoxA8rqTxy1CHV6gHS//QdaH4pulbq/JuBSGgQspQQqcgnwdAx6pNI7cmvz5Sv/addzHmUg==",
"engines": {
"node": ">=12"
}
},
"node_modules/make-dir": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz",

View File

@ -15,6 +15,7 @@
"cors": "^2.8.5",
"express": "^4.18.2",
"knex": "^2.5.1",
"luxon": "^3.4.3",
"mocha": "^10.2.0",
"pino": "^8.15.0",
"pino-http": "^8.5.0",

Binary file not shown.