time_helper.h (1460B)
1 #pragma once 2 3 #include <stdbool.h> 4 #include <stddef.h> 5 #include <stdint.h> 6 7 /** 8 * Convert hours, minutes, seconds to total seconds. 9 * 10 * @param h Hours (0-23) 11 * @param m Minutes (0-59) 12 * @param s Seconds (0-59) 13 * @return Total seconds 14 */ 15 uint32_t time_helper_hms_to_seconds(uint8_t h, uint8_t m, uint8_t s); 16 17 /** 18 * Convert total seconds to hours, minutes, seconds. 19 * 20 * @param total_seconds Total seconds to convert 21 * @param h Output: hours (0-23, wraps at 24) 22 * @param m Output: minutes (0-59) 23 * @param s Output: seconds (0-59) 24 */ 25 void time_helper_seconds_to_hms(uint32_t total_seconds, uint8_t *h, uint8_t *m, 26 uint8_t *s); 27 28 #ifndef TIMED_REMOTE_TEST_BUILD 29 /** 30 * Calculate seconds remaining until a target time. 31 * Uses Flipper's RTC. If target time has passed, rolls to next day. 32 * If target time is exactly now, returns 0. 33 * 34 * @param target_h Target hour (0-23) 35 * @param target_m Target minute (0-59) 36 * @param target_s Target second (0-59) 37 * @return Seconds until target (today or next day), or 0 if now 38 */ 39 uint32_t time_helper_seconds_until(uint8_t target_h, uint8_t target_m, 40 uint8_t target_s); 41 42 /** 43 * Generate a timestamp-based signal name placeholder. 44 * Format: IR_YYYYMMDD_HHMMSS 45 * 46 * @param buffer Output buffer (must be at least 20 bytes) 47 * @param buffer_size Size of buffer 48 */ 49 void time_helper_generate_signal_name(char *buffer, size_t buffer_size); 50 #endif