Skip to content

Commit

Permalink
fix current date for tz
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeTWC1984 committed Mar 9, 2021
1 parent a3b74ad commit 776c195
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions htdocs/js/home-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,19 @@ onmessage = function(e) {
let dupCheck = {} // tick string might contain dups, ignore them
item.ticks.toString().trim().replace(/\s+/g, ' ').split(/[\,\|]/).forEach(e => {
if(!e) return
let format = e.trim().length > 8 ? 'YYYY-MM-DD HH:mm A' : 'HH:mm A'
let actual = moment(e, format).tz(tz).unix()
let isRecurring = false;
if(e.trim().length < 9) { // expecting HH:mm A
isRecurring = true
e = moment().tz(tz).format('YYYY-MM-DD') + ' ' + e
}
let actual = moment.tz(e, 'YYYY-MM-DD HH:mm A', tz).unix()
if(dupCheck[actual]) return
dupCheck[actual] = true;
if (actual && (actual >= min_epoch) && (actual < max_epoch)) {
events.push({ epoch: actual, id: item.id });
}
// for HH:mm (recurring) ticks also check next day
if(format === 'HH:mm A' && (actual + 60*60*24 >= min_epoch) && (actual + 60*60*24 < max_epoch)) {
if(isRecurring && (actual + 60*60*24 >= min_epoch) && (actual + 60*60*24 < max_epoch)) {
events.push({ epoch: actual + 60*60*24, id: item.id });
}
});
Expand Down
2 changes: 1 addition & 1 deletion lib/scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ module.exports = Class.create({
checkEventTicks: function checkTicks(tickString, cursor, tz) {
if(!tickString) return false
return tickString.toString().trim().replace(/\s+/g, ' ').split(/[\,\|]/)
.map(e => moment(e, e.trim().length > 8 ? 'YYYY-MM-DD HH:mm A' : 'HH:mm A').tz(tz || this.tz).unix())
.map(e => moment.tz(e.trim().length < 9 ? moment().tz(tz).format('YYYY-MM-DD') + ' ' + e : e, 'YYYY-MM-DD HH:mm A', tz).unix())
.includes(cursor)
},

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Cronicle",
"version": "1.3.2",
"version": "1.3.3",
"description": "A simple, distributed task scheduler and runner with a web based UI.",
"author": "Joseph Huckaby <[email protected]>",
"homepage": "https://github.com/jhuckaby/Cronicle",
Expand Down

0 comments on commit 776c195

Please sign in to comment.