Server IP : 103.119.228.120 / Your IP : 18.119.141.115 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/ssl/local/ssl/local/ssl/local/share/man/man3/ |
Upload File : |
.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "DateTime::Duration 3" .TH DateTime::Duration 3 "2016-08-06" "perl v5.16.3" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DateTime::Duration \- Duration objects for date math .SH "VERSION" .IX Header "VERSION" version 1.36 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use DateTime::Duration; \& \& $dur = DateTime::Duration\->new( \& years => 3, \& months => 5, \& weeks => 1, \& days => 1, \& hours => 6, \& minutes => 15, \& seconds => 45, \& nanoseconds => 12000 \& ); \& \& my ( $days, $hours, $seconds ) = $dur\->in_units(\*(Aqdays\*(Aq, \*(Aqhours\*(Aq, \*(Aqseconds\*(Aq); \& \& # Human\-readable accessors, always positive, but consider using \& # DateTime::Format::Duration instead \& $dur\->years; \& $dur\->months; \& $dur\->weeks; \& $dur\->days; \& $dur\->hours; \& $dur\->minutes; \& $dur\->seconds; \& $dur\->nanoseconds; \& \& $dur\->is_wrap_mode \& $dur\->is_limit_mode \& $dur\->is_preserve_mode \& \& print $dur\->end_of_month_mode; \& \& # Multiply all values by \-1 \& my $opposite = $dur\->inverse; \& \& my $bigger = $dur1 + $dur2; \& my $smaller = $dur1 \- $dur2; # the result could be negative \& my $bigger = $dur1 * 3; \& \& my $base_dt = DateTime\->new( year => 2000 ); \& my @sorted = \& sort { DateTime::Duration\->compare( $a, $b, $base_dt ) } @durations; \& \& if ( $dur\->is_positive ) { ... } \& if ( $dur\->is_zero ) { ... } \& if ( $dur\->is_negative ) { ... } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This is a simple class for representing duration objects. These objects are used whenever you do date math with DateTime.pm. .PP See the How DateTime Math Works section of the DateTime.pm documentation for more details. The short course: One cannot in general convert between seconds, minutes, days, and months, so this class will never do so. Instead, create the duration with the desired units to begin with, for example by calling the appropriate subtraction/delta method on a \f(CW\*(C`DateTime.pm\*(C'\fR object. .SH "METHODS" .IX Header "METHODS" Like \f(CW\*(C`DateTime\*(C'\fR itself, \f(CW\*(C`DateTime::Duration\*(C'\fR returns the object from mutator methods in order to make method chaining possible. .PP \&\f(CW\*(C`DateTime::Duration\*(C'\fR has the following methods: .SS "DateTime::Duration\->new( ... )" .IX Subsection "DateTime::Duration->new( ... )" This method takes the parameters \*(L"years\*(R", \*(L"months\*(R", \*(L"weeks\*(R", \*(L"days\*(R", \&\*(L"hours\*(R", \*(L"minutes\*(R", \*(L"seconds\*(R", \*(L"nanoseconds\*(R", and \*(L"end_of_month\*(R". All of these except \*(L"end_of_month\*(R" are numbers. If any of the numbers are negative, the entire duration is negative. .PP All of the numbers \fBmust be integers\fR. .PP Internally, years as just treated as 12 months. Similarly, weeks are treated as 7 days, and hours are converted to minutes. Seconds and nanoseconds are both treated separately. .PP The \*(L"end_of_month\*(R" parameter must be either \*(L"wrap\*(R", \*(L"limit\*(R", or \&\*(L"preserve\*(R". This parameter specifies how date math that crosses the end of a month is handled. .PP In \*(L"wrap\*(R" mode, adding months or years that result in days beyond the end of the new month will roll over into the following month. For instance, adding one year to Feb 29 will result in Mar 1. .PP If you specify \*(L"end_of_month\*(R" mode as \*(L"limit\*(R", the end of the month is never crossed. Thus, adding one year to Feb 29, 2000 will result in Feb 28, 2001. If you were to then add three more years this will result in Feb 28, 2004. .PP If you specify \*(L"end_of_month\*(R" mode as \*(L"preserve\*(R", the same calculation is done as for \*(L"limit\*(R" except that if the original date is at the end of the month the new date will also be. For instance, adding one month to Feb 29, 2000 will result in Mar 31, 2000. .PP For positive durations, the \*(L"end_of_month\*(R" parameter defaults to wrap. For negative durations, the default is \*(L"limit\*(R". This should match how most people \*(L"intuitively\*(R" expect datetime math to work. .ie n .SS "$dur\->\fIclone()\fP" .el .SS "\f(CW$dur\fP\->\fIclone()\fP" .IX Subsection "$dur->clone()" Returns a new object with the same properties as the object on which this method was called. .ie n .SS "$dur\->in_units( ... )" .el .SS "\f(CW$dur\fP\->in_units( ... )" .IX Subsection "$dur->in_units( ... )" Returns the length of the duration in the units (any of those that can be passed to \f(CW\*(C`new\*(C'\fR) given as arguments. All lengths are integral, but may be negative. Smaller units are computed from what remains after taking away the larger units given, so for example: .PP .Vb 1 \& my $dur = DateTime::Duration\->new( years => 1, months => 15 ); \& \& $dur\->in_units( \*(Aqyears\*(Aq ); # 2 \& $dur\->in_units( \*(Aqmonths\*(Aq ); # 27 \& $dur\->in_units( \*(Aqyears\*(Aq, \*(Aqmonths\*(Aq ); # (2, 3) \& $dur\->in_units( \*(Aqweeks\*(Aq, \*(Aqdays\*(Aq ); # (0, 0) ! .Ve .PP The last example demonstrates that there will not be any conversion between units which don't have a fixed conversion rate. The only conversions possible are: .IP "\(bu" 8 years <=> months .IP "\(bu" 8 weeks <=> days .IP "\(bu" 8 hours <=> minutes .IP "\(bu" 8 seconds <=> nanoseconds .PP For the explanation of why this is the case, please see the How DateTime Math Works section of the DateTime.pm documentation .PP Note that the numbers returned by this method may not match the values given to the constructor. .PP In list context, in_units returns the lengths in the order of the units given. In scalar context, it returns the length in the first unit (but still computes in terms of all given units). .PP If you need more flexibility in presenting information about durations, please take a look a \f(CW\*(C`DateTime::Format::Duration\*(C'\fR. .ie n .SS "$dur\->\fIis_positive()\fP, $dur\->\fIis_zero()\fP, $dur\->\fIis_negative()\fP" .el .SS "\f(CW$dur\fP\->\fIis_positive()\fP, \f(CW$dur\fP\->\fIis_zero()\fP, \f(CW$dur\fP\->\fIis_negative()\fP" .IX Subsection "$dur->is_positive(), $dur->is_zero(), $dur->is_negative()" Indicates whether or not the duration is positive, zero, or negative. .PP If the duration contains both positive and negative units, then it will return false for \fBall\fR of these methods. .ie n .SS "$dur\->\fIis_wrap_mode()\fP, $dur\->\fIis_limit_mode()\fP, $dur\->\fIis_preserve_mode()\fP" .el .SS "\f(CW$dur\fP\->\fIis_wrap_mode()\fP, \f(CW$dur\fP\->\fIis_limit_mode()\fP, \f(CW$dur\fP\->\fIis_preserve_mode()\fP" .IX Subsection "$dur->is_wrap_mode(), $dur->is_limit_mode(), $dur->is_preserve_mode()" Indicates what mode is used for end of month wrapping. .ie n .SS "$dur\->\fIend_of_month_mode()\fP" .el .SS "\f(CW$dur\fP\->\fIend_of_month_mode()\fP" .IX Subsection "$dur->end_of_month_mode()" Returns one of \*(L"wrap\*(R", \*(L"limit\*(R", or \*(L"preserve\*(R". .ie n .SS "$dur\->\fIcalendar_duration()\fP" .el .SS "\f(CW$dur\fP\->\fIcalendar_duration()\fP" .IX Subsection "$dur->calendar_duration()" Returns a new object with the same \fIcalendar\fR delta (months and days only) and end of month mode as the current object. .ie n .SS "$dur\->\fIclock_duration()\fP" .el .SS "\f(CW$dur\fP\->\fIclock_duration()\fP" .IX Subsection "$dur->clock_duration()" Returns a new object with the same \fIclock\fR deltas (minutes, seconds, and nanoseconds) and end of month mode as the current object. .ie n .SS "$dur\->inverse( ... )" .el .SS "\f(CW$dur\fP\->inverse( ... )" .IX Subsection "$dur->inverse( ... )" Returns a new object with the same deltas as the current object, but multiple by \-1. The end of month mode for the new object will be the default end of month mode, which depends on whether the new duration is positive or negative. .PP You can set the end of month mode in the inverted duration explicitly by passing \*(L"end_of_month => ...\*(R" to the \f(CW\*(C`inverse()\*(C'\fR method. .ie n .SS "$dur\->add_duration( $duration_object ), $dur\->subtract_duration( $duration_object )" .el .SS "\f(CW$dur\fP\->add_duration( \f(CW$duration_object\fP ), \f(CW$dur\fP\->subtract_duration( \f(CW$duration_object\fP )" .IX Subsection "$dur->add_duration( $duration_object ), $dur->subtract_duration( $duration_object )" Adds or subtracts one duration from another. .ie n .SS "$dur\->add( ... ), $dur\->subtract( ... )" .el .SS "\f(CW$dur\fP\->add( ... ), \f(CW$dur\fP\->subtract( ... )" .IX Subsection "$dur->add( ... ), $dur->subtract( ... )" Syntactic sugar for addition and subtraction. The parameters given to these methods are used to create a new object, which is then passed to \&\f(CW\*(C`add_duration()\*(C'\fR or \f(CW\*(C`subtract_duration()\*(C'\fR, as appropriate. .ie n .SS "$dur\->multiply( $number )" .el .SS "\f(CW$dur\fP\->multiply( \f(CW$number\fP )" .IX Subsection "$dur->multiply( $number )" Multiplies each unit in the by the specified number. .ie n .SS "DateTime::Duration\->compare( $duration1, $duration2, $base_datetime )" .el .SS "DateTime::Duration\->compare( \f(CW$duration1\fP, \f(CW$duration2\fP, \f(CW$base_datetime\fP )" .IX Subsection "DateTime::Duration->compare( $duration1, $duration2, $base_datetime )" This is a class method that can be used to compare or sort durations. Comparison is done by adding each duration to the specified \&\f(CW\*(C`DateTime.pm\*(C'\fR object and comparing the resulting datetimes. This is necessary because without a base, many durations are not comparable. For example, 1 month may or may not be longer than 29 days, depending on what datetime it is added to. .PP If no base datetime is given, then the result of \f(CW\*(C`DateTime\->now\*(C'\fR is used instead. Using this default will give non-repeatable results if used to compare two duration objects containing different units. It will also give non-repeatable results if the durations contain multiple types of units, such as months and days. .PP However, if you know that both objects only consist of one type of unit (months \fIor\fR days \fIor\fR hours, etc.), and each duration contains the same type of unit, then the results of the comparison will be repeatable. .ie n .SS "$dur\->\fIdelta_months()\fP, $dur\->\fIdelta_days()\fP, $dur\->\fIdelta_minutes()\fP, $dur\->\fIdelta_seconds()\fP, $dur\->\fIdelta_nanoseconds()\fP" .el .SS "\f(CW$dur\fP\->\fIdelta_months()\fP, \f(CW$dur\fP\->\fIdelta_days()\fP, \f(CW$dur\fP\->\fIdelta_minutes()\fP, \f(CW$dur\fP\->\fIdelta_seconds()\fP, \f(CW$dur\fP\->\fIdelta_nanoseconds()\fP" .IX Subsection "$dur->delta_months(), $dur->delta_days(), $dur->delta_minutes(), $dur->delta_seconds(), $dur->delta_nanoseconds()" These methods provide the information \f(CW\*(C`DateTime.pm\*(C'\fR needs for doing date math. The numbers returned may be positive or negative. This is mostly useful for doing date math in DateTime. .ie n .SS "$dur\->\fIdeltas()\fP" .el .SS "\f(CW$dur\fP\->\fIdeltas()\fP" .IX Subsection "$dur->deltas()" Returns a hash with the keys \*(L"months\*(R", \*(L"days\*(R", \*(L"minutes\*(R", \*(L"seconds\*(R", and \&\*(L"nanoseconds\*(R", containing all the delta information for the object. This is mostly useful for doing date math in DateTime. .ie n .SS "$dur\->\fIyears()\fP, $dur\->\fImonths()\fP, $dur\->\fIweeks()\fP, $dur\->\fIdays()\fP, $dur\->\fIhours()\fP, $dur\->\fIminutes()\fP, $dur\->\fIseconds()\fP, $dur\->\fInanoseconds()\fP" .el .SS "\f(CW$dur\fP\->\fIyears()\fP, \f(CW$dur\fP\->\fImonths()\fP, \f(CW$dur\fP\->\fIweeks()\fP, \f(CW$dur\fP\->\fIdays()\fP, \f(CW$dur\fP\->\fIhours()\fP, \f(CW$dur\fP\->\fIminutes()\fP, \f(CW$dur\fP\->\fIseconds()\fP, \f(CW$dur\fP\->\fInanoseconds()\fP" .IX Subsection "$dur->years(), $dur->months(), $dur->weeks(), $dur->days(), $dur->hours(), $dur->minutes(), $dur->seconds(), $dur->nanoseconds()" These methods return numbers indicating how many of the given unit the object represents, after having done a conversion to any larger units. For example, days are first converted to weeks, and then the remainder is returned. These numbers are always positive. .PP Here's what each method returns: .PP .Vb 8 \& $dur\->years() == abs( $dur\->in_units(\*(Aqyears\*(Aq) ) \& $dur\->months() == abs( ( $dur\->in_units( \*(Aqmonths\*(Aq, \*(Aqyears\*(Aq ) )[0] ) \& $dur\->weeks() == abs( $dur\->in_units( \*(Aqweeks\*(Aq ) ) \& $dur\->days() == abs( ( $dur\->in_units( \*(Aqdays\*(Aq, \*(Aqweeks\*(Aq ) )[0] ) \& $dur\->hours() == abs( $dur\->in_units( \*(Aqhours\*(Aq ) ) \& $dur\->minutes == abs( ( $dur\->in_units( \*(Aqminutes\*(Aq, \*(Aqhours\*(Aq ) )[0] ) \& $dur\->seconds == abs( $dur\->in_units( \*(Aqseconds\*(Aq ) ) \& $dur\->nanoseconds() == abs( ( $dur\->in_units( \*(Aqnanoseconds\*(Aq, \*(Aqseconds\*(Aq ) )[0] ) .Ve .PP If this seems confusing, remember that you can always use the \&\f(CW\*(C`in_units()\*(C'\fR method to specify exactly what you want. .PP Better yet, if you are trying to generate output suitable for humans, use the \f(CW\*(C`DateTime::Format::Duration\*(C'\fR module. .SS "Overloading" .IX Subsection "Overloading" This class overloads addition, subtraction, and mutiplication. .PP Comparison is \fBnot\fR overloaded. If you attempt to compare durations using \f(CW\*(C`<=>\*(C'\fR or \f(CW\*(C`cmp\*(C'\fR, then an exception will be thrown! Use the \&\f(CW\*(C`compare()\*(C'\fR class method instead. .SH "SEE ALSO" .IX Header "SEE ALSO" datetime@perl.org mailing list .PP http://datetime.perl.org/ .SH "SUPPORT" .IX Header "SUPPORT" Support for this module is provided via the datetime@perl.org email list. See http://lists.perl.org/ for more details. .PP Bugs may be submitted through the \s-1RT\s0 bug tracker <http://rt.cpan.org/Public/Dist/Display.html?Name=DateTime> (or bug\-datetime@rt.cpan.org <mailto:bug-datetime@rt.cpan.org>). .PP There is a mailing list available for users of this distribution, <mailto:datetime@perl.org>. .PP I am also usually active on \s-1IRC\s0 as 'drolsky' on \f(CW\*(C`irc://irc.perl.org\*(C'\fR. .SH "AUTHOR" .IX Header "AUTHOR" Dave Rolsky <autarch@urth.org> .SH "COPYRIGHT AND LICENCE" .IX Header "COPYRIGHT AND LICENCE" This software is Copyright (c) 2016 by Dave Rolsky. .PP This is free software, licensed under: .PP .Vb 1 \& The Artistic License 2.0 (GPL Compatible) .Ve