PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|Code_Examples|Perl|site_perl|DateTime|TimeZone.pm =

page 6 of 9




    $offset = abs($offset);

    my $hours = int( $offset / 3600 );
    $offset %= 3600;
    my $mins = int( $offset / 60 );
    $offset %= 60;
    my $secs = int( $offset );

    return ( $secs ?
             sprintf( '%s%02d%02d%02d', $sign, $hours, $mins, $secs ) :
             sprintf( '%s%02d%02d', $sign, $hours, $mins )
           );
}

# These methods all operate on data contained in the DateTime/TimeZoneCatalog.pm file.

sub all_names
{
    return wantarray ? @DateTime::TimeZone::ALL : [@DateTime::TimeZone::ALL];
}

sub categories
{
    return wantarray
        ? @DateTime::TimeZone::CATEGORY_NAMES
        : [@DateTime::TimeZone::CATEGORY_NAMES];
}

sub links
{
    return
        wantarray ? %DateTime::TimeZone::LINKS : {%DateTime::TimeZone::LINKS};
}

sub names_in_category
{
    shift if $_[0]->isa('DateTime::TimeZone');
    return unless exists $DateTime::TimeZone::CATEGORIES{ $_[0] };

    return
        wantarray
        ? @{ $DateTime::TimeZone::CATEGORIES{ $_[0] } }
        : [ $DateTime::TimeZone::CATEGORIES{ $_[0] } ];
}

sub countries
{
    wantarray
        ? ( sort keys %DateTime::TimeZone::ZONES_BY_COUNTRY )
        : [ sort keys %DateTime::TimeZone::ZONES_BY_COUNTRY ];
}

sub names_in_country
{
    shift if $_[0]->isa('DateTime::TimeZone');

    return unless exists $DateTime::TimeZone::ZONES_BY_COUNTRY{ lc $_[0] };

    return
        wantarray
        ? @{ $DateTime::TimeZone::ZONES_BY_COUNTRY{ lc $_[0] } }
        : $DateTime::TimeZone::ZONES_BY_COUNTRY{ lc $_[0] };
}


1;

__END__

=head1 NAME

DateTime::TimeZone - Time zone object base class and factory

=head1 SYNOPSIS

  use DateTime;
  use DateTime::TimeZone;

  my $tz = DateTime::TimeZone->new( name => 'America/Chicago' );

  my $dt = DateTime->now();
  my $offset = $tz->offset_for_datetime($dt);

=head1 DESCRIPTION

This class is the base class for all time zone objects.  A time zone
is represented internally as a set of observances, each of which
describes the offset from GMT for a given time period.

Note that without the C<DateTime.pm> module, this module does not do
much.  It's primary interface is through a C<DateTime> object, and
most users will not need to directly use C<DateTime::TimeZone>
methods.

=head1 USAGE

This class has the following methods:

=head2 DateTime::TimeZone->new( name => $tz_name )
=6=

1|2|3|4|5| < PREV = PAGE 6 = NEXT > |7|8|9

UP TO ROOT | UP TO DIR | TO FIRST PAGE

Google
 


E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

0.00603199 wallclock secs ( 0.00 usr + 0.00 sys = 0.00 CPU)