Skip Menu |

This queue is for tickets about the Class-Date CPAN distribution.

Report information
The Basics
Id: 40867
Status: resolved
Priority: 0/
Queue: Class-Date

People
Owner: yanick+cpan [...] babyl.dyndns.org
Requestors: admiral.grinder [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in:
  • 1.1.7
  • 1.1.8
  • 1.1.9
Fixed in: (no value)



Subject: TZ environmental variable getting deleted.
I read through the documents, so I'm not sure how this should be handled. In my case my program is expecting 'TZ' to be defined after I use the Class::Date module, but it is being deleted in Class::Date without a suitable value being stored in it. Here is a test script that shows the moment Class::Date is loaded the variable is cleared out. I tested with 1.1.5 and it doesn't remove the variable.
Subject: tz_env.pl
#!usr/bin/perl use strict; use warnings; # # Testing using 'use' # my %start_env; BEGIN { print "\nDump ENV =============================\n"; foreach( sort keys %ENV ) { print "$_: " . $ENV{$_} . "\n"; } %start_env = %ENV; } print "\nTest Start with Class::Date ==========\n"; use Class::Date; _env_compare( \%start_env, \%ENV ); # # Testing Using Require: # #my %start_env = %ENV; #print "\nDump ENV =============================\n"; #foreach( sort keys %ENV ) { print "$_: " . $ENV{$_} . "\n"; } #print "\nTest Start ENV =======================\n"; #_env_compare( \%start_env, \%ENV ); #print "\nTest Start with Require Class::Date ==========\n"; #require Class::Date; #_env_compare( \%start_env, \%ENV ); ###################################################################### sub _env_compare # # # ###################################################################### { my $env_one = shift; my $env_two = shift; my @env_one_keys = sort keys %$env_one; my @env_two_keys = sort keys %$env_two; my @different_list; my @added_list; my @removed_list; # Prime the loop my $current_one_key = shift @env_one_keys; my $current_two_key = shift @env_two_keys; while( $current_one_key && $current_two_key ) { # Check to see if the keys match if( $current_one_key eq $current_two_key ) { push(@different_list, $current_one_key) unless( $env_one->{$current_one_key} eq $env_two->{$current_two_key} ); # grab new keys and continue $current_one_key = shift @env_one_keys; $current_two_key = shift @env_two_keys; next; } # If the first key alphas before the second key, then it was removed # in the second hash if( $current_one_key lt $current_two_key ) { push(@removed_list, $current_one_key); # Grab new keys and continue $current_one_key = shift @env_one_keys; next; } # If the first key alphas after the second key, then the second # key was added to the list if( $current_one_key gt $current_two_key ) { push(@added_list, $current_two_key ); # Grab new keys and continue $current_two_key = shift @env_two_keys; next; } } # We have exausted our list at this point. # If there are keys in the first list then they have been removed in the second list # If there are keys in the second list then they have been added push(@removed_list, @env_one_keys) if scalar @env_one_keys; push(@added_list, @env_two_keys) if scalar @env_two_keys; # Output if( scalar @added_list ) { my $added_string = "Added in environment:\n"; foreach( @added_list ) { $added_string .= "ADDED $_: [" . $env_two->{$_} . "]\n"; } print $added_string; } if( scalar @different_list ) { my $change_string = "Changes in environment:\n"; foreach( @different_list ) { $change_string .= "CHANGE $_: [" . $env_one->{$_} . "] => [" . $env_two->{$_} . "]\n"; } print $change_string ; } if( scalar @removed_list ) { my $removed_string = "Removed from environment:\n"; foreach( @removed_list ) { $removed_string .= "REMOVED $_: [" . $env_one->{$_} . "]\n"; } print $removed_string ; } }
Hi, Thanks for the script, it is indeed useful. A short digging in the script turned out that Class::Date indeed delete the timezone when it is equal to the local timezone. I wrote the logic quite some time ago, so I don't really remember to every detail, but if it is still a problem I might take a look at it. What is your timezone that you use for testing? Balázs On Wed Nov 12 14:48:44 2008, admiral.grinder@gmail.com wrote: Show quoted text
> I read through the documents, so I'm not sure how this should be > handled. In my case my program is expecting 'TZ' to be defined after I > use the Class::Date module, but it is being deleted in Class::Date > without a suitable value being stored in it. Here is a test script that > shows the moment Class::Date is loaded the variable is cleared out. I > tested with 1.1.5 and it doesn't remove the variable.
Seems to work with latest version