From: Kevin Day Date: Fri, 30 Jun 2023 02:49:14 +0000 (-0500) Subject: Cleanup: Restructure time related types and add f_date_spec_t. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=350b99f27e4527e9b410672991b7a00b4e6eb693;p=fll Cleanup: Restructure time related types and add f_date_spec_t. Make the time based types more interchangeable by using f_time_t. Create a new time type called f_date_spec_t that utilizes f_time_spec_t instead of f_time_t for the time property. --- diff --git a/level_0/f_type/c/type.h b/level_0/f_type/c/type.h index e87d029..d8ad80b 100644 --- a/level_0/f_type/c/type.h +++ b/level_0/f_type/c/type.h @@ -457,28 +457,9 @@ extern "C" { #endif // _di_f_directory_mode_ /** - * A non-kernel dependent version of "struct timespec". - * - * seconds: The total number of seconds. - * nanoseconds: The total number of nanoseconds. - */ -#ifndef _di_f_time_spec_t_ - typedef struct { - uint64_t seconds; - uint64_t nanoseconds; - } f_time_spec_t; - - #define f_time_spec_t_initialize { 0, 0 } - - #define macro_f_time_spec_t_clear(spec) \ - spec.seconds = 0; \ - spec.nanoseconds = 0; -#endif // _di_f_time_spec_t_ - -/** * Hold a unit of Time. * - * This utilizes the unit of measurement called a "Time", represented with uppercase "T". + * This is intended to be utilized for the unit of measurement called a "Time", represented with uppercase "T". * For comparison, a unit of Time is equivalent to a nanosecond, or 10^-9 seconds. * * A unit of Time is intended to represent some unit of Time such that a single 64-bit integer may hold all units of Time for a single calendar year. @@ -504,6 +485,26 @@ extern "C" { #endif // _di_f_time_t_ /** + * A non-kernel dependent version of "struct timespec". + * + * Properties: + * - seconds: The total number of seconds. + * - seconds_nano: The total number of nanoseconds. + */ +#ifndef _di_f_time_spec_t_ + typedef struct { + f_time_t seconds; + f_time_t seconds_nano; + } f_time_spec_t; + + #define f_time_spec_t_initialize { f_time_t_initialize, f_time_t_initialize } + + #define macro_f_time_spec_t_clear(spec) \ + spec.seconds = 0; \ + spec.seconds_nano = 0; +#endif // _di_f_time_spec_t_ + +/** * Hold a unit of Time along with a year to represent a date. * * This implementation of a date using the unit of Time is limited on the size of the year. @@ -515,6 +516,10 @@ extern "C" { * * For example, "2020:86400000000000" would represent: January 02, 2020 0:00 UTC. * For example, "2020:86.4 TT" would represent: January 02, 2020 0:00 UTC. + * + * Properties: + * - year: A number representing the year. + * - time: A number representing the time. */ #ifndef _di_f_date_t_ typedef struct { @@ -530,6 +535,30 @@ extern "C" { #endif // _di_f_date_t_ /** + * A variation of f_date_t that using f_time_spec_t rather than f_time_t. + * + * This can is a more precise alternative to f_date_t because it stores nanoseconds. + * + * The f_time_spec_t.time.seconds can be directly cast to the f_date_t.time. + * + * Properties: + * - year: A number representing the year. + * - time: A number representing the time with seconds and nanoseconds. + */ +#ifndef _di_f_date_spec_t_ + typedef struct { + f_time_t year; + f_time_spec_t time; + } f_date_spec_t; + + #define f_date_spec_t_initialize { f_time_t_initialize, macro_f_time_spec_t_clear } + + #define macro_f_date_spec_t_clear(date) \ + date.year = 0; \ + macro_f_time_spec_t_clear(date.time); +#endif // _di_f_date_spec_t_ + +/** * An array of array lengths. * * The macros are defined in type_array.h or type_array-common.h.