Digital-Alchemy-TS / automation

Higher level typescript based automation utilities
https://docs.digital-alchemy.app/Automation
MIT License
1 stars 0 forks source link

Time functions #8

Closed zoe-codez closed 5 months ago

zoe-codez commented 5 months ago

Changes

  1. renamed automation.utils to automation.time
  2. updated solar.onEvent to work off scheduler.sliding
    • context is no longer required
    • new optional param: offset
  3. added automation.time methods, which consume strings and return bool
    • isBetween
    • isBefore
    • isAfter

Offset

Offset examples

automation.solar.onEvent({
  eventName: "dusk",
  exec() {
    logger.info("hour before dusk");
  },
  offset: "-1h",
});

automation.solar.onEvent({
  eventName: "dusk",
  exec() {
    logger.info("some random time within an hour after dusk");
  },
  offset: () => Math.random() * 60 * 60 * 1000,
});

Checklist