libamxc
1.10.3
C Generic Data Containers
|
#include <unistd.h>
#include <sys/time.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <time.h>
#include <amxc/amxc_timestamp.h>
#include <amxc/amxc_macros.h>
Go to the source code of this file.
Macros | |
#define | _GNU_SOURCE |
#define | EPOCH INT64_C(62135683200) /* 1970-01-01T00:00:00 */ |
#define | MIN_SEC INT64_C(-62135596800) /* 0001-01-01T00:00:00 */ |
#define | MAX_SEC INT64_C(253402300799) /* 9999-12-31T23:59:59 */ |
#define | RDN_OFFSET INT64_C(62135683200) /* 1970-01-01T00:00:00 */ |
Functions | |
static int | leap_year (uint16_t y) |
static unsigned char | month_days (uint16_t y, uint16_t m) |
static int | parse_2d (const unsigned char *const p, size_t i, uint16_t *vp) |
static int | parse_4d (const unsigned char *const p, size_t i, uint16_t *vp) |
static void | rdn_to_ymd (uint32_t rdn, uint16_t *yp, uint16_t *mp, uint16_t *dp) |
static size_t | timestamp_format_internal (char *dst, size_t len, const amxc_ts_t *tsp, const int precision) |
static void | rdn_to_struct_tm (uint32_t rdn, struct tm *tmp) |
static int | timestamp_to_tm (const amxc_ts_t *tsp, struct tm *tmp, const bool local) |
int | amxc_ts_now (amxc_ts_t *tsp) |
Takes current time as unix epoch time. More... | |
static int | amxc_ts_parse_date (const unsigned char *cur, uint16_t *year, uint16_t *month, uint16_t *day) |
static int | amxc_ts_parse_time (const unsigned char *cur, uint16_t *hour, uint16_t *min, uint16_t *sec) |
static int | amxc_ts_parse_offset (const unsigned char *cur, const unsigned char *end, int16_t *offset) |
int | amxc_ts_parse (amxc_ts_t *tsp, const char *str, size_t len) |
Transforms the given string in to unix epoch time. More... | |
size_t | amxc_ts_format (const amxc_ts_t *tsp, char *dst, size_t len) |
Transforms unix epoch time to a string. More... | |
size_t | amxc_ts_format_precision (const amxc_ts_t *tsp, char *dst, size_t len, int precision) |
Transforms unix epoch time to a string. More... | |
int | amxc_ts_compare (const amxc_ts_t *tsp1, const amxc_ts_t *tsp2) |
Checks if tsp1 comes after tsp2. More... | |
bool | amxc_ts_is_valid (const amxc_ts_t *tsp) |
Checks if a timestamp is valid. More... | |
int | amxc_ts_to_tm_utc (const amxc_ts_t *tsp, struct tm *tmp) |
Converts timestamp in unix epoch time to a struct tm type in UTC time. More... | |
int | amxc_ts_to_tm_local (const amxc_ts_t *tsp, struct tm *tmp) |
Converts timestamp in unix epoch time to a struct tm type in local time. More... | |
int | amxc_ts_to_local (amxc_ts_t *tsp) |
Adds the local time offset to the timestamp structure. More... | |
int | amxc_ts_from_tm (amxc_ts_t *const tsp, struct tm *tmp) |
Converts a broken down time in a struct tm to a timestamp structure. More... | |
Variables | |
static const uint32_t | Pow10 [10] |
static const uint16_t | DayOffset [13] |
#define _GNU_SOURCE |
Definition at line 82 of file amxc_timestamp.c.
#define EPOCH INT64_C(62135683200) /* 1970-01-01T00:00:00 */ |
Definition at line 95 of file amxc_timestamp.c.
#define MAX_SEC INT64_C(253402300799) /* 9999-12-31T23:59:59 */ |
Definition at line 97 of file amxc_timestamp.c.
#define MIN_SEC INT64_C(-62135596800) /* 0001-01-01T00:00:00 */ |
Definition at line 96 of file amxc_timestamp.c.
#define RDN_OFFSET INT64_C(62135683200) /* 1970-01-01T00:00:00 */ |
Definition at line 98 of file amxc_timestamp.c.
|
static |
Definition at line 319 of file amxc_timestamp.c.
|
static |
Definition at line 347 of file amxc_timestamp.c.
|
static |
Definition at line 333 of file amxc_timestamp.c.
|
static |
Definition at line 108 of file amxc_timestamp.c.
|
static |
Definition at line 112 of file amxc_timestamp.c.
|
static |
Definition at line 120 of file amxc_timestamp.c.
|
static |
Definition at line 130 of file amxc_timestamp.c.
|
static |
Definition at line 248 of file amxc_timestamp.c.
|
static |
Definition at line 143 of file amxc_timestamp.c.
|
static |
Definition at line 163 of file amxc_timestamp.c.
|
static |
Definition at line 272 of file amxc_timestamp.c.
|
static |
Definition at line 104 of file amxc_timestamp.c.
|
static |
Definition at line 100 of file amxc_timestamp.c.