blob: f15185912f47b4095b51f7dff1c11fdc312b2acc [file] [log] [blame] [raw]
/*
* time.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Date and time functions and types.
*
*/
#ifndef _TIME_H
#define _TIME_H
/* All the headers include this file. */
#include <_mingw.h>
#define __need_wchar_t
#define __need_size_t
#define __need_NULL
#include <stddef.h>
#include <sys/types.h>
/*
* Number of clock ticks per second. A clock tick is the unit by which
* processor time is measured and is returned by 'clock'.
*/
#define CLOCKS_PER_SEC ((clock_t)1000)
#define CLK_TCK CLOCKS_PER_SEC
/*
* A type for measuring processor time (in clock ticks).
*/
#ifndef _CLOCK_T_DEFINED
typedef long clock_t;
#define _CLOCK_T_DEFINED
#endif
#ifndef _TM_DEFINED
/*
* A structure for storing all kinds of useful information about the
* current (or another) time.
*/
struct tm {
int tm_sec; /* Seconds: 0-59 (K&R says 0-61?) */
int tm_min; /* Minutes: 0-59 */
int tm_hour; /* Hours since midnight: 0-23 */
int tm_mday; /* Day of the month: 1-31 */
int tm_mon; /* Months *since* january: 0-11 */
int tm_year; /* Years since 1900 */
int tm_wday; /* Days since Sunday (0-6) */
int tm_yday; /* Days since Jan. 1: 0-365 */
int tm_isdst; /* +1 Daylight Savings Time, 0 No DST,
* -1 don't know */
};
#define _TM_DEFINED
#endif
struct timespec {
time_t tv_sec; // Seconds.
long int tv_nsec; // Nanoseconds.
};
#ifdef __cplusplus
extern "C" {
#endif
clock_t __cdecl __MINGW_NOTHROW clock(void);
time_t __cdecl __MINGW_NOTHROW time(time_t *);
double __cdecl __MINGW_NOTHROW difftime(time_t, time_t);
time_t __cdecl __MINGW_NOTHROW mktime(struct tm *);
/*
* These functions write to and return pointers to static buffers that may
* be overwritten by other function calls. Yikes! Using *_r versions to
* avoid it.
*/
char *__cdecl __MINGW_NOTHROW asctime(const struct tm *);
char *__cdecl __MINGW_NOTHROW asctime_r(const struct tm *, char *);
char *__cdecl __MINGW_NOTHROW ctime(const time_t *);
char *__cdecl __MINGW_NOTHROW ctime_r(const time_t *, char *);
struct tm *__cdecl __MINGW_NOTHROW gmtime(const time_t *);
struct tm *__cdecl __MINGW_NOTHROW gmtime_r(const time_t *, struct tm *);
struct tm *__cdecl __MINGW_NOTHROW localtime(const time_t *);
struct tm *__cdecl __MINGW_NOTHROW localtime_r(const time_t *, struct tm *);
size_t __cdecl __MINGW_NOTHROW strftime(char *, size_t, const char *, const struct tm *);
char *__cdecl __MINGW_NOTHROW strptime(const char *, const char *, const struct tm *);
void __cdecl __MINGW_NOTHROW tzset(void);
/*
* daylight: non zero if daylight savings time is used.
* timezone: difference in seconds between GMT and local time.
* tzname: standard/daylight savings time zone names (an array with two
* elements).
*/
extern int daylight;
extern long timezone;
extern char *tzname[2];
/* Nonzero if YEAR is a leap year (every 4 years,
except every 100th isn't, and every 400th is). */
# define __isleap(year) ((year)%4 == 0 && ((year)%100 || (year)%400 == 0))
#define CLOCK_REALTIME 0
#define CLOCK_MONOTONIC 1
int clock_gettime(clockid_t, struct timespec *);
int clock_settime(clockid_t, const struct timespec *);
#ifdef __cplusplus
}
#endif
#endif