DateTime-Lite

 view release on metacpan or  search on metacpan

lib/DateTime/Lite/TimeZone.pm  view on Meta::CPAN

        return;
    }
    # Should not be a reference, but a plain string
    elsif( ref( $data ) )
    {
        die( "\$cldr->_decode_sql_array( \$data )" );
    }

    my $j = $JSON_CLASS->new->relaxed;
    local $@;
    my $decoded = eval
    {
        $j->decode( $data );
    };
    if( $@ )
    {
        warn( "Warning only: error attempting to decode $JSON_CLASS array: $@" );
        $decoded = [];
    }
    return( $decoded );
}

# _decode_sql_arrays() takes an hash reference, or an array of hash reference,
# and decode the array fields of those tuples
sub _decode_sql_arrays
{
    my $self = shift( @_ );
    die( "\$cldr->_decode_sql_arrays( \$array_ref_of_array_fields, \$data )" ) if( @_ != 2 );
    my( $where, $ref ) = @_;
    if( ref( $where ) ne 'ARRAY' )

lib/DateTime/Lite/TimeZone.pm  view on Meta::CPAN

    my $j = $JSON_CLASS->new->relaxed;
    local $@;
    if( ref( $ref ) eq 'HASH' )
    {
        foreach my $field ( @$where )
        {
            if( exists( $ref->{ $field } ) &&
                defined( $ref->{ $field } ) &&
                length( $ref->{ $field } ) )
            {
                my $decoded = eval
                {
                    $j->decode( $ref->{ $field } );
                };
                if( $@ )
                {
                    warn( "Warning only: error attempting to decode $JSON_CLASS array in field \"${field}\" for value '", $ref->{ $field }, "': $@" );
                    $ref->{ $field } = [];
                }
                else
                {
                    $ref->{ $field } = $decoded;
                }
            }
        }
    }
    elsif( Scalar::Util::reftype( $ref ) eq 'ARRAY' )
    {
        for( my $i = 0; $i < scalar( @$ref ); $i++ )
        {
            if( ref( $ref->[$i] ) ne 'HASH' )
            {

scripts/build_tz_database.pl  view on Meta::CPAN

                              $local
                    ) );
    }
    else
    {
        _message( 2, sprintf( "Unexpected response: HTTP %d %s",
                              $resp->code,
                              $resp->message
                     ) );
    }
    my $out = $resp->decoded_content_utf8;
    return( $out ) if( defined( $out ) && length( $out ) );
    return;
}

sub _fetch_url
{
    my $url = shift( @_ );
    require HTTP::Promise;
    my $ua = HTTP::Promise->new(
        auto_switch_https       => 1,
        ext_vary                => 1,
        max_body_in_memory_size => 102400,
        max_redirect            => 3,
        timeout                 => 10,
        use_promise             => 0,
        ( $opts->{http_debug} ? ( debug => $opts->{http_debug} ) : () ),
    ) || die( "Error instantiating a HTTP::Promise object: ", HTTP::Promise->error );
    my $resp = $ua->get( $url ) ||
        die( "Error fetching remote URL $url: ", $ua->error );
    my $out = $resp->decoded_content_utf8;
    return( $out ) if( defined( $out ) && length( $out ) );
    return;
}

my %_tool_cache;
sub _has_tool
{
    my $t = shift( @_ );
    return( $_tool_cache{ $t } ) if( exists( $_tool_cache{ $t } ) );
    my $bin = which( $t );



( run in 0.667 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )