バージョンごとのドキュメント一覧

B.5. POSIX 時間帯の指定 #

<title><acronym>POSIX</acronym> Time Zone Specifications</title>

<productname>PostgreSQL</productname> can accept time zone specifications that are written according to the <acronym>POSIX</acronym> standard's rules for the <varname>TZ</varname> environment variable. <acronym>POSIX</acronym> time zone specifications are inadequate to deal with the complexity of real-world time zone history, but there are sometimes reasons to use them. PostgreSQLTZ環境変数を使ったPOSIX標準ルールに沿って記述された時間帯指定を受け入れることができます。 POSIX時間帯の指定は複雑な実世界の時間帯の歴史を扱うには不足しているところもありますが、それを利用する理由があることもあります。

A POSIX time zone specification has the form <synopsis> <replaceable>STD</replaceable> <replaceable>offset</replaceable> <optional> <replaceable>DST</replaceable> <optional> <replaceable>dstoffset</replaceable> </optional> <optional> , <replaceable>rule</replaceable> </optional> </optional> </synopsis> (For readability, we show spaces between the fields, but spaces should not be used in practice.) The fields are: POSIX時間帯の指定には以下の形式があります。

STD offset [ DST [ dstoffset ] [ , rule ] ]

(可読性のためにフィールド間にスペースを表示していますが、実際にはスペースは使用されません。) フィールドは以下の通りです。

In this syntax, a zone abbreviation can be a string of letters, such as <literal>EST</literal>, or an arbitrary string surrounded by angle brackets, such as <literal>&lt;UTC-05&gt;</literal>. Note that the zone abbreviations given here are only used for output, and even then only in some timestamp output formats. The zone abbreviations recognized in timestamp input are determined as explained in <xref linkend="datetime-config-files"/>. この構文では、ゾーンの省略形はESTのような文字列か、<UTC-05>のような角括弧で囲った任意の文字列にすることができます。 ここで与えられた省略形は出力にのみ、中でも一部のタイムスタンプの出力フォーマットにのみ使われることに注意してください。 タイムスタンプの入力で認識される時間帯の省略形はB.4の中で説明されているように決定されます。

The offset fields specify the hours, and optionally minutes and seconds, difference from UTC. They have the format <replaceable>hh</replaceable><optional><literal>:</literal><replaceable>mm</replaceable><optional><literal>:</literal><replaceable>ss</replaceable></optional></optional> optionally with a leading sign (<literal>+</literal> or <literal>-</literal>). The positive sign is used for zones <emphasis>west</emphasis> of Greenwich. (Note that this is the opposite of the ISO-8601 sign convention used elsewhere in <productname>PostgreSQL</productname>.) <replaceable>hh</replaceable> can have one or two digits; <replaceable>mm</replaceable> and <replaceable>ss</replaceable> (if used) must have two. オフセットのフィールドはUTCからの差を時間、オプションで分、秒で指定します。 オフセットはhh[:mm[:ss]]のフォーマットで、オプションで先頭に符号をつけることができます(+ もしくは -)。 正の符号はグリニッジよりも西の時間帯に使用されます。(これは他のPostgreSQLで使われているISO-8601の規定とは反対であることに注意してください。) hhは1桁もしくは2桁です。mmssを使う場合は2桁でなければなりません。

The daylight-savings transition <replaceable>rule</replaceable> has the format サマータイム変換のruleには以下のフォーマットがあります。

dstdate [ / dsttime ] , stddate [ / stdtime ]

(As before, spaces should not be included in practice.) The <replaceable>dstdate</replaceable> and <replaceable>dsttime</replaceable> fields define when daylight-savings time starts, while <replaceable>stddate</replaceable> and <replaceable>stdtime</replaceable> define when standard time starts. (In some cases, notably in zones south of the equator, the former might be later in the year than the latter.) The date fields have one of these formats: (前述の通り、実際にはスペースを含めるべきではありません) 夏時間の開始時刻は、dstdatedsttimeフィールドが定義し、標準時間の開始時刻はstddatestdtimeで定義します。 (特に赤道より南の時間帯では前者は後者より年の後半になることもあります。) 日付フィールドには以下のような形式があります。

n

A plain integer denotes a day of the year, counting from zero to 364, or to 365 in leap years. 単純な整数は年の日を示し、0から364、閏年の場合は365までを数えます。

Jn

