QSC Post Quantum Cryptographic Library 1.0.0.6c (A6)
A post quantum secure library written in Ansi C
 
Loading...
Searching...
No Matches
timestamp.h
Go to the documentation of this file.
1/* 2025 Quantum Resistant Cryptographic Solutions Corporation
2 * All Rights Reserved.
3 *
4 * NOTICE: This software and all accompanying materials are the exclusive
5 * property of Quantum Resistant Cryptographic Solutions Corporation (QRCS).
6 * The intellectual and technical concepts contained within this implementation
7 * are proprietary to QRCS and its authorized licensors and are protected under
8 * applicable U.S. and international copyright, patent, and trade secret laws.
9 *
10 * CRYPTOGRAPHIC STANDARDS:
11 * - This software includes implementations of cryptographic algorithms such as
12 * SHA3, AES, and others. These algorithms are public domain or standardized
13 * by organizations such as NIST and are NOT the property of QRCS.
14 * - However, all source code, optimizations, and implementations in this library
15 * are original works of QRCS and are protected under this license.
16 *
17 * RESTRICTIONS:
18 * - Redistribution, modification, or unauthorized distribution of this software,
19 * in whole or in part, is strictly prohibited.
20 * - This software is provided for non-commercial, educational, and research
21 * purposes only. Commercial use in any form is expressly forbidden.
22 * - Licensing and authorized distribution are solely at the discretion of QRCS.
23 * - Any use of this software implies acceptance of these restrictions.
24 *
25 * DISCLAIMER:
26 * This software is provided "as is," without warranty of any kind, express or
27 * implied, including but not limited to warranties of merchantability or fitness
28 * for a particular purpose. QRCS disclaims all liability for any direct, indirect,
29 * incidental, or consequential damages resulting from the use or misuse of this software.
30 *
31 * FULL LICENSE:
32 * This software is subject to the **Quantum Resistant Cryptographic Solutions
33 * Proprietary License (QRCS-PL)**. The complete license terms are included
34 * in the LICENSE.txt file distributed with this software.
35 *
36 * Written by: John G. Underhill
37 * Contact: john.underhill@protonmail.com
38 */
39
40#ifndef QSC_TIMESTAMP_H
41#define QSC_TIMESTAMP_H
42
43#include "common.h"
44#include <time.h>
45
46QSC_CPLUSPLUS_ENABLED_START
47
94
99#define QSC_TIMESTAMP_EPOCH_START 1900ULL
100
105#define QSC_TIMESTAMP_SECONDS_PER_MINUTE 60ULL
106
111#define QSC_TIMESTAMP_SECONDS_PER_HOUR (QSC_TIMESTAMP_SECONDS_PER_MINUTE * 60ULL)
112
117#define QSC_TIMESTAMP_SECONDS_PER_DAY (QSC_TIMESTAMP_SECONDS_PER_HOUR * 24ULL)
118
123#define QSC_TIMESTAMP_STRING_SIZE 20ULL
124
131
139
146
153
161QSC_EXPORT_API void qsc_timestamp_time_struct_to_string(char output[QSC_TIMESTAMP_STRING_SIZE], const struct tm* tstruct);
162
170QSC_EXPORT_API void qsc_timestamp_string_to_time_struct(struct tm* tstruct, const char input[QSC_TIMESTAMP_STRING_SIZE]);
171
183
191
198
206
207#if defined(QSC_DEBUG_MODE)
211QSC_EXPORT_API void qsc_timestamp_print_values(void);
212#endif
213
214QSC_CPLUSPLUS_ENABLED_END
215
216#endif
Contains common definitions for the Quantum Secure Cryptographic (QSC) library.
#define QSC_EXPORT_API
API export macro for Microsoft compilers when importing from a DLL.
Definition common.h:520
QSC_EXPORT_API uint64_t qsc_timestamp_datetime_to_seconds(const char input[QSC_TIMESTAMP_STRING_SIZE])
Convert the date-time string to a seconds from epoch unsigned 64-bit integer.
Definition timestamp.c:282
QSC_EXPORT_API uint64_t qsc_timestamp_epochtime_seconds(void)
Get the date and time from the current locale in seconds from epoch.
Definition timestamp.c:362
QSC_EXPORT_API uint64_t qsc_timestamp_datetime_seconds_remaining(const char basetime[QSC_TIMESTAMP_STRING_SIZE], const char comptime[QSC_TIMESTAMP_STRING_SIZE])
Compare a base date-time with another future date-time string, and return the difference in seconds....
Definition timestamp.c:253
QSC_EXPORT_API void qsc_timestamp_time_struct_to_string(char output[QSC_TIMESTAMP_STRING_SIZE], const struct tm *tstruct)
Convert a time structure to a date and time string. Time-stamp string format is YYYY-MM-DD HH-MM-SS.
Definition timestamp.c:9
QSC_EXPORT_API void qsc_timestamp_current_datetime(char output[QSC_TIMESTAMP_STRING_SIZE])
Get the calendar date and time from the current locale. Time-stamp string format is YYYY-MM-DD HH-MM-...
Definition timestamp.c:173
#define QSC_TIMESTAMP_STRING_SIZE
The size of the time-stamp string.
Definition timestamp.h:123
QSC_EXPORT_API void qsc_timestamp_current_time(char output[QSC_TIMESTAMP_STRING_SIZE])
Get the local time.
Definition timestamp.c:206
QSC_EXPORT_API void qsc_timestamp_current_date(char output[QSC_TIMESTAMP_STRING_SIZE])
Get the calendar date from the current locale.
Definition timestamp.c:126
QSC_EXPORT_API void qsc_timestamp_string_to_time_struct(struct tm *tstruct, const char input[QSC_TIMESTAMP_STRING_SIZE])
Convert a date and time string to a time structure. Time-stamp string format must be YYYY-MM-DD HH-MM...
Definition timestamp.c:100
QSC_EXPORT_API uint64_t qsc_timestamp_datetime_utc(void)
Get the calendar date and time for utc time.
Definition timestamp.c:298
QSC_EXPORT_API void qsc_timestamp_seconds_to_datetime(uint64_t tsec, char output[QSC_TIMESTAMP_STRING_SIZE])
Convert a seconds count from epoch-time to a date-time string.
Definition timestamp.c:330