PebbleOS
Loading...
Searching...
No Matches
Macros | Enumerations | Functions
clock.h File Reference
#include <stdbool.h>
#include <inttypes.h>
#include <time.h>

Macros

#define TIMEZONE_NAME_LENGTH   32
 The maximum length for a timezone full name (e.g.
 
#define TIME_STRING_REQUIRED_LENGTH   20
 Buffer size for common strings like "Wednesday" or "30 minutes ago".
 
#define TIME_STRING_TIME_LENGTH   10
 Buffer size for a time, e.g.
 
#define TIME_STRING_DATE_LENGTH   10
 Buffer size for a day and month, e.g.
 
#define TIME_STRING_DAY_DATE_LENGTH   3
 Buffer size for a day of the month, e.g.
 

Enumerations

enum  WeekDay {
  TODAY = 0 , SUNDAY , MONDAY , TUESDAY ,
  WEDNESDAY , THURSDAY , FRIDAY , SATURDAY
}
 Weekday values. More...
 

Functions

void clock_init (void)
 Initialize the clock service.
 
void clock_hourly_chime_arm (void)
 Arm the hourly chime.
 
void clock_get_time_tm (struct tm *time_tm)
 Get the current local time from the RTC.
 
size_t clock_format_time (char *buffer, uint8_t size, int16_t hours, int16_t minutes, bool add_space)
 Format a time of day according to the user's 12h/24h preference.
 
size_t clock_copy_time_string_timestamp (char *buffer, uint8_t size, time_t timestamp)
 Same as clock_copy_time_string(), for a given timestamp.
 
void clock_copy_time_string (char *buffer, uint8_t size)
 Copies a time string into the buffer, formatted according to the user's time display preferences (such as 12h/24h time).
 
size_t clock_get_time_number (char *buffer, size_t buffer_size, time_t timestamp)
 Format a time as "7:30" or "15:00" depending on the user's 12h/24h preference.
 
size_t clock_get_time_word (char *buffer, size_t buffer_size, time_t timestamp)
 Get the AM/PM designator of a time.
 
void clock_get_event_relative_time_string (char *number_buffer, int number_buffer_size, char *word_buffer, int word_buffer_size, time_t timestamp, uint16_t duration, time_t current_day, bool all_day)
 Get the relative time string of an event, split in a number and a word.
 
bool clock_is_24h_style (void)
 Gets the user's 12/24h clock style preference.
 
void clock_set_24h_style (bool is_24h_style)
 Set the user's time display style.
 
bool clock_is_timezone_set (void)
 Checks if timezone is currently set, otherwise gmtime == localtime.
 
bool clock_timezone_source_is_manual (void)
 Check whether the timezone is selected manually.
 
void clock_set_manual_timezone_source (bool manual)
 Set the timezone source.
 
bool clock_time_source_is_manual (void)
 Check whether the time is set manually.
 
void clock_set_manual_time_source (bool manual)
 Set the time source.
 
void clock_request_time_from_phone (void)
 Ask the phone to send its current time.
 
void clock_get_timezone_region (char *region_name, const size_t buffer_size)
 Get the name of the current timezone region, e.g.
 
int16_t clock_get_timezone_region_id (void)
 Get the current timezone region.
 
void clock_set_timezone_by_region_id (uint16_t region_id)
 Switch to a timezone region and fire a time change event.
 
void clock_set_time (time_t utc_time)
 Set the current UTC time and fire a time change event.
 
time_t clock_to_timestamp (WeekDay day, int hour, int minute)
 Converts a (day, hour, minute) specification to a UTC timestamp occurring in the future.
 
void clock_get_friendly_date (char *buffer, int buf_size, time_t timestamp)
 Get a friendly date for a timestamp.
 
void clock_get_since_time (char *buffer, int buf_size, time_t timestamp)
 Get a friendly time elapsed since a timestamp, e.g.
 
void clock_get_until_time (char *buffer, int buf_size, time_t timestamp, int max_relative_hrs)
 Get a friendly time relative to a timestamp, e.g.
 
void clock_get_until_time_without_fulltime (char *buffer, int buf_size, time_t timestamp, int max_relative_hrs)
 clock_get_until_time_capitalized() that never writes the time of day.
 
size_t clock_get_date (char *buffer, int buf_size, time_t timestamp)
 Get the date in MM/DD format.
 
size_t clock_get_date_tm (char *buffer, int buf_size, const struct tm *time_tm)
 Same as clock_get_date(), from a broken-down time.
 
size_t clock_get_day_date (char *buffer, int buf_size, time_t timestamp)
 Get the day of the month in DD format.
 
size_t clock_get_month_named_date (char *buffer, size_t buffer_size, time_t timestamp)
 Get the date as month name and day, e.g.
 
size_t clock_get_month_named_abbrev_date (char *buffer, size_t buffer_size, time_t timestamp)
 Get the date as abbreviated month name and day, e.g.
 
void clock_get_until_time_capitalized (char *buffer, int buf_size, time_t timestamp, int max_relative_hrs)
 Capitalized clock_get_until_time(), e.g.
 
const char * clock_get_relative_daypart_string (time_t current_timestamp, uint32_t hours_in_the_future)
 Get a daypart phrase for a time in the future, e.g.
 
void clock_hour_and_minute_add (int *hour, int *minute, int delta_minutes)
 Add minutes to a wall clock time, wrapping around 24 hours.