time.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <Kernel/API/POSIX/time.h>
  8. #include <sys/cdefs.h>
  9. __BEGIN_DECLS
  10. struct tm {
  11. int tm_sec; /* Seconds (0-60) */
  12. int tm_min; /* Minutes (0-59) */
  13. int tm_hour; /* Hours (0-23) */
  14. int tm_mday; /* Day of the month (1-31) */
  15. int tm_mon; /* Month (0-11) */
  16. int tm_year; /* Year - 1900 */
  17. int tm_wday; /* Day of the week (0-6, Sunday = 0) */
  18. int tm_yday; /* Day in the year (0-365, 1 Jan = 0) */
  19. int tm_isdst; /* Daylight saving time */
  20. };
  21. extern long timezone; /* The difference in seconds between UTC and local time */
  22. extern long altzone;
  23. extern char* tzname[2];
  24. extern int daylight;
  25. struct tm* localtime(time_t const*);
  26. struct tm* gmtime(time_t const*);
  27. time_t mktime(struct tm*);
  28. time_t timegm(struct tm*);
  29. time_t time(time_t*);
  30. char* ctime(time_t const*);
  31. char* ctime_r(time_t const* tm, char* buf);
  32. void tzset(void);
  33. char* asctime(const struct tm*);
  34. char* asctime_r(const struct tm*, char* buf);
  35. clock_t clock(void);
  36. int clock_gettime(clockid_t, struct timespec*);
  37. int clock_settime(clockid_t, struct timespec*);
  38. int clock_nanosleep(clockid_t, int flags, const struct timespec* requested_sleep, struct timespec* remaining_sleep);
  39. int clock_getres(clockid_t, struct timespec* result);
  40. int nanosleep(const struct timespec* requested_sleep, struct timespec* remaining_sleep);
  41. struct tm* gmtime_r(time_t const* timep, struct tm* result);
  42. struct tm* localtime_r(time_t const* timep, struct tm* result);
  43. double difftime(time_t, time_t);
  44. size_t strftime(char* s, size_t max, char const* format, const struct tm*) __attribute__((format(strftime, 3, 0)));
  45. __END_DECLS