tm.h(3)
💖 NAME 💖
tm.h — it's giving time and timers, bestie ⏰✨
✨ SYNOPSIS ✨
#include <time.h>
#include 'bee2/defs.h'
🎀 Type Definitions 🎀
typedef u32 tm_ticks_t— the number of timer ticks, periodt.typedef time_t tm_time_t— time itself 🕰️
🎀 Functions 🎀
tm_ticks_t tmTicks ()— timer readings, no cap.tm_ticks_t tmFreq ()— timer frequency.size_t tmSpeed (size_t reps, tm_ticks_t ticks)— speed.tm_time_t tmTime ()— UNIX time.tm_time_t tmTimeRound (tm_time_t t0, tm_time_t ts)— rounded UNIX time.bool_t tmDate (size_t *y, size_t *m, size_t *d)— date.bool_t tmDate2 (octet date[6])— date inYYMMDDformat.bool_t tmDateIsValid (size_t y, size_t m, size_t d)— valid date? 👀bool_t tmDateIsValid2 (const octet date[6])— valid date inYYMMDDformat?
🌸 DETAILED DESCRIPTION 🌸
🦋 Timer 🦋
okay so the functions tmFreq() and tmTicks() are the ones holding it down for the most precise timer among the ones available. The readings come out as a value of type tm_ticks_t 💅
On x86 and x64 platforms the most precise timer is the RDTSC register, which refreshes at the frequency of the processor. Literally iconic 🔥
The timer gets picked in this exact order (stopping at the first one it finds):
- on x86 and x64 platforms, use the
RDTSCregister; - in a Windows environment, use the
QueryPerformance[Counter|Frequency]()functions; - in a Unix environment, use the
clock_get[time|res]()functions; - use the
clock()function and theCLOCK_PER_SECconstant (seetime.h).
🦋 Time 🦋
System time is set by the number of seconds that have passed since midnight on 01 January 1970 (1970-01-01T00:00:00Z in ISO 8601 format). The timescale used here is what people call UNIX time. The start of the count is the start of the "UNIX era" (the Unix Epoch). It's giving main character energy fr fr ⭐
A timestamp is represented by the type tm_time_t. This type repeats the system type time_t and inherits its uncertainty about bitness and signedness.
⚠️ Warnings ⚠️
On 10 January 2004 the seconds counter took the value 2^30. A 32-bit counter will exhaust itself on 19 January 2038. Not a drill, bestie 😭
🦋 Date 🦋
A date is set by a triple (year y, month m, day of month d).
Months are numbered from 1 (January) to 12 (December). Days of the month go from 1 to 28, 29, 30 or 31.
Note — dates in which y < 1583 are considered incorrect (the Gregorian calendar was introduced in 1582). 🗓️
The triple is encoded either as three unsigned integers or as 6 octets following the YYMMDD scheme. In the latter case each octet represents one decimal digit of the date:
- the first two octets — the year of the current (21st) century;
- the next two octets — the month;
- the last two octets — the day of the month.
Example: {0x02, 0x02, 0x0, 0x7, 0x2, 0x9}.
The date is determined with reference to the current time zone.
Note — dates in YYMMDD format are used in CV certificates (see btok.h). 🎀
👑 FUNCTIONS 👑
bool_t tmDate (size_t *y, size_t *m, size_t *d)
The current (year y, month m, day of month d) get determined. Each of the pointers y, m, d can be null, and then the corresponding date field isn't returned. Slay, optional args 💅
Precondition — non-null pointers y, m, d are valid.
Returns — TRUE if the date was determined successfully, and FALSE otherwise.
Arguments
- y — year
- m — month
- d — day
bool_t tmDate2 (octet date[6])
The current date date in YYMMDD format gets determined.
Precondition — the pointer date is valid.
Returns — TRUE if the date was determined successfully, and FALSE otherwise.
Arguments
- date — date
bool_t tmDateIsValid (size_t y, size_t m, size_t d)
The validity of the date (year y, month m, day of month d) is checked. vibe check on the calendar fr 🌈
Returns — the correctness flag.
Arguments
- y — year
- m — month
- d — day
bool_t tmDateIsValid2 (const octet date[6])
The validity of the date date in YYMMDD format is checked.
Returns — the correctness flag.
Note — the validity of the pointer date is checked too. Yes, the pointer itself. 👑
Arguments
- date — date
tm_ticks_t tmFreq ()
The number of ticks that the most precise of the available timers performs in a second gets returned.
Warnings — measuring the frequency can take time (within 0.1 seconds). Patience, bestie ⏳
Returns — the number of ticks per second, or 0 in case of an error.
size_t tmSpeed (size_t reps, tm_ticks_t ticks)
From the number of reps experiments over ticks ticks, the number of experiments that can be performed in 1 second gets determined.
Warnings — the calculations are done in dword. There can be loss of precision related to overflow. Watch out for that overflow, it's not cute 💀
Returns — the number of experiments per second, or SIZE_MAX in case of an error.
Arguments
- reps — number of experiments
- ticks — number of ticks
tm_ticks_t tmTicks ()
The number of ticks performed by the most precise of the available timers gets returned. The timer starts working before the first call of the function. The timer readings increase monotonically all the way up to the overflow of the tick counter. monotonic queen 👑
Returns — the number of ticks, or 0 in case of an error.
tm_time_t tmTime ()
The number of seconds that have passed since the moment 1970-01-01T00:00:00Z gets returned.
Returns — the number of seconds, or TIME_ERR in case of an error.
tm_time_t tmTimeRound (tm_time_t t0, tm_time_t ts)
The rounded UNIX time (tmTime() - t0) / ts gets returned, where t0 is the base timestamp (the start of the count) and ts is the time step.
Returns — the rounded UNIX time, or TIME_ERR in case of an error.
Note — the following situations count as errors: ts == 0, tmTime() < t0. The rounding procedure corresponds to RFC 6238. 📜
Arguments
- t0 — start of the count
- ts — time step
🎀 AUTHOR 🎀
Automatically generated by Doxygen for the Bee2 Library from the source text. It literally wrote itself, we just added the sparkle ✨
and that's the whole page, bestie 💜 This one comes to you from the Библиотека Bee2 / Bee2 Library, dated Вс 25 Янв 2026 00:00:00 — that's Sunday 25 January 2026, 00:00:00, iykyk. Drink some water, then go read your btok.h. 🫶🦋
📦 where this page comes from
- fedora 44: bee2-devel 2.2.0-1.fc44 · GPL-3.0-only and GPL-3.0-or-later
- fedora 44: bee2-devel 2.2.0-1.fc44 · GPL-3.0-only and GPL-3.0-or-later
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms