Skip to content

Latest commit

 

History

History
executable file
·
577 lines (385 loc) · 16.9 KB

File metadata and controls

executable file
·
577 lines (385 loc) · 16.9 KB

NAME

Time::Piece - ��ŝ����吾�с�壔����������ʋ�������ŝ����吾�с�壔��

SYNOPSIS

use Time::Piece;

my $t = localtime;
print "Time is $t\n";
print "Year is ", $t->year, "\n";

DESCRIPTION

�����勉�≪�吾�ャ�若�˨�壔��罔�羣���� localtime ��� gmtime ��∽�違�������ŝ����吾�с�壔�����菴���� 絎�茖���勉����勉�̥舟�����������障����� ���������緇���剛�������с��������綵≪�ц�������勉�с��perlfunc �����吾�������⓾������������� localtime/gmtime ���篏帥�c�⓾��������緇���������勉����勉��菴������障�����

�����勉�≪�吾�ャ�若�˨�壔��Larry Wall ��� perl5-porters ��<�若�ŝ�潟�違�ŝ�鴻�������吾�������� ��ゃ�潟�帥�若����с�若�鴻�勉�祉�������í��絎�������絎�茖������障��: http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2000-01/msg00241.html

USAGE

(篏帥�����)

�����勉�≪�吾�ャ�若�˨����ゃ�潟����若��������緇���壔����鴻�˨�í�潟�潟����㏍�鴻����� localtime ��� gmtime ���篏帥����������ヤ��������������茵◐憗�������勰����勉�鴻�˨�ð��絖������с�壔�ŝ����� Time::Piece ��ŝ����吾�с�壔�����緇���障����� Time::Piece ��ŝ����吾�с�壔����勖��絖���������壔����句�吟�˨�� localtime ��� gmtime ��∽�違� ��������号�������������障����� new() ��潟�潟�鴻����í�壔�帥����������障��������Time::Piece ��ŝ����吾�с�壔�����羝<�������ŝ�������� localtime() �����������с����� Time::Piece ��ŝ����吾�с�壔�����羝<����������������潟����若�潟�潟�鴻����í�壔�帥�˨�ŝ����障����� 筝�荐���勉�<�純����������ŝ����吾�с�壔����у�ñ����с����障��:

$t->sec                 # $t->second ����
$t->min                 # $t->minute ����
$t->hour                # 24 �����
$t->mday                # $t->day_of_month ����
$t->mon                 # 1 = 筝����
$t->_mon                # 0 = 筝����
$t->monname             # Feb
$t->month               # $t->monname ���������
$t->fullmonth           # February
$t->year                # 0 紮���障��(AD 0 綛眼�壔�������<��������BC 1 綛�)
$t->_year               # 綛眼����� 1900 ���綣������������
$t->yy                  # 2 罅���勐拘
$t->wday                # 1 = ��ユ��
$t->_wday               # 0 = ��ユ��
$t->day_of_week         # 0 = ��ユ��
$t->wdayname            # Tue
$t->day                 # wdayname ���������
$t->fullday             # Tuesday
$t->yday                # $t->day_of_year ������, 0 = 1 ��� 1 ��
$t->isdst               # $t->daylight_savings ����檽��

$t->hms                 # 12:34:56
$t->hms(".")            # 12.34.56
$t->time                # $t->hms ���������

$t->ymd                 # 2000-02-29
$t->date                # $t->ymd ���������
$t->mdy                 # 02-29-2000
$t->mdy("/")            # 02/29/2000
$t->dmy                 # 29-02-2000
$t->dmy(".")            # 29.02.2000
$t->datetime            # 2000-02-29T12:34:56 (ISO 8601)
$t->cdate               # Tue Feb 29 12:34:56 2000
"$t"                    # $t->cdate ���������

$t->epoch               # epoch��������勛��
$t->tzoffset            # Time::Seconds ��ŝ����吾�с�壔����˨�������帥�ゃ����障�若�潟�ŝ����祉�����

$t->julian_day          # ��⓾�ŝ�⓾�号⑳���紮���障�c�⓾�������勖�ャ�勖�
$t->mjd                 # 篆勖③��⓾�ŝ�⓾�号�� (JD-2400000.5 ���)

$t->week                # ��援�ɱ�� (ISO 8601)

$t->is_leap_year        # ��鎶眼�ŝ��������菴����
$t->month_last_day      # 28-31

$t->time_separator($s)  # ��������í�˨����勉�祉����㋘�若�帥��荐㊤�� (��������í�˨�� ":")
$t->date_separator($s)  # ��������í�˨����勉�祉����㋘�若�帥��荐㊤�� (��������í�˨�� "-")
$t->day_list(@days)     # ��������í�˨����勖����ャ��荐㊤��
$t->mon_list(@days)     # ��������í�˨����勖��������荐㊤��

$t->strftime(FORMAT)    # POSIX::strftime ���������(���������絎������
                        # POSIX ��≦宍��勉�������勉�ŝ�若����若����������壔�������障�����)
$t->strftime()          # "Tue, 29 Feb 2000 12:34:56 GMT"

Time::Piece->strptime(STRING, FORMAT)
                        # strptime man �����若�吾��荀���☖�������������違����
                        # Time::Piece ��ŝ����吾�с�壔�����篏������障��

Local Locales

(��㏍�若�˨�˨�㏍�宴�若��)

wdayname (day) ��� monname (month) ��勌検��鴻�������˨�������ャ�勉�ゃ�潟�������壔�鴻�˩戎��� ��ŝ�鴻�����羝<�������������с����障����� 絎������˨�㏍�宴�若�˨����ゃ�潟�鴻����若�˨��������篏帥�c�������������˨��������腮勉�勐�医��������絎�茖������� 綽�荀������������ŝ�������������с�����������

my @days = qw( Dimanche Lundi Merdi Mercredi Jeudi Vendredi Samedi );

my $french_day = localtime->day(@days);

�����������勤┃絎���壔�違�㏍�若����˨�˨����ŝ�若����若�í�ゃ����с����障��:

Time::Piece::day_list(@days);

��障����������ŝ��:

Time::Piece::mon_list(@months);

�����̹�≪����⓾�㏍�若�˨�˨�̬�������ŝ��:

print localtime->month(@months);

Date Calculations

(��ヤ����勖��膊�)

���膣���ŝ�ŝ����吾�с�壔����勤恭���膊����綣����膊������с����障��:

use Time::Seconds;

my $seconds = $t1 - $t2;
$t1 += ONE_DAY; # add 1 day (constant from Time::Seconds)

筝�荐���勉����勉�壩����鴻�с��($t1 ��� $t2 ��� Time::Piece ��ŝ����吾�с�壔��):

$t1 - $t2; # returns Time::Seconds object
$t1 - 42; # returns Time::Piece object
$t1 + 533; # returns Time::Piece object

��с��������Time::Piece ��ŝ����吾�с�壔�������ャ�� Time::Piece ��ŝ����吾�с�壔����� 莇潟����勉�壔��絎�茵���������í�若��綣����莎激�������障�����

筝���勌����勖�������勉����勉�壔��Time::Seconds ��ŝ����吾�с�壔�����菴�������������羈���������☖��������; ��ŝ����吾�с�壔�����荅☁�����������������(��ŝ�若����若�㏍�若����˨����c��)腱���違����阪��������筝���鴻�с�� Time::Seconds ��� API ���篏帥�c�⓾�������勐勲��違�������������違����������違����ユ�違����宴�勖�違�� 綛贋�違��緇���������������堺�ャ�障�����

腱���勐��膊������������⓾��������綛眼�����膊���������������勌����ゃ�� API �����������障��:

$t->add_months(6);
$t->add_years(5);

������綛眼�壩��膊���勉�������̬����違�˨����ŝ��緇���障����� �����˨�ф��������羝�膊������������������������ŝ����壔����������˨�ŝ�����������羈���������⓾�������������� 筝���㋜����̥����������ŝ�����������紮������������㏍����翫����������ŝ�c����ャ�勐�����菴遵����������障����� 箴������違��2008-03-31 ������ 1 ��倶��綣����������������緇���ŝ����ヤ����с����� 2008-02-31 ��˨� ��ŝ����障�������� 篁c�������� 2008-03-02 ��˨�ŝ����障����� ��������壚����勖�ヤ�����篏������若�˨��筝�莢���с����������������������������障�����

Date Comparisons

(��ヤ����勖��莠�)

��ヤ����勖��莠�����櫝�純�с��; "<"��� ">"���"<="��� ">="��� "<=>"��� "=="��� "!=" ��勐����⓾��篏帥����障�����

Date Parsing

(��ヤ����勤В���)

Time::Piece ��壔��薊������祉�ð��荵������ヤ�����茹f��������腟���粋昭��帥�� (FreeBSD ��掩�ャ��) strptime() ��∽�違��篏帥����障����� ������������:

my $t = Time::Piece->strptime("Sunday 3rd Nov, 1943",
                              "%A %drd %b, %Y");

print $t->strftime("%a, %d %b %Y");

罨<�勉����������阪�������障��:

Wed, 03 Nov 1943

(��祉�����腱���勌����勛�㊦�吟�ʋ�ヤ����勉����違����眼����勉����������ŝ��������莖≪����с��)

�����c�◐�ャ�������������違��"man strptime" ���荀���☖��������; ��������壔�������鴻�⓾�� unix ��激�鴻�������т戎��������壔����с�����

�����������壔��罨<�勉�ŝ�潟�壔��荀���⓾�����������: http://www.unix.com/man-page/FreeBSD/3/strftime/

