From bab040df0fd6bb5e0eb1cf0f24e2472b527a8ad0 Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Thu, 24 Oct 2024 15:21:56 +0300 Subject: [PATCH] check if the file is older than an hour --- server.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server.js b/server.js index bfdd02c..cf94a02 100644 --- a/server.js +++ b/server.js @@ -118,6 +118,10 @@ app.get('/calendar/:name', async (req, res) => { const stats = fs.statSync(icsFilePath); const lastModified = new Date(stats.mtime); const now = new Date(); + // Check if the file is older than one hour + if (now - lastModified > 60 * 60 * 1000) { + console .log('Refreshing calendar data...'); + } } }