perl-DateTimeX-Period-0.03-alt1.noarch.rpm


Advertisement

Description

perl-DateTimeX-Period - Provides safe methods to get start and end of period

Property Value
Distribution ALT Linux Sisyphus
Repository Autoimports noarch
Package filename perl-DateTimeX-Period-0.03-alt1.noarch.rpm
Package name perl-DateTimeX-Period
Package version 0.03
Package release alt1
Package architecture noarch
Package type rpm
Category Development/Perl
Homepage -
License -
Maintainer -
Download size 12.02 KB
Installed size 12.02 KB
DateTimeX::Period is a subclass of DateTime & provides easy yet safe methods
to work in period context such as a day for all timezones.
It is recommended practise to work in UTC and switch to specific timezones only
when needed. IF YOU CAN DO SO, THEN THIS MODULE IS NOT FOR YOU!!!
Yet sometimes this is not possible and this module can help you. It works
around such problems like:
1. Assume you want to get start of the month, it's convenient to use
truncate() available in DateTime, however this would throw an error:
use DateTime;
my $dt = DateTime->new(
_year      => 2011,
_month     => 4,
_day       => 2,
_time_zone => 'Asia/Amman'
);
$dt->truncate(to => 'month'); # Runtime error
Q: You might have guessed, what did I do wrong?
A: Well time between 00:00 - 00:59 01/04/2011 in 'Asia/Amman' did not exist.
There are cases when you can't truncate to weeks, days or even hours!
( see unit tests ).
2. Assume your client that lives in 'America/Goose_Bay' is running your app and
today is 13/03/2010 00:05, and your app for whatever reason adds a day:
use DateTime;
my $dt = DateTime->new(
_year      =>2010,
_month     => 3,
_day       => 13,
_minute    => 5,
_time_zone => 'America/Goose_Bay',
);
$dt->add(days => 1); # Runtime error!
Q: What's wrong now?
A: 14/03/2010 00:05 in 'America/Goose_Bay' did not exist!
3. Assume you are running critical application that needs to get epoch!
Conveniently DateTime has epoch() and for whatever reasons you need to perform
some operations, such as these:
use DateTime;
my $dt = DateTime->new(
_year=> 2013,
_month => 10,
_day => 26,
_hour => 23,
_minute => 59,
_second => 59,
_time_zone => 'Atlantic/Azores',
);
$dt->add( seconds => 1 );    # 2013-10-27T00:00:00  same
print $dt->epoch();          # 1382832000           diff!!!
$dt->truncate(to => 'hour'); # 2013-10-27T00:00:00  same
print $dt->epoch();          # 1382835600           diff!!!
Q: Why epoch() returns different epoch time when local time doesn't change?
A: It so happens that 00:00 occurred twice! DateTime documentation classify this
as ambiguous and always returns later date! Whereas get_start('hour') from
DateTimeX::Period ( i.e. this module ), would have returned correct epoch:
use DateTimeX::Period;
my $dt = DateTime::Period->new(
_year=> 2013,
_month => 10,
_day => 26,
_hour => 23,
_minute => 59,
_second => 59,
_time_zone => 'Atlantic/Azores',
);
$dt->add( seconds => 1 );    # 2013-10-27T00:00:00  same
print $dt->epoch();          # 1382832000           same
$dt->get_start('hour');      # 2013-10-27T00:00:00  same
print $dt->epoch();          # 1382832000           same
All in all, this is convenient and safe module to play with when you can't use
UTC time. It is great solution for such case as following:
$user cannot use more than $threshold of something within a day in his local
time or within your operating timezone. Hence query database using its APIs to
get $user's $threshold so far and react upon:
pretended_api_call_GET_DATA(
_from => $dt->get_start('day')->epoch(),
_to   => $dt->get_end('day')->epoch(),
);

Alternatives

Package Version Architecture Repository
perl-DateTimeX-Period - - -

Requires

Name Value
/usr/share/perl5 -
perl(DateTime.pm) -
perl(Try/Tiny.pm) -
perl(parent.pm) -
rpmlib(PayloadIsLzma) -

Provides

Name Value
perl(DateTimeX/Period.pm) = 0.030
perl-DateTimeX-Period = 0.03-alt1

Download

Type URL
Mirror ftp.altlinux.org
Binary Package perl-DateTimeX-Period-0.03-alt1.noarch.rpm
Source Package perl-DateTimeX-Period-0.03-alt1.src.rpm

Install Howto

  1. Add the following line to /etc/apt/sources.list:
    
    rpm [Sisyphus] http://ftp.altlinux.org/pub/distributions/ALTLinux/autoimports/Sisyphus noarch autoimports
    rpm [Sisyphus] http://ftp.altlinux.org/pub/distributions/ALTLinux/autoimports/Sisyphus noarch autoimports
    
  2. Update the package index:
    # sudo apt-get update
  3. Install perl-DateTimeX-Period rpm package:
    # sudo apt-get install perl-DateTimeX-Period

Files

Path
/usr/share/doc/perl-DateTimeX-Period-0.03/Changes
/usr/share/doc/perl-DateTimeX-Period-0.03/LICENSE
/usr/share/perl5/DateTimeX/Period.pm

See Also

Package Description
perl-DateTimeX-Seinfeld-1.000-alt1.noarch.rpm Calculate Seinfeld chain length
perl-DateTimeX-Start-1.6.0-alt1.noarch.rpm Find the time at which a day starts
perl-DateTimeX-TO_JSON-0.0.2-alt1.noarch.rpm Adds a TO_JSON method to DateTime
perl-DateTimeX-Tiny-Compact-0.002-alt1.noarch.rpm DateTime::Tiny but uses less space
perl-DateTimeX-Web-0.08-alt1.noarch.rpm DateTime factory for web apps
perl-DateTimeX-ymdhms-0.0.2-alt1.noarch.rpm [One line description of module's purpose here]
perl-Date_Hijri-0.02-alt1.noarch.rpm perl module Date_Hijri
perl-Datify-0.19.045-alt1.noarch.rpm Simple stringification of data
perl-DayOfNthWeek-1.0-alt1.noarch.rpm perl module DayOfNthWeek
perl-Db-Mediasurface-0.03-alt1.noarch.rpm perl module Db-Mediasurface
perl-Db-Mediasurface-Cache-0.04-alt1.noarch.rpm perl module Db-Mediasurface-Cache
perl-Db-Mediasurface-ReadConfig-0.01-alt1.noarch.rpm perl module Db-Mediasurface-ReadConfig
perl-Debian-Apt-PM-0.09-alt1.noarch.rpm locate Perl Modules in Debian repositories
perl-Debian-Apt-PM-scripts-0.09-alt1.noarch.rpm Debian-Apt-PM scripts
perl-Debian-Copyright-0.2-alt1.noarch.rpm manage Debian copyright files
Advertisement
Advertisement