diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/c/fastforge_core.c | 18 | ||||
| -rw-r--r-- | src/c/fastforge_logic.c | 32 |
2 files changed, 21 insertions, 29 deletions
diff --git a/src/c/fastforge_core.c b/src/c/fastforge_core.c index 39d9ea8..c9d3ce1 100644 --- a/src/c/fastforge_core.c +++ b/src/c/fastforge_core.c @@ -61,6 +61,24 @@ static int compare_time_t_ascending(const void *a, const void *b) { return 0; } +time_t fastforge_local_day_start_platform(time_t timestamp) { + if (timestamp <= 0) { + return 0; + } + + struct tm *tm_info = localtime(×tamp); + if (!tm_info) { + return 0; + } + + struct tm tm_copy = *tm_info; + tm_copy.tm_hour = 0; + tm_copy.tm_min = 0; + tm_copy.tm_sec = 0; + tm_copy.tm_isdst = -1; + return mktime(&tm_copy); +} + static bool is_next_local_day(time_t first_day, time_t second_day) { if (first_day <= 0 || second_day <= 0 || second_day < first_day) { return false; diff --git a/src/c/fastforge_logic.c b/src/c/fastforge_logic.c index b8b44da..b765e83 100644 --- a/src/c/fastforge_logic.c +++ b/src/c/fastforge_logic.c @@ -3,24 +3,6 @@ #include <stdio.h> #include <time.h> -#ifndef __struct_tm_defined -#define FASTFORGE_TZ_LEN 6 -struct tm { - int tm_sec; - int tm_min; - int tm_hour; - int tm_mday; - int tm_mon; - int tm_year; - int tm_wday; - int tm_yday; - int tm_isdst; - int tm_gmtoff; - char tm_zone[FASTFORGE_TZ_LEN]; -}; -#endif -struct tm *localtime(const time_t *timep); -time_t mktime(struct tm *tb); time_t entry_duration_seconds(const FastEntry *entry) { if (!entry || entry->start_time == 0 || entry->end_time <= entry->start_time) { @@ -74,22 +56,14 @@ void format_duration_hours_minutes(time_t seconds, char *buffer, size_t size) { snprintf(buffer, size, "%dh %02dm", hours, minutes); } +time_t fastforge_local_day_start_platform(time_t timestamp); + time_t local_day_start(time_t timestamp) { if (timestamp <= 0) { return 0; } - struct tm *tm_info = localtime(×tamp); - if (!tm_info) { - return 0; - } - - struct tm tm_copy = *tm_info; - tm_copy.tm_hour = 0; - tm_copy.tm_min = 0; - tm_copy.tm_sec = 0; - tm_copy.tm_isdst = -1; - return mktime(&tm_copy); + return fastforge_local_day_start_platform(timestamp); } bool running_fast_is_at_target(const FastEntry *entry, time_t now) { |
