Search guides and the APICtrl K
  1. API reference
  2. Data, text and crypto

time.h

Dates, and lengths of time, as text.

#include <sonore/time.h>
  • 1type
  • 8other declarations
On this page

Design notes

Why this exists now

files.h reports a modification time and nothing could show it. A preset browser with a Date column, a sampler saying a file is 3:24 long, a "last used" ordering -- all of them need the same two conversions and neither was here.

Not std::chrono's formatting

std::format and <chrono>'s calendar types are C++20, and this SDK is C++17 so a generated plugin builds with whatever toolchain its author already has. What is here is the handful of formats a plugin actually shows, done once.

Thread safety, which localtime does not have

std::localtime returns a pointer to a STATIC struct. Two threads formatting a date at the same time -- a background scan filling a browser while the UI draws it -- get each other's answers, and the bug looks like a date that is occasionally somebody else's. localtime_s and localtime_r are the reentrant forms and this uses whichever the platform has.

Types 1

A moment, split up. Fields are what a human would say: month 1..12, not 0..11, because every off-by-one month bug starts with tm_mon.

Functions 8

↑↓ to move↵ to openEvery public name in the headers, and every guide