summaryrefslogtreecommitdiff
path: root/apps/menus
diff options
context:
space:
mode:
Diffstat (limited to 'apps/menus')
-rw-r--r--apps/menus/settings_menu.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c
index 939a2f3c8c..bc253ed398 100644
--- a/apps/menus/settings_menu.c
+++ b/apps/menus/settings_menu.c
@@ -202,14 +202,20 @@ static int timedate_set(void)
202 /* This prevents problems with time/date setting after a power loss */ 202 /* This prevents problems with time/date setting after a power loss */
203 if (!valid_time(&tm)) 203 if (!valid_time(&tm))
204 { 204 {
205 /* hour */ 205/* Macros to convert a 2-digit string to a decimal constant.
206 (YEAR), MONTH and DAY are set by the date command, which outputs
207 DAY as 00..31 and MONTH as 01..12. The leading zero would lead to
208 misinterpretation as an octal constant. */
209#define S100(x) 1 ## x
210#define C2DIG2DEC(x) (S100(x)-100)
211
206 tm.tm_hour = 0; 212 tm.tm_hour = 0;
207 tm.tm_min = 0; 213 tm.tm_min = 0;
208 tm.tm_sec = 0; 214 tm.tm_sec = 0;
209 tm.tm_mday = 1; 215 tm.tm_mday = C2DIG2DEC(DAY);
210 tm.tm_mon = 0; 216 tm.tm_mon = C2DIG2DEC(MONTH)-1;
211 tm.tm_wday = 1; 217 tm.tm_wday = 1;
212 tm.tm_year = 100; 218 tm.tm_year = YEAR-1900;
213 } 219 }
214 220
215 result = (int)set_time_screen(str(LANG_TIME), &tm); 221 result = (int)set_time_screen(str(LANG_TIME), &tm);