Any progress on this?

             -ben

On Wed, Apr 30, 2003 at 12:30:01PM +1000, Rick Measham wrote:
> > On Tue, 29 Apr 2003, Joshua Hoblitt wrote:
> >> I was thinking of something similar to the 'constant' syntax that
> >> quietly creates namespaces.
> >> 
> >> use DateTime::TimeZone::Alias HST => 'US/Hawaii';
> >> .
> >> .
> >> 
> >> my $dt = DateTime->new( year => 2003, time_zone => 'HST' );
> >> 
> >> That seems like the most tidy way of doing things.  Of course I won't
> >> have time to work on this for several days so I may not get a vote. :)
> 
> On 30/4/03 11:42 AM, Dave Rolsky at [EMAIL PROTECTED] spake thus:
> > The problem is that parsers need more than this, since they can't just set
> > a static list of aliases in advance.  They have to be able to have EST be
> > interpreted in multiple ways.
> 
> I'm looking at setting a range of 'standard' aliases and allowing options:
> 
> use DateTime::TimeZone::Alias EST => 'Australia/Melbourne';
> my $dt = DateTime->now( time_zone => 'EST' );
> print $dt->offset;
> # Returns 36000
> 
> use DateTime::TimeZone::Alias EST => 'America/New_York';
> my $dt = DateTime->now( time_zone => 'EST' );
> print $dt->offset;
> # Returns -14400 even though EST is standard time and NY is in Daylight time
> because EST is mapped to 'America/New_York'.
> 
> use DateTime::TimeZone::Alias;
> my $dt = DateTime->now( time_zone => 'EST' );
> print $dt->offset;
> # Returns -14400 (assumes most people will be thinking about USA).
> 
> Apart from the standard zones I'd include other ones like using 'AEST/V' and
> 'AEST/M' for Australian Eastern Standard/Summer time in Victoria.
> 
> 'AEST' would default to Sydney (as would 'AEST/NSW' and 'AEST/S') simply
> because most people would be expecting Sydney (most of the world seem to
> think it's our capital city!)
> 
> use DateTime::TimeZone::Alias 'I have a lovely bunch of coconuts' =>
> 'America/Hawaii';
> my $dt = DateTime->now( time_zone => 'I have a lovely bunch of coconuts' );
> # Obviously the result is Hawaii, I just added this to demonstrate the
> ability to use anything as an alias.
> 
> I'd also include the A-Z zones (And might even include Adelaide and other
> 1/2 hour zones as 'X.5'!)
> 
> Hmmm .. as I type this I wonder if we should also allow aliasing to custom
> zones:
> my %NO_DST = (
>     dst_start_month => 0,
>     dst_start_day   => 0,
>     dst_start_hour  => 0,
>     dst_end_month   => 0,
>     dst_end_day     => 0,
>     dst_end_hour    => 0,
>     offset          => 36000,
>     dst_offset      => 36000,
> );
> use DateTime::TimeZone::Alias EST => \%NO_DST;
> my $dt = DateTime->now( time_zone => 'EST' );
> print $dt->offset;
> # Returns 36000
> 
> For setting things 'permanently' maybe we should read
> $ENV{DATETIME_TZ_ALIAS} and ~/.DATETIME_TZ_ALIAS
> 
> Developers hooking onto aliases really should either:
> 1. Provide their own aliases
> 2. Provide their own data file
> 3. Not mind if things get screwy
> 4. Get run over by a large bus.
> 
> 
> Cheers!
> Rick

Reply via email to