Fix timezone problem

This commit is contained in:
hgw 2023-12-01 10:42:32 +11:00
parent 16af27106f
commit a7a9bfb094
Signed by: hgw
SSH Key Fingerprint: SHA256:NQGxKc1SBxScBCFxfa0Mx7yzNpOieGL9WUOwyafNEU4
4 changed files with 12 additions and 8 deletions

View File

@ -91,9 +91,9 @@ async function fetchFeed(feedURL, n, nick) {
var body = striptags(body); var body = striptags(body);
if (data.isoDate !== undefined) { if (data.isoDate !== undefined) {
var date = moment(data.isoDate) var date = moment(data.isoDate)
if (uconfig[nick].timezone != undefined) { try {
var syncDate = date.tz(uconfig[nick].timezone) var syncDate = date.tz(uconfig[nick].timezone)
} else { } catch(e) {
var syncDate = date.tz(config.feed.timezone) var syncDate = date.tz(config.feed.timezone)
} }
var date = syncDate.format(config.feed.time_format) var date = syncDate.format(config.feed.time_format)

View File

@ -162,12 +162,11 @@ async function github(user, repo, type, n, nick) {
if (data.isoDate !== undefined) { if (data.isoDate !== undefined) {
var date = moment(data.isoDate) var date = moment(data.isoDate)
if (uconfig[nick].timezone != undefined) { try {
var syncDate = date.tz(uconfig[nick].timezone) var syncDate = date.tz(uconfig[nick].timezone)
} else { } catch(e) {
var syncDate = date.tz(config.feed.timezone) var syncDate = date.tz(config.feed.timezone)
} }
//console.log(syncDate.format())
var date = syncDate.format(config.feed.time_format) var date = syncDate.format(config.feed.time_format)
} else { } else {
var date = data.pubDate var date = data.pubDate

View File

@ -77,9 +77,9 @@ async function fetchFeed(feedURL, n) {
var body = striptags(body); var body = striptags(body);
if (data.isoDate !== undefined) { if (data.isoDate !== undefined) {
var date = moment(data.isoDate) var date = moment(data.isoDate)
if (uconfig[nick].timezone != undefined) { try {
var syncDate = date.tz(uconfig[nick].timezone) var syncDate = date.tz(uconfig[nick].timezone)
} else { } catch(e) {
var syncDate = date.tz(config.feed.timezone) var syncDate = date.tz(config.feed.timezone)
} }
var date = syncDate.format(config.feed.time_format) var date = syncDate.format(config.feed.time_format)

View File

@ -203,7 +203,12 @@ async function set(setting, value, value2, nick) {
sendUpstream(errorMsg+' Invalid timezone entered, not changing') sendUpstream(errorMsg+' Invalid timezone entered, not changing')
} }
var file = editJsonFile('/home/node/app/config/usersettings.json'); 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" var oldvalue = "Unset"
} else { } else {
var oldvalue = file.get(nick+".timezone") var oldvalue = file.get(nick+".timezone")