DatumHueEnterprise v0.0.24datumhue.com
Contents

namespaceTimers10 functions

datumhue.time

Monotonic time measurement and scheduled callbacks.

Returns handles
Timer

Functions 10

datumhue.time.now

function
datumhue.time.now() -> number

Monotonic seconds elapsed since the app started.

datumhue.time.unix_micros

function
datumhue.time.unix_micros() -> integer

Wall-clock microseconds since the Unix epoch.

datumhue.time.calendar

function
datumhue.time.calendar(at_micros: integer) -> Calendar

Break a Unix-microseconds timestamp (as from time.unix_micros) into its UTC calendar fields. Pair with the fields and time.unix_micros to build relative or formatted time in the app's own locale. Raises if the timestamp is out of the representable range.

Example
local epoch = datumhue.time.calendar(0)
print(epoch) --> 1970-01-01T00:00:00Z
-- Months and days count from 1; weekday 1 is Monday.
print(epoch.month, epoch.day, epoch.weekday) --> 1 1 4
-- The date and time now, in UTC.
local now = datumhue.time.calendar(datumhue.time.unix_micros())

datumhue.time.from_calendar

function
datumhue.time.from_calendar(opts: time.FromCalendarOptions) -> integer

Build a Unix-microseconds timestamp (UTC) from calendar fields — the inverse of time.calendar. Raises on an invalid date or time (e.g. month 13, Feb 30, hour 24).

Example
-- Fields left out start their range: day 1, midnight, UTC.
local start = datumhue.time.from_calendar({ year = 2026, month = 10 })
print(start) --> 1790812800000000
print(datumhue.time.calendar(start)) --> 2026-10-01T00:00:00Z

opts time.FromCalendarOptions options 6 keys

KeyTypeDefaultDescription
year requiredintegerno defaultFull year (e.g. 2026).
monthinteger1Month, 1-12.
dayinteger1Day of the month, 1-31.
hourinteger0Hour, 0-23.
minuteinteger0Minute, 0-59.
secondinteger0Second, 0-59.

datumhue.time.day_index

function
datumhue.time.day_index(micros: integer) -> integer

Whole days since 1970-01-01 UTC for a unix-microseconds instant (as returned by unix_micros). Floor division: a day boundary is midnight UTC, and instants before the epoch give negative indices.

Example
local day = 24 * 60 * 60 * 1000000
print(datumhue.time.day_index(day)) --> 1
-- Days start at midnight UTC; the instant before 1970 is day -1.
print(datumhue.time.day_index(-1)) --> -1
-- The same all day long: a seed for a daily puzzle.
local today = datumhue.time.day_index(datumhue.time.unix_micros())

datumhue.time.after

function
datumhue.time.after(secs: number, callback: fun(dt: number)) -> Timer

Schedule a one-shot callback to fire after secs seconds, on the first frame tick that reaches them. dt is the seconds the timer ran before it fired, leaving out any time it was paused. 0 fires on the next frame tick — the way to defer work out of the current callback. Returns a timer; call :unsubscribe() to cancel it before it fires, or pause/resume and query it.

Example
datumhue.time.after(0.2, function(dt)
    print("a fifth of a second later")
end)
-- 0 waits for the next frame.
datumhue.time.after(0, function(dt)
    print("next frame")
end)

datumhue.time.every

function
datumhue.time.every(secs: number, callback: fun(dt: number)) -> Timer

Schedule a repeating callback to fire every secs seconds, on frame ticks. dt is the seconds the timer ran since its last fire, or since it was created for the first, leaving out any time it was paused. Fires that come due while the last one still waits to run, behind a callback that runs long or waits for a result, run as one, whose dt covers them all. An interval of 0 fires once every frame — the frame hook for a library, leaving the app's single datumhue.on_update slot free. Returns a timer; call :unsubscribe() to stop it, or pause/resume and query it.

Example
-- Every 0.05 seconds, until it stops itself after the third.
local count = 0
local timer
timer = datumhue.time.every(0.05, function(dt)
    count = count + 1
    if count == 3 then
        timer:unsubscribe()
    end
end)

datumhue.time.tween

function
datumhue.time.tween(opts: time.TweenOptions) -> Timer

Animate a value from from to to over duration seconds, delivering the eased in-between value to on_update on each frame tick. Like a timer's fires, deliveries that come due while the last one still waits to run come as one, with the latest value. The final delivery is exactly to, then on_finish runs. from and to must be the same type. Returns a timer: :unsubscribe() cancels it (no further deliveries, on_finish never runs), and pause/resume/elapsed/remaining work as on any timer. Colors blend perceptually (Oklab, like Color:lerp).

Example
local canvas = datumhue.draw.new({ width = 320, height = 240 })
canvas:mount({ width = 320, height = 240 })
local dot = canvas:circle({ color = datumhue.color("#a7c080") })
datumhue.time.tween({
    from = datumhue.math.vec2(-120, 0),
    to = datumhue.math.vec2(120, 0),
    duration = 0.5,
    easing = "cubic_out",
    on_update = function(pos)
        dot.pos = pos
    end,
})

opts time.TweenOptions options 6 keys

KeyTypeDefaultDescription
from requirednumber | Vec2 | Vec3 | Colorno defaultStart value. Same type as to.
to requirednumber | Vec2 | Vec3 | Colorno defaultEnd value. Same type as from.
duration requirednumberno defaultTween duration in seconds.
easingEasing"linear"Easing curve.
on_update requiredfun(value: number | Vec2 | Vec3 | Color)no defaultReceives the in-between value each frame while the tween runs; a delivery due while the last one still waits to run replaces its value. The final delivery is exactly to.
on_finishfun()no defaultRuns once, after the final on_update delivery. Skipped when the tween is unsubscribed before it finishes.

datumhue.time.sleep

functionsuspends
datumhue.time.sleep(secs: number)

Pause the calling code for secs seconds on the per-frame clock that drives timers, then continue. The wait resolves on frame ticks, so the actual pause rounds up to the frame. 0 returns at once.

Example
print("on your marks")
-- A quarter second, rounded up to whole frames.
datumhue.time.sleep(0.25)
print("go")

datumhue.time.wait_frames

functionsuspends
datumhue.time.wait_frames(frames: integer)

Pause the calling code for frames frame ticks, then continue. 1 resumes on the next frame; 0 returns at once.

datumhue.com

(c) 2026 Shuusei AB. Quote excerpts of this manual, with attribution to DatumHue, in your own documentation, tutorials, course materials, reviews, and other writing or video. Republishing it in whole or in substantial part needs written permission: support@datumhue.com.

Victor Mono is licensed under the SIL Open Font License 1.1
Copyright (c) 2024, Rune Bjørnerås (https://github.com/rubjo)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Try

    ↑↓ selectEnter openTab filter

    Settings

    Theme
    Text
    Print

    Keyboard shortcuts

    / or Ctrl KSearch
    ↑ ↓ EnterPick a result
    TabNext result filter
    j kNext or previous entry
    [ ]Previous or next page
    yCopy a link to the current entry
    ?These shortcuts
    EscClose

    On this page