https://github.com/chansen/c-timestamp
Fast RFC 3339 (ISO 8601) timestamp parser and formatter implemented in C, zero dependencies.
https://github.com/chansen/c-timestamp
Last synced: 9 months ago
JSON representation
Fast RFC 3339 (ISO 8601) timestamp parser and formatter implemented in C, zero dependencies.
- Host: GitHub
- URL: https://github.com/chansen/c-timestamp
- Owner: chansen
- Created: 2014-01-28T15:37:16.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-02-13T20:15:36.000Z (over 12 years ago)
- Last Synced: 2025-04-04T09:23:20.795Z (about 1 year ago)
- Language: C
- Homepage:
- Size: 203 KB
- Stars: 37
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://travis-ci.org/chansen/c-timestamp) [](https://coveralls.io/r/chansen/c-timestamp)
timestamp
=========
```c
typedef struct {
int64_t sec; /* Number of seconds since the epoch of 1970-01-01T00:00:00Z */
int32_t nsec; /* Nanoseconds [0, 999999999] */
int16_t offset; /* Offset from UTC in minutes [-1439, 1439] */
} timestamp_t;
int timestamp_parse (const char *str, size_t len, timestamp_t *tsp);
size_t timestamp_format (char *dst, size_t len, const timestamp_t *tsp);
size_t timestamp_format_precision (char *dst, size_t len, const timestamp_t *tsp, int precision);
int timestamp_compare (const timestamp_t *tsp1, const timestamp_t *tsp2);
bool timestamp_valid (const timestamp_t *tsp);
struct tm * timestamp_to_tm_utc (const timestamp_t *tsp, struct tm *tmp);
struct tm * timestamp_to_tm_local (const timestamp_t *tsp, struct tm *tmp);
```