From 40a07d9ba6c9e89255b79c8a6fa2aa5a1f1be9b2 Mon Sep 17 00:00:00 2001 From: varun Date: Thu, 30 May 2024 02:36:58 -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);