.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" References consulted: .\" Linux libc source code .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) .\" 386BSD man pages .\" Modified Sun Jul 25 11:01:58 1993 by Rik Faith (faith@cs.unc.edu) .\" Modified 2001-11-13, aeb .\" Modified 2004-12-01 mtk and Martin Schulze .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1998 NAKANO Takeo all rights reserved. .\" Translated 1998-03-23, NAKANO Takeo .\" Updated 2000-09-14, Kentaro Shirakata .\" Updated 2002-01-06, NAKANO Takeo .\" Updated 2007-01-07, Akihiro MOTOKI, catch up to LDP v2.43 .\" .TH TZSET 3 " 2017\-09\-15" "" "Linux Programmer's Manual" .SH 名前 tzset, tzname, timezone, daylight \- 時刻の変換情報を初期化する .SH 書式 .nf \fB#include \fP .PP \fBvoid tzset (void);\fP .PP \fBextern char *\fP\fItzname\fP\fB[2];\fP \fBextern long \fP\fItimezone\fP\fB;\fP \fBextern int \fP\fIdaylight\fP\fB;\fP .fi .PP .RS -4 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .RE .PP \fBtzset\fP(): _POSIX_C_SOURCE .br \fItzname\fP: _POSIX_C_SOURCE .br \fItimezone\fP, \fIdaylight\fP: _XOPEN_SOURCE || /* Glibc since 2.19: */ _DEFAULT_SOURCE || /* Glibc versions <= 2.19: */ _SVID_SOURCE .SH 説明 The \fBtzset\fP() function initializes the \fItzname\fP variable from the \fBTZ\fP environment variable. This function is automatically called by the other time conversion functions that depend on the timezone. In a System\-V\-like environment, it will also set the variables \fItimezone\fP (seconds West of UTC) and \fIdaylight\fP (to 0 if this timezone does not have any daylight saving time rules, or to nonzero if there is a time, past, present or future when daylight saving time applies). .PP \fBTZ\fP 環境変数が設定されていない場合には、 システムのタイムゾーンが使用される。 ステムのタイムゾーンを設定するには、 \fBtzfile\fP(5) 形式のファイルを \fI/etc/localtime\fP にコピーしたりリンクしたりする。 これらのファイルがあるタイムゾーンデータベースはシステムのタイムゾーンディレクトリ (\fBファイル\fP の節を参照) に置かれている。 .PP \fBTZ\fP 環境変数が存在しているが、その値が空だったり、 以下に示す形式のどれにもあてはまらない場合は、 協定世界時 (Coordinated Universal Time: UTC) が用いられる。 .PP \fBTZ\fP の値は以下の 2 つの形式のいずれかを取ることができる。 最初の形式は、 使用するタイムゾーンを表す文字列を直接指定する方法である。 .PP .in +4n .EX \fIstd offset\fP[\fIdst\fP[\fIoffset\fP][,\fIstart\fP[\fI/time\fP],\fIend\fP[\fI/time\fP]]] .EE .in .PP There are no spaces in the specification. The \fIstd\fP string specifies an abbreviation for the timezone and must be three or more alphabetic characters. When enclosed between the less\-than (<) and greater\-than (>) signs, the characters set is expanded to include the plus (+) sign, the minus (\-) sign, and digits. The \fIoffset\fP string immediately follows \fIstd\fP and specifies the time value to be added to the local time to get Coordinated Universal Time (UTC). The \fIoffset\fP is positive if the local timezone is west of the Prime Meridian and negative if it is east. The hour must be between 0 and 24, and the minutes and seconds 00 and 59: .PP .in +4n .EX [\fI+\fP|\fI\-\fP]\fIhh\fP[\fI:mm\fP[\fI:ss\fP]] .EE .in .PP \fIdst\fP 文字列と \fIoffset\fP は、 対応するサマータイムゾーンの名前とオフセットを指定する。 オフセットが省略されると、デフォルトでは標準の一時間前となる。 .PP \fIstart\fP フィールドはサマータイムが有効になる時刻、 \fIend\fP フィールドは標準に戻る時刻である。 これらのフィールドは以下の形式で指定する。 .TP J\fIn\fP 年の通日 (Julian day) で日にちを指定する。 \fIn\fP は 1 から 365 の間の数値。閏日は計算に入らない。 この形式では、2 月 29 日を表現することはできず、 2 月 28 日が第 59 日で、3 月 1 日が常に第 60 日となる。 .TP \fIn\fP 年の通日 (Julian day) で日にちを指定する。 \fIn\fP は 1 から 365 の間の数値。 閏年の場合も、2 月 29 日も日にちの計算に含められる。 .TP M\fIm\fP.\fIw\fP.\fId\fP \fIm\fP は月 (1 <= \fIm\fP <= 12) を、 \fIw\fP は月のうちの週 (1 <= \fIw\fP <= 5) を、 \fId\fP は週のうちの日にち (0 <= \fId\fP <= 6) を示す。 \fIw\fP = 1 は所属する \fId\fP が存在する最初の週、 \fIw\fP = 5 は最後の週である。 \fId\fP = 0 は日曜日である。 .PP \fItime\fP フィールドは、ローカルタイムを切り替える時刻を、 変更前のローカルタイムで表したものである。 省略された場合のデフォルトは 02:00:00 である。 .PP ニュージーランドの例である。 ニュージーランドでは、標準のタイムゾーン (NZST) は UTC より 12時間進んでおり、 サマータイム (NZDT) は UTC の 13時間進んでいる。 サマータイムは 10月の第一日曜から 3月の第三日曜までであり、 ローカルタイムの切り替えはデフォルトの 02:00:00 に行われる。 .PP .in +4n .EX TZ="NZST\-12:00:00NZDT\-13:00:00,M10.1.0,M3.3.0" .EE .in .PP 2 番目の形式は、タイムゾーンの情報をファイルから読み込むように指定する。 .PP .in +4n .EX :[filespec] .EE .in .PP ファイルの指定 \fIfilespec\fP が省略された場合、 もしくは指定された値が解釈できない場合、 協定標準時 (UTC; Coordinated Universal Time) が使用される。 指定された場合、 \fIfilespec\fP はタイムゾーン情報を読み出す \fBtzfile\fP(5) 形式のファイルを指定する。 \fIfilespec\fP が \(aq/\(aq で始まっていない場合には、 システムタイムゾーンディレクトリからの相対パスで ファイルが指定されたことになる。 コロンが省略された場合には、 上記の \fBTZ\fP の各形式での解釈を試みる。 .PP 例を挙げておく。もう一度ニュージーランドの例である。 .PP .in +4n .EX TZ=":Pacific/Auckland" .EE .in .SH 環境変数 .TP \fBTZ\fP この変数が設定された場合、 その値がシステムで設定されたタイムゾーンより優先して使用される。 .TP \fBTZDIR\fP この変数が設定された場合、 その値がシステムで設定されたタイムゾーンデータベースのディレクトリパスより優先して使用される。 .SH ファイル .TP \fI/etc/localtime\fP システムのタイムゾーンファイル。 .TP \fI/usr/share/zoneinfo/\fP システムのタイムゾーンデータベースのディレクトリ。 .TP \fI/usr/share/zoneinfo/posixrules\fP TZ 文字列で dst タイムゾーンが他に何の指定なしで単独で指定された場合、 このファイルが start/end のルールに使用される。 このファイルは \fBtzfile\fP(5) 形式である。 デフォルトでは、 ゾーン情報の Makefile でこのファイルは \fIAmerica/New_York\fP にハードリンクされる。 .PP 上記は現在の標準のファイルの場所だが、 glibc のコンパイル時に変更できる。 .SH 属性 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。 .TS allbox; lb lb lb l l l. インターフェース 属性 値 T{ \fBtzset\fP() T} Thread safety MT\-Safe env locale .TE .SH 準拠 POSIX.1\-2001, POSIX.1\-2008, SVr4, 4.3BSD. .SH 注意 4.3BSD には \fBchar *timezone(\fP\fIzone\fP\fB, \fP\fIdst\fP\fB)\fP というルーチンがあり、これは 最初の引数 (UTC からの西向きの分数) に対応するタイムゾーンの名前を返す。 二番目の引数が 0 の場合は標準の名前が用いられ、 それ以外はサマータイム版の名前が用いられる。 .SH 関連項目 \fBdate\fP(1), \fBgettimeofday\fP(2), \fBtime\fP(2), \fBctime\fP(3), \fBgetenv\fP(3), \fBtzfile\fP(5) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。