I've observed that DateTime does an awful lot of work during object construction that might not be necessary for most use. So I decided to see if I could make it lazier. You can see the work so far here:
http://github.com/schwern/DateTime

I've succeeded in making it load the TZ object and call _calc_utc_rd() on demand. The next hurdle is to eliminate the call to _calc_local_rd().

The weirdness is this. _calc_local_rd() sets $self->{local_rd_days} and $self->{local_rd_secs}. But those are set in the constructor just a few lines before! What's up with that? My read of it is that new() sets $self->{local_rd_days} from the parameters. Then it calculates $self->{utc_rd_days} from $self->{local_rd_days}. Then it recalculates $self->{local_rd_days} from $self->{utc_rd_days}.

Replacing the redundant call to $self->_calc_local_rd with just
$self->_calc_local_components works fine.

Adding to the confusion, _calc_utc_rd() uses $self->{local_rd_days} to set $self->{utc_rd_days} (and seconds, for simplicity let's assume the for the remainder). But _calc_local_rd() does the inverse, it uses $self->{utc_rd_days} to calculate $self->{local_rd_secs}. What's the story there?


--
Reality is that which, when you stop believing in it, doesn't go away.
    -- Phillip K. Dick

Reply via email to