In this form, <replaceable>n</replaceable> counts from 1 to 365, and February 29 is not counted even if it is present. (Thus, a transition occurring on February 29 could not be specified this way. However, days after February have the same numbers whether it's a leap year or not, so that this form is usually more useful than the plain-integer form for transitions on fixed dates.) この形式ではnは1から365までを数え、2月29日は存在したとしても数えません。 (このように、2月29日の変換が発生する場合はこの方法では指定できません。 しかし、2月以降は、うるう年でもそうでなくとも同じ数になります。 このため、この形式は特定のある日に変換する場合、通常、単純な整数型の形式を利用するよりも有用です。)

Mm.n.d

This form specifies a transition that always happens during the same month and on the same day of the week. <replaceable>m</replaceable> identifies the month, from 1 to 12. <replaceable>n</replaceable> specifies the <replaceable>n</replaceable>'th occurrence of the weekday identified by <replaceable>d</replaceable>. <replaceable>n</replaceable> is a number between 1 and 4, or 5 meaning the last occurrence of that weekday in the month (which could be the fourth or the fifth). <replaceable>d</replaceable> is a number between 0 and 6, with 0 indicating Sunday. For example, <literal>M3.2.0</literal> means <quote>the second Sunday in March</quote>. この形式は同じ月の同じ曜日にいつも発生する変換を指定します。 mは1から12までの月を指定します。 nnで指定された週のd番目の日を指定します。 nは数字の1から5で、5の場合はその月の最後の週を意味します(4番目か5番目の週になる可能性があります)。 dは数字の0から6で、0は日曜日を指します。 例えば、M3.2.03月の第2日曜日を意味します。

注記

The <literal>M</literal> format is sufficient to describe many common daylight-savings transition laws. But note that none of these variants can deal with daylight-savings law changes, so in practice the historical data stored for named time zones (in the IANA time zone database) is necessary to interpret past time stamps correctly. M形式は多くの一般的な夏時間の変換法を記述するのに十分です。 しかし、夏時間変換法の変化を扱う変数は無いため、実際には、過去のデータを名前付き時間帯(IANA時間帯のデータベースにある)で配置するためには、過去のタイムスタンプを変換する必要があります。

The time fields in a transition rule have the same format as the offset fields described previously, except that they cannot contain signs. They define the current local time at which the change to the other time occurs. If omitted, they default to <literal>02:00:00</literal>. 変換ルール中の時間フィールドは符号を含めることができない点を除いて、先に記載したオフセットのフィールドと同じ形式を持っています。 これらのフィールドは他の時間への変換が発生した時の現在のローカル時間を定義します。 省略された場合、デフォルトは02:00:00です。

If a daylight-savings abbreviation is given but the transition <replaceable>rule</replaceable> field is omitted, the fallback behavior is to use the rule <literal>M3.2.0,M11.1.0</literal>, which corresponds to USA practice as of 2020 (that is, spring forward on the second Sunday of March, fall back on the first Sunday of November, both transitions occurring at 2AM prevailing time). Note that this rule does not give correct USA transition dates for years before 2007. 夏時間の省略形が与えられているが移行ruleフィールドが省略されている場合、代替の動作には2020年のアメリカ合衆国の習慣と照合されるM3.2.0,M11.1.0(3月の第2日曜日に夏時間に切り替わり、11月の第1日曜日に戻ります。両方の移行はその時進んでいる時間の午前2時に行われます)が使用されます。 この規則は、2007年より前の年の正しいアメリカ合衆国移行日を示していないことに注意してください。

As an example, <literal>CET-1CEST,M3.5.0,M10.5.0/3</literal> describes current (as of 2020) timekeeping practice in Paris. This specification says that standard time has the abbreviation <literal>CET</literal> and is one hour ahead (east) of UTC; daylight savings time has the abbreviation <literal>CEST</literal> and is implicitly two hours ahead of UTC; daylight savings time begins on the last Sunday in March at 2AM CET and ends on the last Sunday in October at 3AM CEST. 例えば、CET-1CEST,M3.5.0,M10.5.0/3は(2020年時点の)パリの現時点の時計方法を表しています。 この指定では、標準時間はCETという略語を持ち、UTCより1時間(東)進んでいます。また、夏時間には、CESTという略語を持ち、暗黙的にUTCより2時間進んでいます。夏時間は3月の最終日曜のAM2時に始まり、10月の最終日曜日の3AM CESTに終わります。

The four timezone names <literal>EST5EDT</literal>, <literal>CST6CDT</literal>, <literal>MST7MDT</literal>, and <literal>PST8PDT</literal> look like they are POSIX zone specifications. However, they actually are treated as named time zones because (for historical reasons) there are files by those names in the IANA time zone database. The practical implication of this is that these zone names will produce valid historical USA daylight-savings transitions, even when a plain POSIX specification would not. 4つの時間帯名、EST5EDTCST6CDTMST7MDTPST8PDTはPOSIXゾーンの指定に見えます。 しかし、(歴史的な理由で)IANA時間帯データベースにこれらの名前が記録されているため、実際には名前付き時間帯として扱われます。 これの実際の影響は、明白なPOSIX仕様が提供されない場合でも、これらのゾーン名が有効な歴史的なアメリカ合衆国の夏時間の変換を提供することです。

One should be wary that it is easy to misspell a POSIX-style time zone specification, since there is no check on the reasonableness of the zone abbreviation(s). For example, <literal>SET TIMEZONE TO FOOBAR0</literal> will work, leaving the system effectively using a rather peculiar abbreviation for UTC. ゾーンの省略形は妥当性をチェックされていないため、POSIX形式の時間帯指定はスペルミスしやすいことに注意してください。 例えば、SET TIMEZONE TO FOOBAR0は動作しますが、実質的にシステムはUTCの特殊な省略形を使用します。