Scroll to navigation

TIME(2) Podręcznik programisty Linuksa TIME(2)

NAZWA

time - pobranie czasu w sekundach

SKŁADNIA

#include <time.h>

time_t time(time_t *tloc);

OPIS

time() zwraca czas jako liczbę sekund od epoki, tj. 1970-01-01 00:00:00 +0000 (UTC).

Jeśli tloc nie jest równe NULL, to zwracana wartość jest również zapisywana w pamięci wskazywanej przez tloc.

WARTOŚĆ ZWRACANA

W przypadku pomyślnego zakończenia, zwracana jest wartość liczbowa dla czasu w sekundach od Epoki. W przypadku błędu, zwracane jest ((time_t) -1) i odpowiednio ustawiane errno.

BŁĘDY

tloc wskazuje poza dostępną dla użytkownika przestrzeń adresową (ale zob. BŁĘDY).
On systems where the C library time() wrapper function invokes an implementation provided by the vdso(7) (so that there is no trap into the kernel), an invalid address may instead trigger a SIGSEGV signal.

ZGODNE Z

SVr4, 4.3BSD, C89, C99, POSIX.1-2001. POSIX nie określa żadnych sytuacji błędnych.

UWAGI

POSIX.1 defines seconds since the Epoch using a formula that approximates the number of seconds between a specified time and the Epoch. This formula takes account of the facts that all years that are evenly divisible by 4 are leap years, but years that are evenly divisible by 100 are not leap years unless they are also evenly divisible by 400, in which case they are leap years. This value is not the same as the actual number of seconds between the time and the Epoch, because of leap seconds and because system clocks are not required to be synchronized to a standard reference. The intention is that the interpretation of seconds since the Epoch values be consistent; see POSIX.1-2008 Rationale A.4.15 for further rationale.

On Linux, a call to time() with tloc specified as NULL cannot fail with the error EOVERFLOW, even on ABIs where time_t is a signed 32-bit integer and the clock ticks past the time 2**31 (2038-01-19 03:14:08 UTC, ignoring leap seconds). (POSIX.1 permits, but does not require, the EOVERFLOW error in the case where the seconds since the Epoch will not fit in time_t.) Instead, the behavior on Linux is undefined when the system time is out of the time_t range. Applications intended to run after 2038 should use ABIs with time_t wider than 32 bits.

BŁĘDY

Error returns from this system call are indistinguishable from successful reports that the time is a few seconds before the Epoch, so the C library wrapper function never sets errno as a result of this call.

The tloc argument is obsolescent and should always be NULL in new code. When tloc is NULL, the call cannot fail.

Różnice biblioteki C/jądra

Na niektórych architekturach, implementacja time() jest zapewniona w vdso(7).

ZOBACZ TAKŻE

date(1), gettimeofday(2), ctime(3), ftime(3), time(7), vdso(7)

O STRONIE

Angielska wersja tej strony pochodzi z wydania 5.10 projektu Linux man-pages. Opis projektu, informacje dotyczące zgłaszania błędów oraz najnowszą wersję oryginału można znaleźć pod adresem https://www.kernel.org/doc/man-pages/.

TŁUMACZENIE

Autorami polskiego tłumaczenia niniejszej strony podręcznika są: Przemek Borys <pborys@dione.ids.pl>, Andrzej Krzysztofowicz <ankry@green.mf.pg.gda.pl> i Michał Kułach <michal.kulach@gmail.com>

Niniejsze tłumaczenie jest wolną dokumentacją. Bliższe informacje o warunkach licencji można uzyskać zapoznając się z GNU General Public License w wersji 3 lub nowszej. Nie przyjmuje się ŻADNEJ ODPOWIEDZIALNOŚCI.

Błędy w tłumaczeniu strony podręcznika prosimy zgłaszać na adres listy dyskusyjnej manpages-pl-list@lists.sourceforge.net.

15 września 2017 r. Linux