notesy::time
The time: now, written in the user's time zone, read from a date, and how long ago something was. Needs nothing.
rustuse notesy::{log, store, time};
pub fn ready() {
let now = time::now();
log::info(`It's ${time::format(now, "%H:%M")}`);
if let Some(at) = store::get("synced") {
log::info(`Synced ${time::ago(at)}`);
}
store::set("synced", now);
let due = time::parse("2026-09-30").unwrap_or(0);
log::info(`${(due - now) / 86400} days to go`);
}
| Function | What it does |
|---|---|
time::now() |
Seconds since 1 January 1970 (UTC), now. |
time::format(secs, pattern) |
secs written in the user's time zone with a strftime pattern: %Y-%m-%d, %H:%M, %a for the day's short name … An empty or broken pattern writes it as ISO 8601, in UTC. |
time::parse(text) |
Seconds for a date as front matter writes one: 2026-09-14, maybe with a time (2026-09-14T15:00, :30 for seconds) and a Z or +01:00. Without an offset it counts as UTC, so a date's day and hour read back with plain arithmetic (secs % 86400 / 3600 is its hour). None for text that isn't a date. |
time::ago(secs) |
How long ago that was, as notesy says it: just now, 5 minutes ago, yesterday, 3 days ago, then the date. |
time::after(seconds, handler) |
handler() once, seconds from now (a fraction is fine). Its id, a number, for time::cancel. |
time::every(seconds, handler) |
handler() every seconds, at most once a second, until it's cancelled or the plugin stops. A computer that slept doesn't owe it the times it missed: the next is from when it woke. Its id. |
time::cancel(id) |
Lets go of a timer; one that's gone already is nothing to cancel. |
A script has at most 32 timers waiting. Its handlers run between everything else it's handed, one at a time, each within the budget of a call; one that fails counts as a failure, as an event handler's does.
Every page
- Overview
- plugin.toml: Every field of plugin.toml
- Permissions: What a plugin can ask for, when notesy asks, and what changes it
- Scripts: How a script runs: its lifecycle, events, limits and errors
- Packing and installing: Making, checking, signing, packing and installing
- notesy::log: Lines for its log on the Plugins page
- notesy::events: Hearing what happens, and every event
- notesy::commands: Adding commands, and running notesy's
- notesy::store: Keeping its own data
- notesy::settings: Reading its settings
- notesy::secrets: Keys and tokens, in the system keychain
- notesy::notes: Reading and changing the vault's notes
- notesy::editor: The note in front
- notesy::templates: What templates fill in, and functions of its own for them
- notesy::files: A folder of its own
- notesy::links: Opening pages in the browser, naming links after their pages
- notesy::clipboard: Copying and pasting
- notesy::view: What panels, tabs and sections show
- notesy::sections: Sidebar sections
- notesy::hidden: Hiding notes, files and folders from the tree
- notesy::status: Status bar items
- notesy::tools: Buttons in the formatting bar
- notesy::notices: Notices
- notesy::dialogs: Asking in a dialog, notesy's kinds or its own
- notesy::wizards: Pages one after another, like a setup
- notesy::boards: Boards' cards and arrows, and kinds of card of its own
- notesy::blocks: Drawing its fenced blocks
- notesy::icons: Drawing its own icons
- notesy::net: Requests to the sites it names
- notesy::ipc: Talking to a program on this computer
- notesy::accounts: Signing in to a service
- notesy::json: Reading and writing JSON
- notesy::toml: Reading and writing TOML
- notesy::yaml: Reading and writing YAML, and a note's front matter
- notesy::time: Now, written in the user's time zone, dates read, how long ago
- notesy::math: Trigonometry and the like, for drawing
- Names: Icon, Color, Tone, Side, Method, Command, Zone, Event: Notesy's names as enums
- notesy::preview: Its own screens for notesy preview
- notesy::perf: Timing its own work
- notesy::drawings: Drawings' shapes, and buttons in their tool strip
- notesy::sound: Playing sounds, and making them as it runs
- notesy::tex: Math macros for every note's formulas
- notesy::views: Side panels, tabs of its own, and its part of the tree's hover cards
- notesy::zones: Notesy's own places — its menus, its bars and its headings