Print this page
2849 uptime should use locale settings for current time

*** 133,143 **** static void showtotals(struct uproc *); static void calctotals(struct uproc *); static char *getty(dev_t); static void prttime(time_t, char *); static void prtat(time_t *); - static void checkampm(char *); static char *prog; static int header = 1; /* true if -h flag: don't print heading */ static int lflag = 0; /* true if -l flag: w command format */ static char *sel_user; /* login of particular user selected */ --- 133,142 ----
*** 289,299 **** /* * print current time and date */ (void) strftime(date_buf, sizeof (date_buf), ! dcgettext(NULL, "%C", LC_TIME), localtime(&now)); (void) printf("%s\n", date_buf); /* * print system name */ --- 288,298 ---- /* * print current time and date */ (void) strftime(date_buf, sizeof (date_buf), ! "%+", localtime(&now)); (void) printf("%s\n", date_buf); /* * print system name */
*** 766,790 **** p = localtime(time); if (now - *time <= 18 * HR) { char timestr[50]; (void) strftime(timestr, sizeof (timestr), ! dcgettext(NULL, " %l:%M""%p", LC_TIME), p); ! checkampm(timestr); (void) printf("%s", timestr); } else if (now - *time <= 7 * DAY) { char weekdaytime[20]; (void) strftime(weekdaytime, sizeof (weekdaytime), ! dcgettext(NULL, "%a%l%p", LC_TIME), p); ! checkampm(weekdaytime); (void) printf(" %s", weekdaytime); } else { char monthtime[20]; (void) strftime(monthtime, sizeof (monthtime), ! dcgettext(NULL, "%e%b%y", LC_TIME), p); (void) printf(" %s", monthtime); } } /* --- 765,787 ---- p = localtime(time); if (now - *time <= 18 * HR) { char timestr[50]; (void) strftime(timestr, sizeof (timestr), ! " %R ", p); (void) printf("%s", timestr); } else if (now - *time <= 7 * DAY) { char weekdaytime[20]; (void) strftime(weekdaytime, sizeof (weekdaytime), ! "%a%H ", p); (void) printf(" %s", weekdaytime); } else { char monthtime[20]; (void) strftime(monthtime, sizeof (monthtime), ! "%e%b%y", p); (void) printf(" %s", monthtime); } } /*
*** 828,844 **** } *c = '?'; } } } - - /* replaces all occurences of AM/PM with am/pm */ - static void - checkampm(char *str) - { - char *ampm; - while ((ampm = strstr(str, "AM")) != NULL || - (ampm = strstr(str, "PM")) != NULL) { - *ampm = tolower(*ampm); - *(ampm+1) = tolower(*(ampm+1)); - } - } --- 825,829 ----