Provided by: manpages-ja-dev_0.5.0.0.20221215+dfsg-1_all bug

名前

       time - 秒単位の時間を得る

書式

       #include <time.h>

        time_t time(time_t *tloc);

説明

       time()  は、紀元 (Epoch; 1970-01-01 00:00:00 (UTC)) からの秒数で返す。

       もし tloc が NULL でなかったら返り値は tloc の指しているメモリーにも格納される。

返り値

       成功した場合、紀元(the  Epoch)からの経過秒数を返す。エラーの場合は  ((time_t) -1)  を返し、errno を設定す
       る。

エラー

       EFAULT tloc がアクセス可能なアドレス空間の外を指している (ただし「バグ」を参照)。

              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.

準拠

       SVr4, 4.3BSD, C89, C99, POSIX.1-2001.  POSIX にはエラー状態の規定はない。

注意

       POSIX.1 では、指定した時刻と紀元との間の秒数を近似する変換式を使って、
        「紀元からの経過秒数 (seconds  since  the  Epoch)」  を定義している。  この変換式では、4  で割り切れる年
       で、100 で割り切れない年はすべて閏年 (但し、400 で割り切れる年は閏年) であるという点も考慮されている。 「
       紀元からの経過秒数」は、紀元と現在時刻との間で実際に経過した秒数と同じではない。 なぜならば、閏秒が存在す
       るし、システムの時計を標準時間  (standard  reference)  に同期させる必要もないからである。  この定義の目的
       は、紀元からの経過秒数の解釈に一貫性を持たせることになる。 より詳しい原理は POSIX.1 Rationale A.4.15 を参
       照すること。

       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.

バグ

       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.

   C library/kernel differences
       On some architectures, an implementation of time()  is provided in the vdso(7).

関連項目

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

この文書について

       この man ページは Linux man-pages プロジェクトのリリース 5.10  の一部である。プロジェクトの説明とバグ報告
       に関する情報は https://www.kernel.org/doc/man-pages/ に書かれている。