format date

This commit is contained in:
Marc Pasteur 2026-03-01 16:50:11 +01:00
parent b7552e15ce
commit bce9f03eb4

View File

@ -1310,13 +1310,25 @@ static void time_observer_cb(lv_observer_t *observer, lv_subject_t *subject)
lv_obj_t *parent = observer->target;
struct tm *timeStruct=lv_subject_get_pointer(subject);
lv_obj_t *hour = lv_obj_get_child_by_name(parent, "hour");
lv_obj_t *minute = lv_obj_get_child_by_name(parent, "minute");
lv_obj_t *day = lv_obj_find_by_name(parent, "day");
lv_obj_t *month = lv_obj_find_by_name(parent, "month");
lv_obj_t *hour = lv_obj_find_by_name(parent, "hour");
lv_obj_t *minute = lv_obj_find_by_name(parent, "minute");
int d = timeStruct->tm_mday;
int monthVal = timeStruct->tm_mon;
int h = timeStruct->tm_hour;
int m = timeStruct->tm_min;
char buf[3];
char buf[12];
snprintf(buf, sizeof(buf), "%02d", d);
lv_label_set_text(day, buf);
snprintf(buf, sizeof(buf), "%02d", monthVal+1);
lv_label_set_text(month, buf);
snprintf(buf, sizeof(buf), "%02d", h);
lv_label_set_text(hour, buf);
@ -1787,20 +1799,41 @@ void messageCardContent(lv_obj_t *cont_messages)
//lv_obj_remove_style_all(date_and_time);
lv_obj_set_size(date_and_time, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_t *date = lv_spangroup_create(date_and_time);
lv_obj_t *date = lv_obj_create(date_and_time);
lv_obj_set_name(date, "date");
lv_obj_set_id(date, "date");
lv_obj_set_size(date, 250, LV_SIZE_CONTENT);
lv_obj_clear_flag(date, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_set_style_bg_opa(date, LV_OPA_TRANSP, 0);
lv_obj_set_style_border_width(date, 0, 0);
// Layout flex horizontal
lv_obj_set_flex_flow(date, LV_FLEX_FLOW_ROW);
lv_obj_set_flex_align(
date,
LV_FLEX_ALIGN_SPACE_BETWEEN, // répartit les enfants
LV_FLEX_ALIGN_CENTER, // align vertical
LV_FLEX_ALIGN_CENTER
);
// lv_obj_add_style(date, &c->fonts[FONT_HEADING_MD], 0);
// lv_obj_add_style(date, &c->styles[STYLE_COLOR_BASE][STYLE_TYPE_TEXT], 0);
lv_span_t *day = lv_spangroup_add_span(date);
lv_span_set_text(day, "--");
lv_style_set_text_font(lv_span_get_style(day), &super_malibu_80);
lv_style_set_text_color(lv_span_get_style(day), base);
lv_style_set_line_color(lv_span_get_style(day), lv_color_black());
lv_style_set_line_width(lv_span_get_style(day), 2);
lv_span_t *month = lv_spangroup_add_span(date);
lv_span_set_text(month, "--");
lv_style_set_text_font(lv_span_get_style(month), &super_malibu_80);
lv_obj_t *day = lv_label_create(date);
lv_obj_set_name(day, "day");
lv_label_set_text(day, "--");
lv_obj_set_style_text_font(day, &super_malibu_80, 0);
lv_obj_set_style_text_color(day, lv_color_white(), 0);
lv_obj_set_style_line_color(day, lv_color_black(), 0);
lv_obj_set_style_line_width(day, 2, 0);
// --- / ---
lv_obj_t *slash_lbl = lv_label_create(date);
lv_obj_set_name(slash_lbl, "slash");
lv_obj_set_style_text_font(slash_lbl, &super_malibu_80, 0);
lv_obj_set_style_text_color(slash_lbl, base, 0);
lv_label_set_text(slash_lbl, "/");
lv_obj_t *month = lv_label_create(date);
lv_obj_set_name(month, "month");
lv_label_set_text(month, "--");
lv_obj_set_style_text_font(month, &super_malibu_80,0);
lv_obj_t *objTime = lv_obj_create(date_and_time);
lv_obj_set_size(objTime, 250, LV_SIZE_CONTENT);
@ -1840,7 +1873,7 @@ void messageCardContent(lv_obj_t *cont_messages)
// Init datetime
//datetime_ctx_init(date_and_time);
lv_subject_add_observer_obj(&timeSubj, time_observer_cb, objTime, NULL);
lv_subject_add_observer_obj(&timeSubj, time_observer_cb, date_and_time, NULL);
lv_obj_t * subContent = lv_obj_create(info_area);
lv_obj_set_flex_flow(subContent, LV_FLEX_FLOW_COLUMN);