Changeset 24457

Show
Ignore:
Timestamp:
11/20/08 17:19:04 (7 weeks ago)
Author:
daisuke
Message:

TimeZones?, man

Location:
lang/perl/DateTime-Lite/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/DateTime-Lite/trunk/Makefile.PL

    r24134 r24457  
    55all_From('lib/DateTime/Lite.pm'); 
    66 
     7tests 't/*.t t/*/*.t'; 
    78requires 'SelfLoader'; 
    89WriteAll; 
  • lang/perl/DateTime-Lite/trunk/lib/DateTime/Lite.pm

    r24440 r24457  
    805805 
    806806__END__ 
     807 
     808=head1 NAME 
     809 
     810DateTime::Lite - A Low Calorie DateTime 
     811 
     812=head1 SYNOPSIS 
     813 
     814    use DateTime::Lite; 
     815 
     816    my $dt = DateTime::Lite->new(year => 2008, month => 12, day => 1); 
     817    $dt->year; 
     818    $dt->month; 
     819    $dt->day; 
     820    $dt->hour; 
     821    $dt->minuute; 
     822    $dt->second; 
     823 
     824    # Arithmetic doesn't come with DateTime::Lite by default 
     825    use DateTime::Lite qw(Arithmetic); 
     826    $dt->add( DateTime::Liate::Duration->new(days => 5) ); 
     827 
     828=head1 DESCRIPTION 
     829 
     830This is a complete rip-off of the great DateTime module. The code's greatnes owes everything to its author(s). 
     831 
     832However, this module was conceived out of a few specific desires : 
     833 
     834  (1) Reduce the amount of memory consumed 
     835  (2) Make it easy to install on rental servers 
     836  (3) Bundle everything in one distribution, including timezones 
     837 
     838To achieve this, we've taken the original DateTime and rearranged it as follows: 
     839 
     840=over 4 
     841 
     842=item DateTime::Lite is Pure Perl 
     843 
     844No 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. 
     845 
     846=item Parameter validation is done by hand 
     847 
     848Params::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. 
     849 
     850=item Non-essential methods are loaded on demand 
     851 
     852A 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. 
     853 
     854    use DateTime::Lite qw(Arithmetic); 
     855 
     856=item DateTime::Lite::TimeZone and DateTime::Lite::Locale are not singletons 
     857 
     858Singletons 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.  
     859 
     860With this version, the objects are mostly the just plain objects, and the exact definition for each timezone/locale is stored in YAML files. They can be located anywhere DateTime::Lite can find.  
     861 
     862In fact, we don't even bundle most of the timezones/locale that come with their respective sources. I only use Asia/Tokyo, if you live in US, you probably use about 5 at most. If you want more timezones, come grab them from http://tbd, and place it somewhere of your choice and set the appropriate environmental variables. DateTime::Lite will find it out. 
     863 
     864=back 
     865 
     866=cut 
  • lang/perl/DateTime-Lite/trunk/lib/DateTime/Lite/TimeZone.pm

    r24442 r24457  
    88use DateTime::Lite::TimeZone::OffsetOnly; 
    99use DateTime::Lite::TimeZone::UTC; 
     10use YAML(); 
    1011 
    1112use constant INFINITY     =>       100 ** 1000 ; 
     
    5657    } 
    5758 
    58 =head1 
    59     my $zone = $real_class->instance( name => $p{name}, is_olson => 1 ); 
    60  
    61     if ( $zone->is_olson() ) 
    62     { 
     59    my $zone = $class->new(%$conf); 
     60 
     61    if ( $zone->is_olson() ) { 
    6362        my $object_version = 
    6463            $zone->can('olson_version') 
     
    6968        if ( $object_version ne $catalog_version ) 
    7069        { 
    71             warn "Loaded $real_class, which is from an older version ($object_version) of the Olson database than this installation of DateTime::Lite::TimeZone ($catalog_version).\n"; 
     70            warn "Loaded $name, which is from an older version ($object_version) of the Olson database than this installation of DateTime::Lite::TimeZone ($catalog_version).\n"; 
    7271        } 
    7372    } 
    74 =cut 
    75  
    76     my $zone = $class->new(%$conf); 
     73 
    7774    return $zone; 
    7875} 
    7976 
     77sub new { my $class = shift; bless { @_ }, $class } 
     78 
    8079sub _load_time_zone { 
    81     die "Couldn't load timezone $_[0]"; 
     80    my $name = shift; 
     81    my $file = "$name.yaml"; 
     82    $file =~ s/-/_/g; 
     83    return YAML::LoadFile("misc/timezone/$file"); 
    8284} 
    8385