mirror of
https://github.com/UberGuidoZ/Flipper.git
synced 2024-12-23 23:10:16 +00:00
22 lines
589 B
C
22 lines
589 B
C
|
#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};
|
||
|
};
|