QSC Post Quantum Cryptographic Library 1.1.0.2 (B2)
A post quantum secure library written in Ansi C
Loading...
Searching...
No Matches
timestamp.h
Go to the documentation of this file.
1/* 2020-2026 Quantum Resistant Cryptographic Solutions Corporation
2 * All Rights Reserved.
3 *
4 * NOTICE:
5 * This software and all accompanying materials are the exclusive property of
6 * Quantum Resistant Cryptographic Solutions Corporation (QRCS). The intellectual
7 * and technical concepts contained herein are proprietary to QRCS and are
8 * protected under applicable Canadian, U.S., and international copyright,
9 * patent, and trade secret laws.
10 *
11 * CRYPTOGRAPHIC ALGORITHMS AND IMPLEMENTATIONS:
12 * - This software includes implementations of cryptographic primitives and
13 * algorithms that are standardized or in the public domain, such as AES
14 * and SHA-3, which are not proprietary to QRCS.
15 * - This software also includes cryptographic primitives, constructions, and
16 * algorithms designed by QRCS, including but not limited to RCS, SCB, CSX, QMAC, and
17 * related components, which are proprietary to QRCS.
18 * - All source code, implementations, protocol compositions, optimizations,
19 * parameter selections, and engineering work contained in this software are
20 * original works of QRCS and are protected under this license.
21 *
22 * LICENSE AND USE RESTRICTIONS:
23 * - This software is licensed under the Quantum Resistant Cryptographic Solutions
24 * Public Research and Evaluation License (QRCS-PREL), 2025-2026.
25 * - Permission is granted solely for non-commercial evaluation, academic research,
26 * cryptographic analysis, interoperability testing, and feasibility assessment.
27 * - Commercial use, production deployment, commercial redistribution, or
28 * integration into products or services is strictly prohibited without a
29 * separate written license agreement executed with QRCS.
30 * - Licensing and authorized distribution are solely at the discretion of QRCS.
31 *
32 * EXPERIMENTAL CRYPTOGRAPHY NOTICE:
33 * Portions of this software may include experimental, novel, or evolving
34 * cryptographic designs. Use of this software is entirely at the user's risk.
35 *
36 * DISCLAIMER:
37 * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38 * IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS
39 * FOR A PARTICULAR PURPOSE, SECURITY, OR NON-INFRINGEMENT. QRCS DISCLAIMS ALL
40 * LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
41 * ARISING FROM THE USE OR MISUSE OF THIS SOFTWARE.
42 *
43 * FULL LICENSE:
44 * This software is subject to the Quantum Resistant Cryptographic Solutions
45 * Public Research and Evaluation License (QRCS-PREL), 2025-2026. The complete license terms
46 * are provided in the accompanying LICENSE file or at https://www.qrcscorp.ca.
47 *
48 * Written by: John G. Underhill
49 * Contact: contact@qrcscorp.ca
50 */
51
52#ifndef QSC_TIMESTAMP_H
53#define QSC_TIMESTAMP_H
54
55#include "qsccommon.h"
56#include <time.h>
57
58QSC_CPLUSPLUS_ENABLED_START
59
106
111#define QSC_TIMESTAMP_EPOCH_START 1900ULL
112
117#define QSC_TIMESTAMP_SECONDS_PER_MINUTE 60U
118
123#define QSC_TIMESTAMP_SECONDS_PER_HOUR (QSC_TIMESTAMP_SECONDS_PER_MINUTE * 60U)
124
129#define QSC_TIMESTAMP_SECONDS_PER_DAY (QSC_TIMESTAMP_SECONDS_PER_HOUR * 24U)
130
135#define QSC_TIMESTAMP_STRING_SIZE 20U
136
143
151
158
165
172
179
187QSC_EXPORT_API void qsc_timestamp_time_struct_to_string(char output[QSC_TIMESTAMP_STRING_SIZE], const struct tm* tstruct);
188
196QSC_EXPORT_API void qsc_timestamp_string_to_time_struct(struct tm* tstruct, const char input[QSC_TIMESTAMP_STRING_SIZE]);
197
209
217
224
232
233#if defined(QSC_DEBUG_MODE)
237QSC_EXPORT_API void qsc_timestamp_print_values(void);
238#endif
239
240QSC_CPLUSPLUS_ENABLED_END
241
242#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 qsccommon.h:605
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:339
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:438
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:297
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:12
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:197
#define QSC_TIMESTAMP_STRING_SIZE
The size of the time-stamp string.
Definition timestamp.h:135
QSC_EXPORT_API void qsc_timestamp_current_time(char output[QSC_TIMESTAMP_STRING_SIZE])
Get the local time.
Definition timestamp.c:240
QSC_EXPORT_API uint64_t qsc_timestamp_epochtime_microseconds(void)
Get the date and time from the current locale in microseconds from epoch.
Definition timestamp.c:471
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:140
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:107
QSC_EXPORT_API uint64_t qsc_timestamp_datetime_utc(void)
Get the calendar date and time for utc time.
Definition timestamp.c:362
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:397
QSC_EXPORT_API uint64_t qsc_timestamp_epochtime_milliseconds(void)
Get the date and time from the current locale in milliseconds from epoch.
Definition timestamp.c:452