Flipper/Applications/Official/source-OLDER/xMasterX/flipp_pomodoro/helpers/time.c

22 lines
589 B
C
Raw Normal View History

2023-01-26 07:52:38 +00:00
#include <furi.h>
#include <furi_hal.h>
#include "time.h"
const int TIME_SECONDS_IN_MINUTE = 60;
const int TIME_MINUTES_IN_HOUR = 60;
uint32_t time_now()
{
return furi_hal_rtc_get_timestamp();
};
TimeDifference time_difference_seconds(uint32_t begin, uint32_t end)
{
const uint32_t duration_seconds = end - begin;
uint32_t minutes = (duration_seconds / TIME_MINUTES_IN_HOUR) % TIME_MINUTES_IN_HOUR;
uint32_t seconds = duration_seconds % TIME_SECONDS_IN_MINUTE;
return (TimeDifference){.total_seconds = duration_seconds, .minutes = minutes, .seconds = seconds};
};