35 lines
965 B
C
35 lines
965 B
C
/*
|
|
* Trainlog timestamp implementation.
|
|
*
|
|
* Owns this module's bounded behavior and does not redefine persistence, synchronization, or UI contracts owned elsewhere.
|
|
*/
|
|
#ifndef TRAINLOG_INTERNAL_TIMESTAMP_H
|
|
#define TRAINLOG_INTERNAL_TIMESTAMP_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
typedef struct TrainlogTimestampKey {
|
|
int64_t utc_second;
|
|
int64_t local_day;
|
|
const char *fraction;
|
|
size_t fraction_length;
|
|
} TrainlogTimestampKey;
|
|
|
|
/* CONTRACT: Parses the frozen Trainlog timestamp grammar from exactly length
|
|
* bytes. The key borrows fraction storage from value and remains valid only
|
|
* while value does. */
|
|
bool trainlog_timestamp_parse(
|
|
const char *value,
|
|
size_t length,
|
|
TrainlogTimestampKey *output
|
|
);
|
|
|
|
/* Returns less than, zero, or greater than zero by exact represented instant. */
|
|
int trainlog_timestamp_compare(
|
|
const TrainlogTimestampKey *left,
|
|
const TrainlogTimestampKey *right
|
|
);
|
|
|
|
#endif
|