tst_wcsftime.c 626 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <features.h>
  4. #ifdef __UCLIBC_HAS_WCHAR__
  5. #include <wchar.h>
  6. int
  7. main (int argc, char *argv[])
  8. {
  9. wchar_t buf[200];
  10. time_t t;
  11. struct tm *tp;
  12. int result = 0;
  13. size_t n;
  14. time (&t);
  15. tp = gmtime (&t);
  16. n = wcsftime (buf, sizeof (buf) / sizeof (buf[0]),
  17. L"%H:%M:%S %Y-%m-%d\n", tp);
  18. if (n != 21)
  19. result = 1;
  20. wprintf (L"It is now %ls", buf);
  21. wcsftime (buf, sizeof (buf) / sizeof (buf[0]), L"%A\n", tp);
  22. wprintf (L"The weekday is %ls", buf);
  23. return result;
  24. }
  25. #else
  26. int main(void)
  27. {
  28. puts("Test requires WCHAR support; skipping");
  29. return 0;
  30. }
  31. #endif