From a7a9bfb0943135c97fb547ae46464bcdae825025 Mon Sep 17 00:00:00 2001 From: hgw Date: Fri, 1 Dec 2023 10:42:32 +1100 Subject: [PATCH] Fix timezone problem --- commands/feed-list.js | 4 ++-- commands/feed-predef.js | 5 ++--- commands/feed-preset.js | 4 ++-- commands/options.js | 7 ++++++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/commands/feed-list.js b/commands/feed-list.js index acb3780..bbef410 100644 --- a/commands/feed-list.js +++ b/commands/feed-list.js @@ -91,9 +91,9 @@ async function fetchFeed(feedURL, n, nick) { var body = striptags(body); if (data.isoDate !== undefined) { var date = moment(data.isoDate) - if (uconfig[nick].timezone != undefined) { + try { var syncDate = date.tz(uconfig[nick].timezone) - } else { + } catch(e) { var syncDate = date.tz(config.feed.timezone) } var date = syncDate.format(config.feed.time_format) diff --git a/commands/feed-predef.js b/commands/feed-predef.js index 8e566ad..ca46f33 100644 --- a/commands/feed-predef.js +++ b/commands/feed-predef.js @@ -162,12 +162,11 @@ async function github(user, repo, type, n, nick) { if (data.isoDate !== undefined) { var date = moment(data.isoDate) - if (uconfig[nick].timezone != undefined) { + try { var syncDate = date.tz(uconfig[nick].timezone) - } else { + } catch(e) { var syncDate = date.tz(config.feed.timezone) } - //console.log(syncDate.format()) var date = syncDate.format(config.feed.time_format) } else { var date = data.pubDate diff --git a/commands/feed-preset.js b/commands/feed-preset.js index 0a08180..d0f1e4c 100644 --- a/commands/feed-preset.js +++ b/commands/feed-preset.js @@ -77,9 +77,9 @@ async function fetchFeed(feedURL, n) { var body = striptags(body); if (data.isoDate !== undefined) { var date = moment(data.isoDate) - if (uconfig[nick].timezone != undefined) { + try { var syncDate = date.tz(uconfig[nick].timezone) - } else { + } catch(e) { var syncDate = date.tz(config.feed.timezone) } var date = syncDate.format(config.feed.time_format) diff --git a/commands/options.js b/commands/options.js index 9447caf..703e296 100644 --- a/commands/options.js +++ b/commands/options.js @@ -203,7 +203,12 @@ async function set(setting, value, value2, nick) { sendUpstream(errorMsg+' Invalid timezone entered, not changing') } var file = editJsonFile('/home/node/app/config/usersettings.json'); - if (uconfig[nick].timezone == undefined || uconfig[nick].timezone == "" ) { + //try { + // var oldvalue = file.get(nick+".timezone") + //} catch(e) { + // var oldvalue = "Unset" + //} + if (file.get(nick+".timezone") == undefined || file.get(nick+".timezone") == "" ) { var oldvalue = "Unset" } else { var oldvalue = file.get(nick+".timezone")