Hi,

I have an RFC/request for blessing for a module.

So I have this requirement to make DateTime leaner, in terms of speed,
load time, and the amount of memory consumed. The target is for casual
users, so the use of XS code is not an option either.

I've done my share of hacking DateTime before, and I believe that
changing the DateTime.pm code base itself is not really an option since
DateTime needs to be backward compatible and what not.

Instead I took the approach of using DateTime.pm as a reference
implementation, and rearranged the code somewhat to get the desired effect.

Now I have something that passes all current DateTime tests and named it
DateTime::Lite. I intend to do some more hacking soon ish, but thought
I'd ask for your comments before hand.

I've pasted the current POD for DateTime::Lite at the end of this email.
Also, if you are interested, the code is at

note that the location of time zones and locales are hard coded now, so
DateTime::Lite will only work from the checked out root.

regards,

--d

=head1 NAMEDateTime::Lite - A Low Calorie DateTime

=head1 SYNOPSIS

    use DateTime::Lite;

    my $dt = DateTime::Lite->new(year => 2008, month => 12, day => 1);
    $dt->year;
    $dt->month;
    $dt->day;
    $dt->hour;
    $dt->minuute;
    $dt->second;

    # Arithmetic doesn't come with DateTime::Lite by default
    use DateTime::Lite qw(Arithmetic);
    $dt->add( DateTime::Lite::Duration->new(days => 5) );

=head1 DESCRIPTION

This is a complete rip-off of the great DateTime module. The author
simply copy
and pasted about 90% of the code, tweaked it and repackaged it. All
credits go t
o the original DateTime.pm's authors.However, this module was conceived
out of a few specific desires :

  (1) Target those who do not need the full feature of DateTime.pm
  (2) Get better performance:
      * Reduce the amount of memory consumed, and      * Reduce the time
it takes to load the module  (3) Make it easy to install on rental servers
  (4) Bundle everything in one distribution, including timezones and locales

To achieve this, we've taken the original DateTime and rearranged it as
follows:

=over 4

=item DateTime::Lite is Pure Perl

No XS, pronto. Since we expect the audience to be people who are not
sysadmins, we don't expect them to have a full compiler support
either.=item Parameter validation is done by hand
=item Parameter validation is done by hand

Params::Validate is a great module, but it slows things down. We don't
see the merit of removing it from the original DateTime.pm, but we did
so in this version.

=item Non-essential methods are loaded on demand

A lot of times you don't even need to do date time arithmetic, for
example. These methods are separated out onto a different file, so you
need to load it on demand.

    use DateTime::Lite qw(Arithmetic);
    use DateTime::Lite qw(Strftime);

=item DateTime::Lite::TimeZone and DateTime::Lite::Locale

DateTime::Lite::TimeZone and DateTime::Lite::Locale have big changes
from their original counterparts.

First, you do NOT call new() on these objects (unless this is something
you explicitly want to do). Instead, you need to call load(). So if you
were mucking with DateTime::Lite::TimeZone and DateTime::Locale, you
need to find out every occurance of

    DateTime::Lite::TimeZone->load( name => 'Asia/Tokyo' );

and change them to

    DateTime::Lite::TimeZone->load( name => 'Asia/Tokyo' );

Singletons are okay, they serve a particular purpose. But besides being
a memory hog of relative low benefit, when given the number of time
zones are locales, they are just way too overwhelming for underlings.

With this version, the objects are mostly the just plain objects, and
the exact definition for each timezone/locale is stored in data files. #
TODO: They can be located anywhere DateTime::Lite can find them

TODO: We want to make it easy to pick and choose which locales/timezones
to be available -- DateTime::TimeZone and Locale comes with the
full-set, and normally we don't need this feature. For example, I only
use Asia/Tokyo and UTC time zones for my dayjob. When we ask casual
users to install a datetime package, we do not want to overwhelm then
with 100+ timezones and locales.

=cut

Reply via email to