docs » hs.timer
Execute functions with various timing rules
- Functions - API calls offered directly by the extension
- absolutetime
- days
- hours
- localTime
- minutes
- seconds
- secondsSinceEpoch
- usleep
- weeks
- Constructors - API calls which return an object, typically one that offers API methods
- doAfter
- doAt
- doEvery
- doUntil
- doWhile
- new
- waitUntil
- waitWhile
- Methods - API calls which can only be made on an object returned by a constructor
- fire
- nextTrigger
- running
- setNextTrigger
- start
- stop
Signature | hs.timer.absolutetime() -> nanoseconds |
---|---|
Type | Function |
Description | Returns the absolute time in nanoseconds since the last system boot. |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.timer.days(n) -> sec |
---|---|
Type | Function |
Description | Converts days to seconds |
Parameters |
|
Returns |
|
Signature | hs.timer.hours(n) -> seconds |
---|---|
Type | Function |
Description | Converts hours to seconds |
Parameters |
|
Returns |
|
Signature | hs.timer.localTime() -> number |
---|---|
Type | Function |
Description | Returns the number of seconds since local time midnight |
Parameters |
|
Returns |
|
Signature | hs.timer.minutes(n) -> seconds |
---|---|
Type | Function |
Description | Converts minutes to seconds |
Parameters |
|
Returns |
|
Signature | hs.timer.seconds(timeOrDuration) -> seconds |
---|---|
Type | Function |
Description | Converts a string with a time of day or a duration into number of seconds |
Parameters |
|
Returns |
|
Signature | hs.timer.secondsSinceEpoch() -> sec |
---|---|
Type | Function |
Description | Gets the (fractional) number of seconds since the UNIX epoch (January 1, 1970) |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.timer.usleep(microsecs) |
---|---|
Type | Function |
Description | Blocks Lua execution for the specified time |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.timer.weeks(n) -> sec |
---|---|
Type | Function |
Description | Converts weeks to seconds |
Parameters |
|
Returns |
|
Signature | hs.timer.doAfter(sec, fn) -> timer |
---|---|
Type | Constructor |
Description | Calls a function after a delay |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.timer.doAt(time[, repeatInterval], fn[, continueOnError]) -> timer |
---|---|
Type | Constructor |
Description | Creates and starts a timer which will perform fn at the given (local) time and then (optionally) repeat it every interval . |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.timer.doEvery(interval, fn) -> timer |
---|---|
Type | Constructor |
Description | Repeats fn every interval seconds. |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.timer.doUntil(predicateFn, actionFn[, checkInterval]) -> timer |
---|---|
Type | Constructor |
Description | Creates and starts a timer which will perform actionFn every checkinterval seconds until predicateFn returns true. The timer is automatically stopped when predicateFn returns true. |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.timer.doWhile(predicateFn, actionFn[, checkInterval]) -> timer |
---|---|
Type | Constructor |
Description | Creates and starts a timer which will perform actionFn every checkinterval seconds while predicateFn returns true. The timer is automatically stopped when predicateFn returns false. |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.timer.new(interval, fn [, continueOnError]) -> timer |
---|---|
Type | Constructor |
Description | Creates a new hs.timer object for repeating interval callbacks |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.timer.waitUntil(predicateFn, actionFn[, checkInterval]) -> timer |
---|---|
Type | Constructor |
Description | Creates and starts a timer which will perform actionFn when predicateFn returns true. The timer is automatically stopped when actionFn is called. |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.timer.waitWhile(predicateFn, actionFn[, checkInterval]) -> timer |
---|---|
Type | Constructor |
Description | Creates and starts a timer which will perform actionFn when predicateFn returns false. The timer is automatically stopped when actionFn is called. |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.timer:fire() -> timer |
---|---|
Type | Method |
Description | Immediately fires a timer |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.timer:nextTrigger() -> number |
---|---|
Type | Method |
Description | Returns the number of seconds until the timer will next trigger |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.timer:running() -> boolean |
---|---|
Type | Method |
Description | Returns a boolean indicating whether or not the timer is currently running. |
Parameters |
|
Returns |
|
Signature | hs.timer:setNextTrigger(seconds) -> timer |
---|---|
Type | Method |
Description | Sets the next trigger time of a timer |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.timer:start() -> timer |
---|---|
Type | Method |
Description | Starts an hs.timer object |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.timer:stop() -> timer |
---|---|
Type | Method |
Description | Stops an hs.timer object |
Parameters |
|
Returns |
|