Skip to content

Commit

Permalink
#115 wasn't quite done. UTC/local work now
Browse files Browse the repository at this point in the history
  • Loading branch information
mountaindude committed Oct 21, 2021
1 parent 4b2890c commit 98710c4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ scheduler:
showPerAppSchedule:
enable: true # Should the first itemCount scheduled runs be shown for each app, on startup?
itemCount: 10 # Number of coming runs to show for each app
timeZone: LOCAL # Valid values are UTC and LOCAL. Default value is UTC
timeZone: # Valid values are UTC and LOCAL. Default value is UTC
scheduleDefine: UTC # How should times in the apps config file be interpreted?
logs: UTC # What time format should be used in log files?

# Heartbeats can be used to send "I'm alive" messages to some other tool, e.g. an infrastructure monitoring tool
# The concept is simple: The remoteURL will be called at the specified frequency. The receiving tool will then know
Expand Down
4 changes: 2 additions & 2 deletions config/apps_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ apps:
appDescription: Description of app 1
appStepThroughSheets: false
doInitialLoad: false
freq: every 1 hour
freq: every 5 mins every weekend
- server: senseserver.mydomain.com
appId: <app id 2>
appDescription: Description of app 2
appStepThroughSheets: false
doInitialLoad: false
freq: every 2 hours
freq: at 5:00 pm
- server: hsenseserverost2.mydomain.com
appId: <app id 3>
appDescription: Description of app 3
Expand Down
8 changes: 5 additions & 3 deletions config/default_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ fileLogging: false # true/false to enable/disable logging to disk
scheduler:
startup:
showPerAppSchedule:
enable: true # Should the first itemCount scheduled runs be shown for each app, on startup?
itemCount: 10 # Number of coming runs to show for each app
timeZone: LOCAL # Valid values are UTC and LOCAL. Default value is UTC
enable: true # Should the first itemCount scheduled runs be shown for each app, on startup?
itemCount: 10 # Number of coming runs to show for each app
timeZone: # Valid values are UTC and LOCAL. Default value is UTC
scheduleDefine: UTC # How should times in the apps config file be interpreted?
logs: UTC # What time format should be used in log files?

# Heartbeats can be used to send "I'm alive" messages to some other tool, e.g. an infrastructure monitoring tool
# The concept is simple: The remoteURL will be called at the specified frequency. The receiving tool will then know
Expand Down
14 changes: 8 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ function loadAppConfig(appConfig) {
const showItemCount = globals.config.get(
'scheduler.startup.showPerAppSchedule.itemCount'
);
const occurrences = later.schedule(sched).next(showItemCount);
const s = later.schedule(sched);
const occurrences = s.next(showItemCount);

globals.logger.info(
'-------------------------------------------------------------------------'
Expand All @@ -179,12 +180,13 @@ function loadAppConfig(appConfig) {
// eslint-disable-next-line no-plusplus
for (let i = 0; i < showItemCount; i++) {
if (
globals.config.has('scheduler.timeZone') &&
globals.config.get('scheduler.timeZone').toLowerCase() === 'local'
globals.config.has('scheduler.timeZone.logs') &&
globals.config.get('scheduler.timeZone.logs').toLowerCase() === 'local'
) {
globals.logger.info(`${i + 1}: ${occurrences[i]}`);
} else {
globals.logger.info(`${i + 1}: ${occurrences[i].toUTCString()}`);
const utcString = occurrences[i].toUTCString();
globals.logger.info(`${i + 1}: ${utcString}`);
}
}
}
Expand Down Expand Up @@ -272,8 +274,8 @@ async function mainScript() {
}

// Set up UTC/local time zone
if (globals.config.has('scheduler.timeZone')) {
const tz = globals.config.get('scheduler.timeZone');
if (globals.config.has('scheduler.timeZone.scheduleDefine')) {
const tz = globals.config.get('scheduler.timeZone.scheduleDefine');
if (tz.toLowerCase() === 'local') {
later.date.localTime();
} else {
Expand Down

0 comments on commit 98710c4

Please sign in to comment.