����14-11 linux/include/time.h


  1 #ifndef _TIME_H

  2 #define _TIME_H

  3

  4 #ifndef _TIME_T

  5 #define _TIME_T

  6 typedef long time_t;               // ��GMT 1970��1��1����ҹ0ʱ��ʼ�Ƶ�ʱ�䣨�룩��

  7 #endif

  8

  9 #ifndef _SIZE_T

 10 #define _SIZE_T

 11 typedef unsigned int size_t;

 12 #endif

 13

 14 #ifndef NULL

 15 #define NULL ((void *) 0)

 16 #endif

 17

 18 #define CLOCKS_PER_SEC 100         // ϵͳʱ�ӵδ�Ƶ�ʣ�100HZ��

 19

 20 typedef long clock_t;              // �ӽ��̿�ʼִ�м����ϵͳ������ʱ�ӵδ�����

 21

 22 struct tm {

 23         int tm_sec;                // ���� [0��59]��

 24         int tm_min;                // ������ [ 0��59]��

 25         int tm_hour;               // Сʱ�� [0��59]��

 26         int tm_mday;               // 1���µ����� [0��31]��

 27         int tm_mon;                // 1�����·� [0��11]��

 28         int tm_year;               // ��1900�꿪ʼ��������

 29         int tm_wday;               // 1�����е�ij�� [0��6]�������� =0����

 30         int tm_yday;               // 1���е�ij�� [0��365]��

 31         int tm_isdst;              // ����ʱ��־������ - ʹ�ã�0 - û��ʹ�ã����� - ��Ч��

 32 };

 33

    // �ж��Ƿ�Ϊ����ĺꡣ

 34 #define __isleap(year)  \

 35   ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 1000 == 0))

 36  

    // �������й�ʱ������ĺ���ԭ�͡�

    // ȷ��������ʹ��ʱ�䡣���س������ô�����ʱ�䣨�δ������Ľ���ֵ��

 37 clock_t clock(void);

    // ȡʱ�䣨�����������ش�1970.1.1:0:0:0��ʼ����������Ϊ����ʱ�䣩��

 38 time_t time(time_t * tp);

    // ����ʱ������ʱ��time2��time1֮�侭����������

 39 double difftime(time_t time2, time_t time1);

    // ��tm�ṹ��ʾ��ʱ��ת��������ʱ�䡣

 40 time_t mktime(struct tm * tp);

 41

    // ��tm�ṹ��ʾ��ʱ��ת����һ���ַ���������ָ��ô���ָ�롣

 42 char * asctime(const struct tm * tp);

    // ������ʱ��ת����һ���ַ�����ʽ���硰Wed Jun 30 21:49:08:1993\n����

 43 char * ctime(const time_t * tp);

    // ������ʱ��ת����tm�ṹ��ʾ��UTCʱ�䣨UTC - ����ʱ�����Universal Time Code����

 44 struct tm * gmtime(const time_t *tp);

    // ������ʱ��ת����tm�ṹ��ʾ��ָ��ʱ��(Time Zone)��ʱ�䡣

 45 struct tm *localtime(const time_t * tp);

    // ��tm�ṹ��ʾ��ʱ�����ø�ʽ�ַ���fmtת������󳤶�Ϊsmax���ַ�����������洢��s�С�

 46 size_t strftime(char * s, size_t smax, const char * fmt, const struct tm * tp);

    // ��ʼ��ʱ��ת����Ϣ��ʹ�û�������TZ����zname�������г�ʼ����

    // ����ʱ����ص�ʱ��ת�������н��Զ����øú�����

 47 void tzset(void);

 48

 49 #endif

 50