Changeset bb65ccb3 in mainline for uspace/app/taskbar/clock.c
- Timestamp:
- 2023-04-14T13:05:15Z (17 months ago)
- Children:
- 00ef082
- Parents:
- 4bfb5a0
- git-author:
- SimonJRiddix <69309548+simonjriddix@…> (2023-04-14 13:05:15)
- git-committer:
- GitHub <noreply@…> (2023-04-14 13:05:15)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/taskbar/clock.c
r4bfb5a0 rbb65ccb3 61 61 }; 62 62 63 ClockFormat function_clock_format = american_clock_format; 64 65 usec_t clock_refresh_seconds = 5 * 1000 * 1000; 66 bool use_seconds = false; 67 bool italian_format = true; 68 69 void american_clock_format(struct tm time, char *buf, size_t bsize) 70 { 71 if(time.tm_hour == 0) 72 snprintf(buf, bsize, "%02d:%02d PM", time.tm_hour, time.tm_min); 73 else if(time.tm_hour > 12) 74 snprintf(buf, bsize, "%02d:%02d PM", time.tm_hour % 12, time.tm_min); 75 else 76 snprintf(buf, bsize, "%02d:%02d AM", time.tm_hour, time.tm_min); 77 } 78 79 void american_seconds_clock_format(struct tm time, char *buf, size_t bsize) 80 { 81 if(time.tm_hour == 0) 82 snprintf(buf, bsize, "%02d:%02d:%02d PM", time.tm_hour, time.tm_min, time.tm_sec); 83 else if(time.tm_hour > 12) 84 snprintf(buf, bsize, "%02d:%02d:%02d PM", time.tm_hour % 12, time.tm_min, time.tm_sec); 85 else 86 snprintf(buf, bsize, "%02d:%02d:%02d AM", time.tm_hour, time.tm_min, time.tm_sec); 87 } 88 89 void italian_clock_format(struct tm time, char *buf, size_t bsize) 90 { 91 snprintf(buf, bsize, "%02d:%02d", time.tm_hour, time.tm_min); 92 } 93 94 void italian_seconds_clock_format(struct tm time, char *buf, size_t bsize) 95 { 96 snprintf(buf, bsize, "%02d:%02d:%02d", time.tm_hour, time.tm_min, time.tm_sec); 97 } 98 99 void set_clock_format(void) 100 { 101 if(italian_format) 102 { 103 function_clock_format = (use_seconds) ? italian_seconds_clock_format : italian_clock_format; 104 } 105 else 106 { 107 function_clock_format = (use_seconds) ? american_seconds_clock_format : american_clock_format; 108 } 109 } 110 63 111 /** Create task bar clock. 64 112 * … … 71 119 taskbar_clock_t *clock; 72 120 errno_t rc; 121 122 set_clock_format(); 73 123 74 124 clock = calloc(1, sizeof(taskbar_clock_t)); … … 91 141 fibril_mutex_initialize(&clock->lock); 92 142 fibril_condvar_initialize(&clock->timer_done_cv); 93 fibril_timer_set(clock->timer, 1000000, taskbar_clock_timer, clock);143 fibril_timer_set(clock->timer, clock_refresh_seconds, taskbar_clock_timer, clock); 94 144 95 145 clock->window = window; … … 136 186 { 137 187 struct timespec ts; 138 struct tm t m;188 struct tm time; 139 189 errno_t rc; 140 190 141 191 getrealtime(&ts); 142 rc = time_utc2tm(ts.tv_sec, &t m);192 rc = time_utc2tm(ts.tv_sec, &time); 143 193 if (rc != EOK) 144 194 return rc; 145 195 146 snprintf(buf, bsize, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min,147 tm.tm_sec);196 function_clock_format(time, buf, bsize); 197 148 198 return EOK; 149 199 } … … 327 377 328 378 if (!clock->timer_cleanup) { 329 fibril_timer_set(clock->timer, 1000000, taskbar_clock_timer,379 fibril_timer_set(clock->timer, clock_refresh_seconds, taskbar_clock_timer, 330 380 clock); 331 381 } else {
Note:
See TracChangeset
for help on using the changeset viewer.