Time-Piece-1.08 > 1.20 との差分

Time::Piece 1.20 と 1.08 の差分

11
22=encoding euc-jp
33
4=head1 NAME
4=head1 名前
55
6=begin original
7
8Time::Piece - Object Oriented time objects
9
10=end original
11
126Time::Piece - オブジェクト指向な時間オブジェクト
137
14=head1 SYNOPSIS
8=head1 概要
159
1610 use Time::Piece;
1711
1812 my $t = localtime;
1913 print "Time is $t\n";
2014 print "Year is ", $t->year, "\n";
2115
22=head1 DESCRIPTION
16=head1 説明
2317
24=begin original
25
2618This module replaces the standard localtime and gmtime functions with
2719implementations that return objects. It does so in a backwards
2820compatible manner, so that using localtime/gmtime in the way documented
2921in perlfunc will still return what you expect.
3022
31=end original
23このモジュールは、標準の localtime と gmtime 関数を、オブジェクトを返す実装のものに置き換えます。
24後方互換性があるので、perlfunc に書かれているように、localtime/gmtime を使っても、期待通りのものを返します。
3225
33このモジュールは、標準の localtime と gmtime 関数を、オブジェクトを返す
34実装のものに置き換えます。
35これを後方互換性がある形で行うので、perlfunc に書かれているように
36localtime/gmtime を使っても、期待通りのものを返します。
37
38=begin original
39
4026The module actually implements most of an interface described by
4127Larry Wall on the perl5-porters mailing list here:
4228http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2000-01/msg00241.html
4329
44=end original
30このモジュールは、実際に、Larry Wall が、perl5-portersメーリングリストに書いた、
31ほとんどのインターフェースを実装します:
46このモジュールは、Larry Wall が perl5-porters メーリングリストに書いた、
47インターフェースのほとんどを実際に実装します:
4832http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2000-01/msg00241.html
4933
50=head1 USAGE
34=head1 使い方
5135
52(使い方)
53
54=begin original
55
5636After importing this module, when you use localtime or gmtime in a scalar
5737context, rather than getting an ordinary scalar string representing the
5838date and time, you get a Time::Piece object, whose stringification happens
5939to produce the same effect as the localtime and gmtime functions. There is
6040also a new() constructor provided, which is the same as localtime(), except
6141when passed a Time::Piece object, in which case it's a copy constructor. The
6242following methods are available on the object:
6343
64=end original
44このモジュールをインポートした後は、スカラコンテキストで、localtime か、gmtime を使うと、
45日付と時間を表現する普通のスカラ文字列ではなくて、Time::Pieceオブジェクトを得ます。
66このモュールをインポーした後は、スカラコンテキストで localtime
46Time::Pieceオブェクの stringification は、localtime と gmtime たまたま関数と同じ効果があります。
67gmtime を使う、日付と時間を表現する普通のスカラ文字列はなく、
47new() コンストラクタもありますが、Time::Pieceオブジェクトが渡されない限りlocaltime()同じす。
68Time::Piece オブジェクトを得ます。
48Time::Pieceオブジェクトが渡されると、コピーするコンストラクタになります。
69Time::Piece オブジェクトの文字列化は、偶然にも localtime と gmtime 関数と
70同じ効果があります。
71new() コンストラクタもありますが、Time::Piece オブジェクトが渡されない限り
72localtime() と同じです。
73Time::Piece オブジェクトが渡されると、コピーコンストラクタになります。
7449下記のメソッドがオブジェクトで利用できます:
7550
76=begin original
77
78 $t->sec # also available as $t->second
79 $t->min # also available as $t->minute
80 $t->hour # 24 hour
81 $t->mday # also available as $t->day_of_month
82 $t->mon # 1 = January
83 $t->_mon # 0 = January
84 $t->monname # Feb
85 $t->month # same as $t->monname
86 $t->fullmonth # February
87 $t->year # based at 0 (year 0 AD is, of course 1 BC)
88 $t->_year # year minus 1900
89 $t->yy # 2 digit year
90 $t->wday # 1 = Sunday
91 $t->_wday # 0 = Sunday
92 $t->day_of_week # 0 = Sunday
93 $t->wdayname # Tue
94 $t->day # same as wdayname
95 $t->fullday # Tuesday
96 $t->yday # also available as $t->day_of_year, 0 = Jan 01
97 $t->isdst # also available as $t->daylight_savings
98
99 $t->hms # 12:34:56
100 $t->hms(".") # 12.34.56
101 $t->time # same as $t->hms
102
103 $t->ymd # 2000-02-29
104 $t->date # same as $t->ymd
105 $t->mdy # 02-29-2000
106 $t->mdy("/") # 02/29/2000
107 $t->dmy # 29-02-2000
108 $t->dmy(".") # 29.02.2000
109 $t->datetime # 2000-02-29T12:34:56 (ISO 8601)
110 $t->cdate # Tue Feb 29 12:34:56 2000
111 "$t" # same as $t->cdate
112
113 $t->epoch # seconds since the epoch
114 $t->tzoffset # timezone offset in a Time::Seconds object
115
116 $t->julian_day # number of days since Julian period began
117 $t->mjd # modified Julian date (JD-2400000.5 days)
118
119 $t->week # week number (ISO 8601)
120
121 $t->is_leap_year # true if it its
122 $t->month_last_day # 28-31
123
124 $t->time_separator($s) # set the default separator (default ":")
125 $t->date_separator($s) # set the default separator (default "-")
126 $t->day_list(@days) # set the default weekdays
127 $t->mon_list(@days) # set the default months
128
129 $t->strftime(FORMAT) # same as POSIX::strftime (without the overhead
130 # of the full POSIX extension)
131 $t->strftime() # "Tue, 29 Feb 2000 12:34:56 GMT"
132
133 Time::Piece->strptime(STRING, FORMAT)
134 # see strptime man page. Creates a new
135 # Time::Piece object
136
137=end original
138
13951 $t->sec # $t->second も可
14052 $t->min # $t->minute も可
141 $t->hour # 24 時制
53 $t->hour # 24時制
14254 $t->mday # $t->day_of_month も可
14355 $t->mon # 1 = 一月
14456 $t->_mon # 0 = 一月
14557 $t->monname # Feb
14658 $t->month # $t->monname と同じ
14759 $t->fullmonth # February
148 $t->year # 0 始まり(AD 0 年は、もちろん、BC 1 年)
60 $t->year # 0始まり(AD0年は、もちろん、BC1年)
149 $t->_year # 年から 1900引いたもの
61 $t->_year # 年から1900引いたもの
150 $t->yy # 2 桁の年
62 $t->yy # 2桁の年
15163 $t->wday # 1 = 日曜
15264 $t->_wday # 0 = 日曜
15365 $t->day_of_week # 0 = 日曜
15466 $t->wdayname # Tue
15567 $t->day # wdayname と同じ
15668 $t->fullday # Tuesday
157 $t->yday # $t->day_of_year も可, 0 = 1 1
69 $t->yday # $t->day_of_year も可, 0 = Jan 01
15870 $t->isdst # $t->daylight_savings も可。
15971
16072 $t->hms # 12:34:56
16173 $t->hms(".") # 12.34.56
16274 $t->time # $t->hms と同じ
16375
16476 $t->ymd # 2000-02-29
16577 $t->date # $t->ymd と同じ
16678 $t->mdy # 02-29-2000
16779 $t->mdy("/") # 02/29/2000
16880 $t->dmy # 29-02-2000
16981 $t->dmy(".") # 29.02.2000
17082 $t->datetime # 2000-02-29T12:34:56 (ISO 8601)
17183 $t->cdate # Tue Feb 29 12:34:56 2000
17284 "$t" # $t->cdate と同じ
17385
17486 $t->epoch # epochからの秒
175 $t->tzoffset # Time::Seconds オブジェクトによるタイムゾーンオフセット
87 $t->tzoffset # timezone offset in a Time::Seconds object
17688
17789 $t->julian_day # ユリウス歴が始まってからの日の数
178 $t->mjd # 修正ユリウス日 (JD-2400000.5 )
90 $t->mjd # modified Julian date (JD-2400000.5 days)
17991
18092 $t->week # 週番号 (ISO 8601)
18193
18294 $t->is_leap_year # 閏年なら真を返す
18395 $t->month_last_day # 28-31
18496
185 $t->time_separator($s) # デフォルトのセパレータを設定 (デフォルト ":")
97 $t->time_separator($s) # デフォルトのセパレータをセットします (default ":")
186 $t->date_separator($s) # デフォルトのセパレータを設定 (デフォルト "-")
98 $t->date_separator($s) # デフォルトのセパレータをセットします (default "-")
187 $t->day_list(@days) # デフォルトの曜日を設定
99 $t->day_list(@days) # デフォルトの曜日をセットします
188 $t->mon_list(@days) # デフォルトの月名を設定
100 $t->mon_list(@days) # デフォルトの月名をセットします
189101
190 $t->strftime(FORMAT) # POSIX::strftime と同じ(しかし完全な
102 $t->strftime(FORMAT) # POSIX::strftime と同じ(without the overhead
191 # POSIX 拡張のためのオーバーヘッドはありません)
103 # of the full POSIX extension)
192104 $t->strftime() # "Tue, 29 Feb 2000 12:34:56 GMT"
193105
194106 Time::Piece->strptime(STRING, FORMAT)
195 # strptime man ページを見て下さい。新しく
107 # strptime man ページを見て下さい
196 # Time::Piece オブジェクトを作ります
108 # 新しく、Time::Piece object を作ります
197109
198110=head2 Local Locales
199111
200(ローカルロケール)
201
202=begin original
203
204112Both wdayname (day) and monname (month) allow passing in a list to use
205113to index the name of the days against. This can be useful if you need
206114to implement some form of localisation without actually installing or
207115using locales.
208116
209=end original
117曜日(day)と月名(month)の両方ともに、曜日のインデックスに使うリストに渡すことを
118許しています。実際にインストールしたり、ロケールを使わずに、
119なんらかのローカライゼーションを実装する必要があれば、有益でしょう。
210120
211wdayname (day) と monname (month) の両方ともに、曜日のインデックスに使う
212リストを渡すことができます。
213実際にロケールをインストールしたり使ったりせずに、ある種の地域化を実装する
214必要があるなら、有益でしょう。
215
216121 my @days = qw( Dimanche Lundi Merdi Mercredi Jeudi Vendredi Samedi );
217122
218123 my $french_day = localtime->day(@days);
219124
220=begin original
221
222125These settings can be overriden globally too:
223126
224=end original
225
226127これらの設定はグローバルにもオーバーライドできます:
227128
228129 Time::Piece::day_list(@days);
229130
230=begin original
231
232131Or for months:
233132
234=end original
235
236133また、月なら:
237134
238135 Time::Piece::mon_list(@months);
239136
240=begin original
241
242137And locally for months:
243138
244=end original
139ローカルにするなら:
245140
246月に関してローカルに行うなら:
247
248141 print localtime->month(@months);
249142
250=head2 Date Calculations
143=head2 日付の演算
251144
252(日付の演算)
253
254=begin original
255
256145It's possible to use simple addition and subtraction of objects:
257146
258=end original
259
260147単純なオブジェクトの足し算、引き算ができます:
261148
262149 use Time::Seconds;
263150
264151 my $seconds = $t1 - $t2;
265152 $t1 += ONE_DAY; # add 1 day (constant from Time::Seconds)
266153
267=begin original
268
269154The following are valid ($t1 and $t2 are Time::Piece objects):
270155
271=end original
156下記のようにx使えます($t と $t2 はTime::Piece オブジェクト):
272157
273下記のものは有効です($t1 と $t2 は Time::Piece オブジェクト):
274
275158 $t1 - $t2; # returns Time::Seconds object
276159 $t1 - 42; # returns Time::Piece object
277160 $t1 + 533; # returns Time::Piece object
278161
279=begin original
280
281162However adding a Time::Piece object to another Time::Piece object
282163will cause a runtime error.
283164
284=end original
165ですが、Time::Piece オブジェクトに、別のTime::Piece オブジェクトを
285
286ですが、Time::Piece オブジェクトに別の Time::Piece オブジェクトを
287166足すのは、実行時エラーを引き起こします。
288167
289=begin original
290
291168Note that the first of the above returns a Time::Seconds object, so
292169while examining the object will print the number of seconds (because
293170of the overloading), you can also get the number of minutes, hours,
294171days, weeks and years in that delta, using the Time::Seconds API.
295172
296=end original
173上の例の最初のものは、Time::Seconds オブジェクトを返すことに注意して下さい。
174オブジェクトを試験することで秒数を出力(オーバーロードによって)する一方で、
175Time::Seconds のAPIを使って、その差異から、分数、時間数、日数、週の数、年数を、
176得ることが出来ます。
297177
298上の例の最初のものは、Time::Seconds オブジェクトを返すことに注意して下さい;
178=head2 日付の比較
299オブジェクトを試験することで(オーバーロードによって)秒数を出力する一方で、
300Time::Seconds の API を使って、その差異から、分数、時間数、日数、週の数、
301年数を得ることが出来ます。
302179
303=begin original
304
305In addition to adding seconds, there are two APIs for adding months and
306years:
307
308=end original
309
310秒の加算に加えて、月と年を加算するための二つの API があります:
311
312 $t->add_months(6);
313 $t->add_years(5);
314
315=begin original
316
317The months and years can be negative for subtractions. Note that there
318is some "strange" behaviour when adding and subtracting months at the
319ends of months. Generally when the resulting month is shorter than the
320starting month then the number of overlap days is added. For example
321subtracting a month from 2008-03-31 will not result in 2008-02-31 as this
322is an impossible date. Instead you will get 2008-03-02. This appears to
323be consistent with other date manipulation tools.
324
325=end original
326
327月と年は減算のために負数にもなり得ます。
328月末で月を加減算すると「おかしな」振る舞いになることに注意してください。
329一般的に結果となる月が開始月より短い場合、重なった日の分が追加されます。
330例えば、2008-03-31 から 1 ヶ月引くと、あり得ない日付である 2008-02-31 には
331なりません。
332代わりに 2008-03-02 になります。
333これは他の日付操作ツールと一貫性があるように思われます。
334
335=head2 Date Comparisons
336
337(日付の比較)
338
339=begin original
340
341180Date comparisons are also possible, using the full suite of "<", ">",
342181"<=", ">=", "<=>", "==" and "!=".
343182
344=end original
183日付の比較もまた可能です。 "<"、 ">"、"<="、 ">="、 "<=>"、 "=="、 "!="
184の全てが使えます。
345185
346日付の比較も可能です;
186=head2 日付の解析
347"<"、 ">"、"<="、 ">="、 "<=>"、 "=="、 "!=" の全てが使えます。
348187
349=head2 Date Parsing
188Time::Piece links to your C library's strptime() function, allowing
350
351(日付の解析)
352
353=begin original
354
355Time::Piece has a built-in strptime() function (from FreeBSD), allowing
356189you incredibly flexible date parsing routines. For example:
357190
358=end original
191Time::Piece は、C ライブラリの strptime()関数にリンクしているので、
192信じられない程柔軟に日付を解析するルーチンを使えます。たとえば:
359193
360Time::Piece は、驚くほど柔軟に日付を解析する組み込みの (FreeBSD 由来の)
194 my $t = Time::Piece->strptime("Sun 3rd Nov, 1943",
361strptime() 関数を使えます。
362たとえば:
363
364 my $t = Time::Piece->strptime("Sunday 3rd Nov, 1943",
365195 "%A %drd %b, %Y");
366196
367197 print $t->strftime("%a, %d %b %Y");
368198
369=begin original
370
371Outputs:
372
373=end original
374
375199次のように出力します:
376200
377201 Wed, 03 Nov 1943
378202
379=begin original
380
381203(see, it's even smart enough to fix my obvious date bug)
382204
383=end original
205(見て下さい、一目瞭然な日付のバグを直すのに十分賢い)
384206
385(ほら、私の一目瞭然な日付のバグを直すのに十分なくらい賢いです)
386
387=begin original
388
389207For more information see "man strptime", which should be on all unix
390208systems.
391209
392=end original
210もっと知りたければ、"man strptime"を見て下さい。これは、
211すべての unix システムで使えます。
393212
394もっと知りたければ、"man strptime" を見て下さい;
395これは、すべての unix システムで使えるはずです。
396
397=begin original
398
399Alternatively look here: http://www.unix.com/man-page/FreeBSD/3/strftime/
400
401=end original
402
403あるいは、次のリンクを見てください:
404http://www.unix.com/man-page/FreeBSD/3/strftime/
405
406213=head2 YYYY-MM-DDThh:mm:ss
407214
408=begin original
409
410215The ISO 8601 standard defines the date format to be YYYY-MM-DD, and
411216the time format to be hh:mm:ss (24 hour clock), and if combined, they
412217should be concatenated with date first and with a capital 'T' in front
413218of the time.
414219
415=end original
220ISO 8601 標準は、日付のフォーマットを YYYY-MM-DDとして、定めています。
221時間は、hh:mm:ss(24時)です。組み合わせる場合、
222日付を最初にして、時間の前に大文字の'T'で結び付ける必要があります。
416223
417ISO 8601 標準は、日付のフォーマットを YYYY-MM-DD として、
224=head2 週番号
418時刻は hh:mm:ss(24 時制) として定めています。
419組み合わせる場合、日付を最初にして、時刻の前に大文字の 'T' で結び付ける
420必要があります。
421225
422=head2 Week Number
423
424(週番号)
425
426=begin original
427
428226The I<week number> may be an unknown concept to some readers. The ISO
4292278601 standard defines that weeks begin on a Monday and week 1 of the
430228year is the week that includes both January 4th and the first Thursday
431229of the year. In other words, if the first Monday of January is the
4322302nd, 3rd, or 4th, the preceding days of the January are part of the
433231last week of the preceding year. Week numbers range from 1 to 53.
434232
435=end original
233I<週番号>は、読者によっては、その概念を知らないかもしれません。
234ISO 8601 標準は、週は、月曜で始まり、一年のweek 1は、1月4日と、
235一年の最初の木曜日の両方を含む週です。
236言い換えると、1月の最初の月曜日が2日か、3日か、4日であれば、
237その前の日は、昨年の最後の週の一部になります。週番号は、1から53の範囲です。
436238
437I<週番号> は、概念を知らい読者もいるかもしれません。
239=head2 グローバルオーバーライド
438ISO 8601 標準は、週は月曜で始まり、その年の第 1 週は 1 月 4 日と
439一年の最初の木曜日の両方を含む週であると定義しています。
440言い換えると、1 月の最初の月曜日が 2 日か、3 日か、4 日であれば、
441それより前の日は、昨年の最後の週の一部になります。
442週番号は、1 から 53 の範囲です。
443240
444=head2 Global Overriding
445
446(グローバルなオーバーライド)
447
448=begin original
449
450241Finally, it's possible to override localtime and gmtime everywhere, by
451242including the ':override' tag in the import list:
452243
453=end original
244localtime と gmtime をどこにでもオーバーライドするのを可能にします。
245インポートリストに、':override'を含めて下さい:
454246
455最後に、localtime と gmtime をどこにでもオーバーライドすることが可能です;
456インポートリストに、':override' タグを含めて下さい:
457
458247 use Time::Piece ':override';
459248
460=head1 CAVEATS
249=head1 著者
461250
462=head2 Setting $ENV{TZ} in Threads on Win32
463
464(Win32 でスレッドで $ENV{TZ} を設定する)
465
466=begin original
467
468Note that when using perl in the default build configuration on Win32
469(specifically, when perl is built with PERL_IMPLICIT_SYS), each perl
470interpreter maintains its own copy of the environment and only the main
471interpreter will update the process environment seen by strftime.
472
473=end original
474
475Win32 で perl をデフォルトビルド設定で使う場合
476(特に perl が PERL_IMPLICIT_SYS でビルドされている場合)、
477それぞれの perl インタプリタは独自の環境変数のコピーを保守していて、
478メインインタプリタのみが strftime で見られるプロセス環境変数を
479更新できることに注意してください。
480
481=begin original
482
483Therefore, if you make changes to $ENV{TZ} from inside a thread other than
484the main thread then those changes will not be seen by strftime if you
485subsequently call that with the %Z formatting code. You must change $ENV{TZ}
486in the main thread to have the desired effect in this case (and you must
487also call _tzset() in the main thread to register the environment change).
488
489=end original
490
491従って、メインスレッド以外のスレッド内から $ENV{TZ} を変更すると、
492後で strftime の %Z フォーマッティングコードを使っても変更は見えません。
493この場合、望み通りの効果を得るためにはメインスレッドで
494$ENV{TZ} を変更しなければなりません (そして環境変数の変更を登録するために
495メインスレッドで _tzset() を呼び出さなければなりません)。
496
497=begin original
498
499Furthermore, remember that this caveat also applies to fork(), which is
500emulated by threads on Win32.
501
502=end original
503
504さらに、この問題は fork() にも適用されることを忘れないでください; これは
505Win32 ではスレッドでエミュレートされています。
506
507=head2 Use of epoch seconds
508
509(紀元秒を使う)
510
511=begin original
512
513This module internally uses the epoch seconds system that is provided via
514the perl C<time()> function and supported by C<gmtime()> and C<localtime()>.
515
516=end original
517
518このモジュールは、perl の C<time()> 経由で提供され、C<gmtime()> と
519C<localtime()> が対応している紀元秒システムを内部で使用しています。
520
521=begin original
522
523If your perl does not support times larger than C<2^31> seconds then this
524module is likely to fail at processing dates beyond the year 2038. There are
525moves afoot to fix that in perl. Alternatively use 64 bit perl. Or if none
526of those are options, use the L<DateTime> module which has support for years
527well into the future and past.
528
529=end original
530
531C<2^31> 秒以上の時間に対応していない perl を使っている場合、このモジュールは
5322038 年以降の日付を扱おうとするとおそらく失敗するでしょう。
533これは perl 内で修正する動きがみられます。
534あるいは、64 ビット perl を使ってください。
535またはこれらの選択肢を取れない場合は、過去と未来の年に対応している
536L<DateTime> モジュールを使ってください。
537
538=head1 AUTHOR
539
540251Matt Sergeant, matt@sergeant.org
541252Jarkko Hietaniemi, jhi@iki.fi (while creating Time::Piece for core perl)
542253
543=head1 License
254=head1 ライセンス
544255
545256This module is free software, you may distribute it under the same terms
546257as Perl.
547258
548259=head1 SEE ALSO
549260
550=begin original
551
552261The excellent Calendar FAQ at http://www.tondering.dk/claus/calendar.html
553262
554=end original
263=head1 バグ
555264
556http://www.tondering.dk/claus/calendar.html にある素晴らしいカレンダー FAQ。
557
558=head1 BUGS
559
560=begin original
561
562265The test harness leaves much to be desired. Patches welcome.
563266
564=end original
267=head1 翻訳について
565268
566テストハーネスは望ましい状態にはほど遠いです。
269翻訳者:加藤敦 (ktat.is@gmail.com)
567パッチを歓迎します。
568270
569=begin meta
271Perlドキュメント日本語訳 Project にて、
272Perlモジュール、ドキュメントの翻訳を行っております。
570273
571Translate: 加藤敦 <ktat.is@gmail.com> (1.08)
274 http://perldocjp.sourceforge.jp/
572Update: SHIRAKATA Kentaro <argrath@ub32.org> (1.20)
275 http://sourceforge.jp/projects/perldocjp/
276 http://www.freeml.com/ctrl/html/MLInfoForm/perldocjp@freeml.com
574=end meta
277 http://www.perldoc.jp
575
576=cut