YYYY-MM-DDThh:mm:ss

ISO 8601 罔�羣���壔����ヤ����勉����í�若����������� YYYY-MM-DD ��������⓾�� �����祉�� hh:mm:ss(24 ������) ��������☗�������⓾����障����� 腟���水�������������翫�������ヤ�������������˨����⓾�������祉�勐�����紊ф��絖���� 'T' ��х����割�������� 綽�荀������������障�����

Week Number

(��援�ɱ��)

��援�ɱ�� ��壔��网�綽泣����ャ����ŝ��茯㊧�������������������������障�������� ISO 8601 罔�羣���壔����宴�壩�������у����障����������勐拘��勛⓬ 1 ��宴�� 1 ��� 4 ��ャ� 筝�綛眼�勖�������勖�������ャ�勌検��鴻����˨����宴�с��������絎�臂í����⓾����障����� 荐�������������������1 �����勖�������勖�������ャ�� 2 ��ャ�����3 ��ャ�����4 ��ャ�с�������違�� �����������������勖�ャ�壔�����綛眼�勖��緇���勰�宴�勌�������˨�ŝ����障����� ��援�ɱ垩�壔��1 ������ 53 ��勛����蚊�с�����

Global Overriding

(��違�㏍�若����˨�ŝ�ŝ�若����若�í�ゃ��)

���緇���˨��localtime ��� gmtime �����í����˨�с����ŝ�若����若�í�ゃ������������������櫝�純�с��; ��ゃ�潟����若����ŝ�鴻����˨��':override' ��帥�違����˨����☖��������:

use Time::Piece ':override';

CAVEATS

Setting $ENV{TZ} in Threads on Win32

(Win32 ��с�鴻�㋘�������� $ENV{TZ} ���荐㊤��������)

Win32 ��� perl �����������í�˨�������˨��荐㊤����т戎�����翫�� (��鴻�� perl ��� PERL_IMPLICIT_SYS ��с����˨����������⓾�������翫��)��� ��������������� perl ��ゃ�潟�帥����ŝ�帥�夌�㋝�ŝ�勛�医��紊���違�勉�潟����若��篆�絎������⓾����⓾�� ��<�ゃ�潟�ゃ�潟�帥����ŝ�帥�勉�帥�� strftime ��ц����������������㏍�祉�合�医��紊���違�� ��贋�違�с��������������羈���������⓾��������������

緇���c�⓾����<�ゃ�潟�鴻�㋘�����篁ュ����勉�鴻�㋘�������������� $ENV{TZ} ���紊���眼����������� 緇���� strftime ��� %Z �����í�若����������c�潟�違�潟�若�����篏帥�c�⓾��紊���眼�虁�������障�������� �����勐�翫����������翠�������勐�号�����緇������������˨�壔�<�ゃ�潟�鴻�㋘������� $ENV{TZ} ���紊���眼����ŝ�������違�ŝ����障����� (��������☎�医��紊���違�勐����眼����脂�蚊������������� ��<�ゃ�潟�鴻�㋘�������� _tzset() �����若�喝�冴����ŝ�������違�ŝ����障�����)���

��������˨�������勐�馹���� fork() ��˨����ñ��������������������綽������ŝ����с�����������; �������� Win32 ��с�壔�鴻�㋘�������с�������ャ�㋘�若����������⓾����障�����

Use of epoch seconds

(膣����腱����篏帥��)

�����勉�≪�吾�ャ�若�˨�壔��perl ��� time() 腟���宴�ф��箴����������gmtime() �� localtime() ���絲上�������⓾�����膣����腱���激�鴻����������������т戎��������⓾����障�����

2^31 腱�篁ヤ����勖��������絲上�������⓾����ŝ�� perl ���篏帥�c�⓾�������翫����������勉�≪�吾�ャ�若�˨� 2038 綛岩札�����勖�ヤ�������宴����������������������������鎀掩����������с����������� ��������� perl �����т信罩c����������������帥�������障����� �����������壔��64 ��������� perl ���篏帥�c�⓾�������������� ��障����壔����������勰�御����≪����������ŝ����翫����壔������サ�����ʋ�ャ�勐拘���絲上�������⓾����� DateTime ��≪�吾�ャ�若�˨��篏帥�c�⓾��������������

AUTHOR

Matt Sergeant, matt@sergeant.org Jarkko Hietaniemi, jhi@iki.fi (while creating Time::Piece for core perl)

License

This module is free software, you may distribute it under the same terms as Perl.

SEE ALSO

http://www.tondering.dk/claus/calendar.html ��˨�����膣���眼����������˨�㋘�潟����� FAQ���

BUGS

�����鴻�������若����鴻�壩����障�������倶����˨�壔�祉�ó�������с����� ������������罩�菴������障�����