- outwalk += strftime(outwalk, 4095, format, &tm);
+
+ // When hide_if_equals_localtime is true, compare local and target time to display only if different
+ time_t local_t = mktime(&local_tm);
+ double diff = difftime(local_t, t);
+ if (hide_if_equals_localtime && diff == 0.0) {
+ goto out;
+ }
+
+ if (locale != NULL) {
+ setlocale(LC_ALL, locale);
+ }
+
+ if (format_time == NULL) {
+ strftime(timebuf, sizeof(timebuf), format, &tm);
+ maybe_escape_markup(timebuf, &outwalk);
+ } else {
+ for (walk = format; *walk != '\0'; walk++) {
+ if (*walk != '%') {
+ *(outwalk++) = *walk;
+
+ } else if (BEGINS_WITH(walk + 1, "time")) {
+ strftime(timebuf, sizeof(timebuf), format_time, &tm);
+ maybe_escape_markup(timebuf, &outwalk);
+ walk += strlen("time");
+
+ } else {
+ *(outwalk++) = '%';
+ }
+ }
+ }
+
+ if (locale != NULL) {
+ setlocale(LC_ALL, "");
+ }
+
+out: