mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-30 13:13:43 +08:00
1baae4aa6f
It doesn't make sense to remove all the internal uses of time. It's still a standard ISO C function, and its callers don't need sub-second resolution and would be unnecessarily complicated if they had to declare a struct timespec instead of just a time_t. However, a handful of places were using the vestigial "result" argument instead of the return value, which is slightly less efficient and also looks strange. Correct this. * misc/syslog.c (__vsyslog_internal) * time/getdate.c (__getdate_r) * time/tst_wcsftime.c (main): Use return value of time, not its argument. * string/strfry.c (strfry) * sysdeps/mach/sleep.c (__sleep): Remove unnecessary casts of NULL in calls to time.
29 lines
471 B
C
29 lines
471 B
C
#include <time.h>
|
|
#include <wchar.h>
|
|
|
|
int
|
|
main (int argc, char *argv[])
|
|
{
|
|
wchar_t buf[200];
|
|
time_t t;
|
|
struct tm *tp;
|
|
int result = 0;
|
|
size_t n;
|
|
|
|
t = time (NULL);
|
|
tp = gmtime (&t);
|
|
|
|
n = wcsftime (buf, sizeof (buf) / sizeof (buf[0]),
|
|
L"%H:%M:%S %Y-%m-%d\n", tp);
|
|
if (n != 21)
|
|
result = 1;
|
|
|
|
wprintf (L"It is now %ls", buf);
|
|
|
|
wcsftime (buf, sizeof (buf) / sizeof (buf[0]), L"%A\n", tp);
|
|
|
|
wprintf (L"The weekday is %ls", buf);
|
|
|
|
return result;
|
|
}
|