@magmacomputing/tempo-plugin-snap
v1.3.2
Published
Snap time to blocks
Maintainers
Readme
@magmacomputing/tempo-plugin-snap
A Community plugin for the Tempo library that provides robust time rounding and snapping functionality (e.g. snapping to the nearest 15 minutes or 1 hour block) for calendar and scheduling applications.
👉 View the full documentation on our GitHub Pages
Installation
npm install @magmacomputing/tempo-plugin-snapUsage
import { Tempo } from '@magmacomputing/tempo';
import { SnapPlugin } from '@magmacomputing/tempo-plugin-snap';
// Pass the plugin to `Tempo.init` to register it into the runtime.
Tempo.init({
plugins: [SnapPlugin]
});
const t = new Tempo('2026-06-01T14:08:00Z');
// Snaps to the nearest 15 minutes by default
const snapped = t.snap();
console.log(snapped.format('{hh}:{mi}')); // "14:15"
// Or explicitly provide units and intervals
const snapHour = t.snap('hh', 1);
const snapSecond = t.snap('ss', 30);Documentation
For full API reference, advanced configuration, and detailed explanations of the rounding features, please visit the official Snap Plugin Documentation ↗.
Licensing
This is a Community plugin. It is completely free and open-source for personal and commercial use. No license token is required.
