GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  DATE::HANDLER::DELTA (3)

.ds Aq ’

NAME

Date::Handler::Delta - Time lapse object

CONTENTS

SYNOPSIS



  use Date::Handler::Delta;

   my $delta = new Date::Handler::Delta([3,1,10,2,5,5]);
   my $delta = new Date::Handler::Delta({
                                                years => 3,
                                                months => 1,
                                                days => 10,
                                                hours => 2,
                                                minutes => 5,
                                                seconds => 5,
                                        });

   $delta->new                          (More information in perldoc Date::Handler::Delta)
   $delta->Months()                     Number of months in delta
   $delta->Seconds()                    Number of seconds in delta
   $delta->AsScalar()                   "%d months and %d seconds"
   $delta->AsNumber()                   "%d-%d-%d"
   $delta->AsArray()                    [y,m,ss]
   $delta->AsHash()                     { months => m, seconds => ss }

   $date + $delta = Date::Handler
   $date - $delta = Date::Handler
   $date - $date2 = Date::Handler::Delta
   $date + n = (+n seconds)
   $date - n = (-n seconds)

   $delta + $delta = Date::Handler::Delta
   $delta - $delta = Date::Handler::Delta
   $delta * n = Date::Handler::Delta
   $delta / n = Date::Handler::Delta
   $delta + n = (+n seconds)
   $delta - n = (-n seconds)



DESCRIPTION

Date::Handler::Delta is an object that represents a lapse of time. It’s internal representation of a time lapse if reduced to months and seconds. A Date::Handler::Delta object is always relative to a Date::Handler object, it’s calculation methods become active when the delta is applied to a date.

IMPLEMENTATION

Implementation details

    Creating a Date::Handler::Delta object

The new() constructor receives only one argument as an array reference or hash reference:



        my $delta = Date::Handler::Delta->new([1,3,5,0,0]);
        my $delta = Date::Handler::Delta->new({
                                                years => 1,
                                                months => 3,
                                                days => 5,
                                                minutes= > 0,
                                                seconds => 0,
                                        });



o As array reference, the order if years, months, days, minutes seconds
o As hash reference, the keys are years, months, days, minutes, seconds.

    Accessors

You can access the data inside the object using any of the provided methods. These methods are detailed in the SYNOPSIS up above.

Since Date::Handler uses operator overloading, you can ’apply’ a Delta object on an absolute date simply by using built-in operators.

Example:



        #A Delta of 1 year.
        my $delta = new Date::Handler::Delta([1,0,0,0,0,0]);

        my $date = new Date::Handler({ date => time } );

        #$newdate is now one year in the furure.
        my $newdate = $date+$delta;



    Operator overload special cases

The Date::Handler overloaded operator have special cases. Refer to the SYNOPSIS to get a description of each overloaded operator’s behaviour.

One special case of the overload is when adding an integer ’n’ to a Date::Handler’s reference. This is treated as if ’n’ was in seconds. Same thing for substraction.

Example Uses of the overload:



        my $date = new Date::Handler({ date =>
                                        {
                                                year => 2001,
                                                month => 5,
                                                day => 14,
                                                hour => 5,
                                                min => 0,
                                                sec => 0,
                                        }});
        #Quoted string overload
        print "Current date is $date\n";
       
        my $delta = new Date::Handler::Delta({ days => 5, });
       
        #+ overload, now, $date is 5 days in the future.     
        $date += $delta;

        #Small clock. Not too accurate, but still ;)
        while(1)
        {
                #Add one second to the date. (same as $date + 1)
                $date++;
                print "$date\n";
                sleep(1);
        }



BUGS (known)

Deltas going after 2038 are not handled by this module yet. (POSIX)

Deltas before 1902 are not handled by this module. (POSIX)

If you find bugs with this module, do not hesitate to contact the author. Your comments and rants are welcomed :)

TODO

Refine reduction to simplest expression of the delta.

COPYRIGHT

Copyright(c) 2001 Benoit Beausejour <bbeausej@pobox.com>

All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Portions Copyright (c) Philippe M. Chiasson <gozer@cpan.org>

Portions Copyright (c) Szabo\k:'Bala\k:'<dlux@kapu.hu>

Portions Copyright (c) Larry Rosler

AUTHOR

Benoit Beausejour <bbeausej@pobox.com>

SEE ALSO

Date::Handler(1). Date::Handler::Range(1). Class::Date(1). Time::Object(1). Date::Calc(1). perl(1).

POD ERRORS

Hey! <B>The above document had some coding errors, which are explained below:B>
Around line 459: Non-ASCII character seen before =encoding in ’Szabo\k:'Assuming ISO8859-1
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 HANDLER::DELTA (3) 2003-08-26

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.