Server for Information Technologies ������ ��������������
������� �������������� ����������
(095) 932-9212, 932-9213, 939-0783
E-mail: [email protected]
������ �������� ����(!) ������������� ���������� CIT Forum CD-ROM

CTIME(3C)

��������
ctime, localtime, gmtime, asctime, cftime, ascftime, tzset - �������������� ���� � ������� � ������� ��������

���������

	#include <sys/types.h>
	#include <time.h>
	
	char *ctime (clock)
	time_t *clock;
	
	struct tm *localtime (clock)
	time_t *clock;
	
	struct tm *gmtime (clock)
	time_t *clock;
	
	char *asctime (tm)
	struct tm *tm;
	
	extern long timezone;
	
	extern int daylight;
	
	extern char *tzname[2];
	
	void tzset ( )

��������
���������� ������� ctime, localtime � gmtime ������ ��������� clock �� �������� ���� time_t, ���������� �� ���������� ����� . ��� �������� ���������������� ��� ����� ������, ������������� �� 00:00:00 1 ������ 1970�. ���������� �������. ������� ctime ���������� ��������� �� ������� �� 26 �������� ����

	Sun Jan 16 01:03:52 1987\n\0
��� ��� ���� ����� ���������� �����.

������� localtime � gmtime ���������� ��������� �� "tm"-���������, ��������� ����. Localtime ������ �������� �� ������� ���� �, ��������, �� ������ �����; gmtime ������������ �������������� ��������������� �� ���������� �������, ������������� � ������� UNIX.

������� asctime ����������� "tm"-��������� � ������� �� 26 �������� (�������� ����������� ����) � ���������� ��������� �� ��� �������.

�� ������� ���� �������, ������� �� �����, � ����� "tm"-��������� ���������� �� ���������� ����� . �������� ��������� �������� ���:

	struct tm {
	  int tm_sec;   /* ������� (0-59) */
	  int tm_min;   /* ������ (0-59) */
	  int tm_hour;  /* ���� (0-23) */
	  int tm_mday;  /* ���� ������ (1-31) */
	  int tm_mon;   /* ����� ���� (0-11) */
	  int tm_year;  /* ��� - 1900 */
	  int tm_wday;  /* ���� ������ (����������� = 0) */
	  int tm_yday;  /* ���� ���� (0-365) */
	  int tm_isdst;
	};

������� tm_isdst �� ���� ��������� �� ��, ��� ������������ ������ �����.

������� ���������� timezone ���� long �������� ������� � �������� ����� ��������� �������� � ������� ������� ��������. ������, ��� ���������� �������� ������� EST (��. ����������) ��� ������� ���������� 5*60*60. ������� ���������� daylight ������� �� ���� ����� � ������ �����, ����� ������ �������������� �������������� � ������� ������� � ������������ �� ���������� ���. ��������� ��������� ����������� ����� �������������� � 1974, 1975 �����; ��� ������������� �������� ����� ��� ����� ���� ��������.

��� ������� ���������� ��������� � ������ TZ, ������� asctime ���������� �������� ���� ���������� ��� ������� �������� �����, ��������� �� ����������������. �������� TZ ������������ �� ���� ������������� �������� �������� �������� ������� (��. ����������), �� ������� ������� �����, ���������� ���������� �������� ������� �� ������������ � ����� � �����, ��������, ������� ������������� �������� ������� �������, ������������ � ������ �����. � �������, ��� ���-������ ������� ���������� �������� EST5EDT. ������ �� �������������� TZ ����� �������� �������� ������� ���������� timezone � daylight, � �� ������� ����������

	char *tzname[2] = {"EST", "EDT"};

��������� �������� ��������� ����. ��� ��������� ������������ ������� tzset; ������ ��� ���������� �������� asctime, �� ����� ���� ������� ������������� � ����.

������� ����� � ����, ��� ��� ����������� ���������� ��������� ������� /etc/profile �������� ������������ ���������� TZ [��. profile(4), timezone(4)].

��. �����
time(2), getenv(3C), profile(4), timezone(4), environ(5).

��������
��������, ������������ ���������� ���������, ��������� �� ���� � ��� �� ����������� ������, ���������� �������� ��������� ���������� ����� ������� ������.

����������
��������� �������� �������� ������� ����� 0-�� �������� �����, ������� ������������ �� ���� ������� ������� ��������� ����� ������������ ���������; ������������ GMT (Greenwich Mean Time).

���������� ����� ��������� ��������� �� 3 ����.(��� ��� ���������� ��������� ���������� ����� - �� ������ � �������!)

������� ����� ������, ������� �� 2-� ������� �����, ��������� ��������� �� 2 ����.

���������� ������ ����� ��������� ��������� �� 4 ����.

�������� ���������� ��� ����������� 4-�� �������� �������, �� ���� 16-�, 17-�, 18-�, 19-�, �������� �������������� ����������� ��������: Pacific (�������������), Mountain (������), Central (�����������), Eastern (���������). � ��� ��������� ��������������� ������� (Standard) � �� ���� ������ �������� ����������, �� ����������� �������, ������ (Daylight [Saving]) ����� (Time). ������ ����������� ��������: PST, MST, CST, EST, � ����� PDT, MDT, CDT, EDT.
Comments: [email protected]
Designed by Andrey Novikov
Copyright © CIT