Re: Finding my localtime

2015-02-04 Thread SSC_perl
On Feb 4, 2015, at 5:20 PM, Shawn H Corey wrote:
> 
> I seems to me if you change locales, you would necessarily change
> timezones too. But I haven't done much playing around with locales. :(

Me neither, but I'm learning more than I thought I would! ;)  Looking 
at the locales for just the US:
en_US
en_US.ISO8859-1
en_US.ISO8859-15
en_US.US-ASCII
en_US.UTF-8

there isn't anything that differentiates the timezone, so I don't think it 
does.  But it might for countries that have only one timezone.

Frank

SurfShopCART
https://github.com/surfshopcart/surfshop


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Finding my localtime

2015-02-04 Thread SSC_perl
On Feb 4, 2015, at 4:30 PM, Shawn H Corey wrote:
> 
> Have you read `perldoc perllocale` especially the `setlocale` function?
> http://perldoc.perl.org/perllocale.html#The-setlocale-function

Actually, I did, but unless I read it incorrectly, it doesn't appear to 
have anything to do with timezones.  Did I miss it?

I can see where it will come in real handy with month names and days of 
the week for different locales, though.

Thanks,
Frank

SurfShopCART
https://github.com/surfshopcart/surfshop


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Finding my localtime

2015-02-04 Thread Shawn H Corey
On Wed, 4 Feb 2015 11:21:32 -0800
SSC_perl  wrote:

> I'm trying to break out a timestamp into it's appropriate fields,
> like so:
> 
> my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
> localtime($my_time);
> 
> but no matter if I use localtime or gmtime, $my_time gets analyzed as
> either in the server's timezone or in UTC.  I need to break apart the
> timestamp in $my_time without it being changed.  In other words, I'm
> trying to get $hour, $min, $sec, etc, in _my_ timezone, not the
> server's nor in UTC.

Have you read `perldoc perllocale` especially the `setlocale` function?
http://perldoc.perl.org/perllocale.html#The-setlocale-function


-- 
Don't stop where the ink does.
Shawn

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Finding my localtime

2015-02-04 Thread SSC_perl
On Feb 4, 2015, at 1:55 PM, $Bill wrote:
> 
> I had a similar situation where I'm in Pacific time and my server is in 
> Eastern time.
> 
> My solution was to just add this to my BEGIN { } :
>   $ENV{TZ} = 'PST8PDT';
> to force my time displays to Pacific time.

I didn't think about adding it to a BEGIN block.  I just added it to 
the get_date sub and it seems to work fine.  I just didn't know if it was a 
proper way to do that.  I'm using it to make sure that all orders added to the 
shopping cart are in the store owners timezone and not the server's, if it's 
different.

> I'm not sure what ( $main::global->{'config'}->{'timezone'}; ) gives you in 
> terms of a timezone.
> Is that the compiled in timezone when Perl was built ?  Or the dynamic 
> timezone determined
> at runtime from the system ?  Or ?

I'm using standard timezone names, e.g. America/Los_Angeles.  I've 
setup the configuration script with a drop down list of all timezone names and 
their offsets ("-8") which then populates the config file.  It's then pulled 
from there.

Thanks,
Frank

SurfShopCART
https://github.com/surfshopcart/surfshop


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Finding my localtime

2015-02-04 Thread SSC_perl
I'm trying to break out a timestamp into it's appropriate fields, like 
so:

my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = 
localtime($my_time);

but no matter if I use localtime or gmtime, $my_time gets analyzed as either in 
the server's timezone or in UTC.  I need to break apart the timestamp in 
$my_time without it being changed.  In other words, I'm trying to get $hour, 
$min, $sec, etc, in _my_ timezone, not the server's nor in UTC.

I finally got it to work using:

$ENV{'TZ'} = $main::global->{'config'}->{'timezone'};
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime();

but I read somewhere that this may cause problems depending on the platform (?) 
or something.  I can't find it again.  Is this solution O.K. to use, or is 
there a better way to do what I'm after?

I know that I can use DateTime for this, but I'm trying to see what I 
can do without it.

Thanks,
Frank

SurfShopCART
https://github.com/surfshopcart/surfshop
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/