summaryrefslogtreecommitdiffstats
path: root/watch-library/shared/watch/watch_utility.h
diff options
context:
space:
mode:
authorJoey Castillo <joeycastillo@utexas.edu>2022-02-06 15:00:58 -0500
committerJoey Castillo <joeycastillo@utexas.edu>2022-02-06 15:00:58 -0500
commitaae91604224bb0f10096b41a23b01654a2e46823 (patch)
treea2119c0993af21eb3a75225fd23f93db3c7627f3 /watch-library/shared/watch/watch_utility.h
parent18302bf9c46093c90e6bfea499360e342c996151 (diff)
downloadSensor-Watch-aae91604224bb0f10096b41a23b01654a2e46823.tar.gz
Sensor-Watch-aae91604224bb0f10096b41a23b01654a2e46823.tar.bz2
Sensor-Watch-aae91604224bb0f10096b41a23b01654a2e46823.zip
utility: add function for formatting a duration in days + HMS
Diffstat (limited to 'watch-library/shared/watch/watch_utility.h')
-rw-r--r--watch-library/shared/watch/watch_utility.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/watch-library/shared/watch/watch_utility.h b/watch-library/shared/watch/watch_utility.h
index dc0ebb6a..f4411ce5 100644
--- a/watch-library/shared/watch/watch_utility.h
+++ b/watch-library/shared/watch/watch_utility.h
@@ -32,6 +32,14 @@
* @brief This section covers various useful functions that don't fit anywhere else.
**/
/// @{
+
+typedef struct {
+ uint8_t seconds; // 0-59
+ uint8_t minutes; // 0-59
+ uint8_t hours; // 0-23
+ uint32_t days; // 0-4294967295
+} watch_duration_t;
+
/** @brief Returns a two-letter weekday for the given timestamp, suitable for display
* in positions 0-1 of the watch face
* @param date_time The watch_date_time whose weekday you want.
@@ -60,6 +68,12 @@ uint32_t watch_utility_convert_to_unix_time(uint16_t year, uint8_t month, uint8_
*/
uint32_t watch_utility_date_time_to_unix_time(watch_date_time date_time, uint32_t utc_offset);
+/** @brief Converts a duration in seconds to a watch_duration_t struct.
+ * @param seconds A positive number of seconds that you wish to convert to a formatted duration.
+ * @return A populated struct with the number of days, hours, minutes and seconds elapsed.
+ */
+watch_duration_t watch_utility_seconds_to_duration(uint32_t seconds);
+
/** @brief Returns the UNIX time (seconds since 1970) for a given watch_date_time struct.
* @param timestamp The UNIX timestamp that you wish to convert.
* @param utc_offset The number of seconds that you wish date_time to be offset from UTC.