]> Kevux Git Server - kevux-tools/commitdiff
Update: Switch to the FLL functions for generating time.
authorKevin Day <Kevin@kevux.org>
Mon, 24 Nov 2025 02:28:38 +0000 (20:28 -0600)
committerKevin Day <Kevin@kevux.org>
Mon, 24 Nov 2025 02:28:38 +0000 (20:28 -0600)
The time Object now properly appears in the packet.

sources/c/program/kevux/tools/tacocat/main/send.c
sources/c/program/kevux/tools/tacocat/main/send.h

index 5b11de81e4dc747531fd3385722f27c45ed87b60..7ef19f69a1eb43e746acbcd8ca3f5c947b08b46f 100644 (file)
@@ -500,39 +500,32 @@ extern "C" {
 
     set->time.used = 0;
 
-    f_string_t string = f_string_t_initialize;
-
     {
-      time_t t = time(NULL);
-
-      string = asctime(gmtime(&t));
-    }
+      time_t t = 0;
+      f_time_part_t part = f_time_part_t_initialize;
 
-    if (string) {
-      f_number_unsigned_t total = strnlen(string, kt_tacocat_max_asctime_d);
+      set->status = f_time_epoch_get(&t);
 
-      // Do not count the NULL (some strnlen() implementations, like glibc, appear to incorrectly include the terminating NULL in the count.
-      if (total && !string[total]) {
-        --total;
+      if (F_status_is_error_not(set->status)) {
+        set->status = f_time_utc_get(t, &part);
       }
 
-      set->status = f_memory_array_increase_by(total + kt_tacocat_time_utc_s.used + 1, sizeof(f_char_t), (void **) &set->time.string, &set->time.used, &set->time.size);
-      if (F_status_is_error(set->status)) return;
-
-      set->status = f_string_append(string, total, &set->time);
-      if (F_status_is_error(set->status)) return;
+      if (F_status_is_error_not(set->status)) {
+        set->status = f_time_calendar_string_part(part, &set->time);
+      }
+    }
 
+    if (F_status_is_error_not(set->status)) {
       set->status = f_string_dynamic_append(kt_tacocat_time_utc_s, &set->time);
-      if (F_status_is_error(set->status)) return;
+    }
 
+    if (F_status_is_error_not(set->status)) {
       set->status = f_string_dynamic_terminate_after(&set->time);
-      if (F_status_is_error(set->status)) return;
+    }
 
+    if (F_status_is_error_not(set->status)) {
       set->status = F_okay;
     }
-    else {
-      set->status = F_status_set_error(F_time);
-    }
   }
 #endif // _di_kt_tacocat_send_process_time_now_
 
index 65fa18c9f24cf23fb2c933c77d7045f24b5d1265..6899a8a1f154311f2305bf7a58e84898ea49a8ad 100644 (file)
@@ -123,19 +123,17 @@ extern "C" {
  *
  *     F_time (with error bit) on failure to get the time.
  *
- *     Errors (with error bit) from: f_memory_array_increase_by().
- *     Errors (with error bit) from: f_string_append().
  *     Errors (with error bit) from: f_string_dynamic_append().
  *     Errors (with error bit) from: f_string_dynamic_terminate_after().
+ *     Errors (with error bit) from: f_time_calendar_string_part().
+ *     Errors (with error bit) from: f_time_epoch_get().
+ *     Errors (with error bit) from: f_time_utc_get().
  *
- * @see f_memory_array_increase_by()
- * @see f_string_append()
  * @see f_string_dynamic_append()
  * @see f_string_dynamic_terminate_after()
- *
- * @see asctime()
- * @see gmtime()
- * @see strnlen()
+ * @see f_time_calendar_string_part()
+ * @see f_time_epoch_get()
+ * @see f_time_utc_get()
  */
 #ifndef _di_kt_tacocat_send_process_time_now_
   extern void kt_tacocat_send_process_time_now(kt_tacocat_socket_set_t * const set);