mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-25 03:29:58 -07:00
21 lines
598 B
C
21 lines
598 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};
|
|
};
|