RE: DateTime::Event::Sunset problems

2003-09-25 Thread Hill, Ronald
Hi Matt,

 
 
[snipped]
 
 If not, at least make sure that the module clearly states the 
 UTC behavior.
 
 Matt
 

It does, from the POD

See DateTime::Set.

=head2 ($sunrise, $sunset) = $sunrise_object-($dt);

Internal method.

Returns two DateTime objects sunrise and sunset.
Please note that the time zone for these objects
is set to UTC. So don't forget to set your timezone!!

=head1 AUTHOR

Ron Hill


Re: DateTime::Event::Sunset problems

2003-09-24 Thread Flavio S. Glock
Steven J. Weinberger wrote:
 
 I'm trying to use DateTime::Event::Sunset in my DateTime::Calendar::Hebrew module, 
 but I'm having a problem. Below is my test code. The
 results from the code are:
 
 2003-09-24T10:42:00
 2003-09-24T22:48:00
 
 Sunrise wasn't at 10:42 and the sun will set well before 22:48. Is there something 
 I'm doing wrong?

I think these results are in UTC time.

- Flavio S. Glock


Re: DateTime::Event::Sunset problems

2003-09-24 Thread Dave Rolsky
On Wed, 24 Sep 2003, Flavio S. Glock wrote:

 Steven J. Weinberger wrote:
 
  I'm trying to use DateTime::Event::Sunset in my DateTime::Calendar::Hebrew module, 
  but I'm having a problem. Below is my test code. The
  results from the code are:
 
  2003-09-24T10:42:00
  2003-09-24T22:48:00
 
  Sunrise wasn't at 10:42 and the sun will set well before 22:48. Is there something 
  I'm doing wrong?

 I think these results are in UTC time.

Hmm, this should probably be changed so that the returned object has the
same time_zone as was passed to next().  I think this change would go in
DT::E::Sunrise.


-dave

/*===
House Absolute Consulting
www.houseabsolute.com
===*/


Re: DateTime::Event::Sunset problems

2003-09-24 Thread Flavio S. Glock
Dave Rolsky wrote:
 
 On Wed, 24 Sep 2003, Flavio S. Glock wrote:
 
  Steven J. Weinberger wrote:
  
   Sunrise wasn't at 10:42 and the sun will set well before 22:48. Is there 
   something I'm doing wrong?
 
  I think these results are in UTC time.
 
 Hmm, this should probably be changed so that the returned object has the
 same time_zone as was passed to next().  I think this change would go in
 DT::E::Sunrise.

You can use (untested):

  $sunset = DateTime::Event::Sunrise( %param )-set_time_zone(
$my_time_zone );

- Flavio S. Glock


Re: DateTime::Event::Sunset problems

2003-09-24 Thread Flavio S. Glock
   Steven J. Weinberger wrote:
   
Sunrise wasn't at 10:42 and the sun will set well before 22:48. Is there 
something I'm doing wrong?
  
   I think these results are in UTC time.
 
  Hmm, this should probably be changed so that the returned object has the
  same time_zone as was passed to next().  I think this change would go in
  DT::E::Sunrise.
 
 You can use (untested):
 
   $sunset = DateTime::Event::Sunrise( %param )-set_time_zone(
 $my_time_zone );

Doesn't work. I'm looking for the bug...

- Flavio S. Glock


Re: DateTime::Event::Sunset problems

2003-09-24 Thread Flavio S. Glock
Flavio S. Glock wrote:
 
Steven J. Weinberger wrote:

 Sunrise wasn't at 10:42 and the sun will set well before 22:48. Is there 
 something I'm doing wrong?
   
I think these results are in UTC time.
  
   Hmm, this should probably be changed so that the returned object has the
   same time_zone as was passed to next().  I think this change would go in
   DT::E::Sunrise.
 
  You can use (untested):
 
$sunset = DateTime::Event::Sunrise( %param )-set_time_zone(
  $my_time_zone );
 
 Doesn't work. I'm looking for the bug...

Fixed in CVS. It was a bug in DateTime::Set

- Flavio S. Glock


Re: DateTime::Event::Sunset problems

2003-09-24 Thread Dave Rolsky
On Wed, 24 Sep 2003, Flavio S. Glock wrote:

 This is what it looks like (tested!):

 ---
 #!/usr/local/bin/perl
 use DateTime;
 use DateTime::Set 0.1202;
 use DateTime::Event::Sunrise;

 my $dt = DateTime-new(
  year   = 2003,
  month  = 9,
  day= 24,
  time_zone = 'America/New_York',
 );

 my $sunrise = DateTime::Event::Sunrise-sunrise (
  longitude ='-73.59',
  latitude ='40.38',
  altitude = '-0.833',
  iteration = '1'
 )-set_time_zone( 'America/New_York' );

I really don't think we should make users do this if we can avoid.

 my $rise = $sunrise-next($dt);
 print $rise-datetime,  , $rise-time_zone_long_name, \n;

This should probably set the returned datetime to the same timezone as the
given datetime.


-dave

/*===
House Absolute Consulting
www.houseabsolute.com
===*/


Re: DateTime::Event::Sunset problems

2003-09-24 Thread Flavio S. Glock
Dave Rolsky wrote:
 
 On Wed, 24 Sep 2003, Flavio S. Glock wrote:
 
  my $sunrise = DateTime::Event::Sunrise-sunrise (
   longitude ='-73.59',
   latitude ='40.38',
   altitude = '-0.833',
   iteration = '1'
  )-set_time_zone( 'America/New_York' );
 
 I really don't think we should make users do this if we can avoid.
 
  my $rise = $sunrise-next($dt);
  print $rise-datetime,  , $rise-time_zone_long_name, \n;
 
 This should probably set the returned datetime to the same timezone as the
 given datetime.

How about this?

 sub _following_sunrise {
[ ... initialize ...]
my $tz = $dt-time_zone;
my $loc = $dt-locale;
[ ... some calculations ... ]
$tmp_rise-set_time_zone( $tz );   # unless $tz-is_floating ???
$tmp_rise-set_locale( $loc );
return $tmp_rise;
 }


- Flavio S. Glock


Re: DateTime::Event::Sunset problems

2003-09-24 Thread Flavio S. Glock
Dave Rolsky wrote:
 
 On Wed, 24 Sep 2003, Flavio S. Glock wrote:
 
   sub _following_sunrise {
  [ ... initialize ...]
  my $tz = $dt-time_zone;
  my $loc = $dt-locale;
  [ ... some calculations ... ]
  $tmp_rise-set_time_zone( $tz );   # unless $tz-is_floating ???
  $tmp_rise-set_locale( $loc );
  return $tmp_rise;
   }
 
 It's probably ok to set the time zone even if the given DT is in the
 floating time zone.

No, converting from UTC to floating would give the same unexpected
results.

How about adding ( localtime - gmtime ) before converting to floating?

- Flavio S. Glock