From bded7a1e594733454a9148ecc99c2fef9dd1b40c Mon Sep 17 00:00:00 2001 From: varun Date: Mon, 27 May 2024 04:19:59 -0400 Subject: [PATCH] This is for getting tank levels --- src/controllers/tanksController.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index d291a0fa..702b6253 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -2377,10 +2377,14 @@ exports.update_auto_percentage = async (req, reply) => { //storing water level for every 15 minutes +const getFormattedISTTime = () => { + return moment().tz('Asia/Kolkata').format('DD-MM-YYYY hh:mm:ss A'); +}; + const storeWaterLevels = async () => { try { const tanks = await Tank.find({}); - const currentTime = new Date().toISOString(); + const currentTime = getFormattedISTTime(); const waterLevelRecords = tanks.map(tank => ({ customerId: tank.customerId, @@ -2397,4 +2401,4 @@ const storeWaterLevels = async () => { } }; -setInterval(storeWaterLevels, 15 * 60 * 1000); // Run every 15 minutes +setInterval(storeWaterLevels, 15 * 60 * 1000);