Constructor validation of parameters

2003-07-29 Thread Dan Sully
0.13 2003-05-05

[ IMPROVEMENTS ]

- DateTime now does more validation of parameters given to
  constructors and to the set() method, so bogus values like a month of
  13 are a fatal error.

I'm not entirely sure I'd call this an improvement.

In 0.12 code, I'm able to do things like:

my $month = 12;

my $dt1 = DateTime-new('month' = $month, 'year' = 2002);

print join(' ', $dt1-ymd(), $dt1-hms()) . \n;



my $dt2 = DateTime-new('month' = $month + 1, 'year' = 2002, 'second' = -1);

print join(' ', $dt2-ymd(), $dt2-hms()) . \n;

To get the beginning and ending times of a month:

2002-12-01 00:00:00
2002-12-31 23:59:59

How would one do this with = 0.13 releases?

This seems like useful functionality to me.

-D
-- 
Indifference will certainly be the downfall of mankind, but who cares?


Re: Constructor validation of parameters

2003-07-29 Thread Eugene van der Pijll
Dan Sully schreef:
 To get the beginning and ending times of a month:
 
 2002-12-01 00:00:00
 2002-12-31 23:59:59
 
 How would one do this with = 0.13 releases?

TIMTOWTDI:

my $dt2 = DateTime-new( month = $month, year = 2002)
  -add( months = 1 )
  -truncate( to = 'month' )
  -subtract( seconds = 1 );

my $dt3 = DateTime-last_day_of_month( month = $month, year = 2002)
  -add( days = 1, seconds = -1 );

But note that the month of December does not end at 2002-12-31T23:59:59!
It doesn't even end at 2002-12-31T23:59:59.9, the last moment in
2002 that DateTime can represent. The ending time of 2002-12 is
2003-01-01T00:00:00.

Eugene


Re: Constructor validation of parameters

2003-07-29 Thread Dave Rolsky
On Tue, 29 Jul 2003, Dan Sully wrote:

 0.13 2003-05-05

 [ IMPROVEMENTS ]

 - DateTime now does more validation of parameters given to
   constructors and to the set() method, so bogus values like a month of
   13 are a fatal error.

 I'm not entirely sure I'd call this an improvement.

This has been beaten to death in the archives, but once again for the
record, it's going to stay like this.

 my $month = 12;

 my $dt1 = DateTime-new('month' = $month, 'year' = 2002);

 print join(' ', $dt1-ymd(), $dt1-hms()) . \n;

 

 my $dt2 = DateTime-new('month' = $month + 1, 'year' = 2002, 'second' = 
 -1);

 print join(' ', $dt2-ymd(), $dt2-hms()) . \n;

 To get the beginning and ending times of a month:

 2002-12-01 00:00:00
 2002-12-31 23:59:59

 How would one do this with = 0.13 releases?

 my $dt1 = DateTime-new( month = $month, year = 2002 );

 my $dt2 = $dt1-clone-add( months = 1 )-subtract( seconds = 1 );

There are several variations on the above that'd work.

 This seems like useful functionality to me.

No, it seems like a way to encourage people to write really weird code
that doesn't really demonstrate their _intent_.  The next person after you
to read the code you posted will be sitting there think second = -1,
WTF?.  If they read the code above, they'll think datetime math, ok.


-dave

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


Re: Constructor validation of parameters

2003-07-29 Thread Dan Sully
* Eugene van der Pijll [EMAIL PROTECTED] shaped the electrons to say...

 TIMTOWTDI:
 
 my $dt2 = DateTime-new( month = $month, year = 2002)
   -add( months = 1 )
   -truncate( to = 'month' )
   -subtract( seconds = 1 );
 
 my $dt3 = DateTime-last_day_of_month( month = $month, year = 2002)
   -add( days = 1, seconds = -1 );

Which yield 

2002-12-01 00:00:-01
2003-01-01 00:00:-01

respectivly. Not quite correct.

-D
-- 
It's the wrong trousers Gromit, and they've gone wrong!


Re: Constructor validation of parameters

2003-07-29 Thread Dave Rolsky
On Tue, 29 Jul 2003, Dan Sully wrote:

 * Dave Rolsky [EMAIL PROTECTED] shaped the electrons to say...

   my $dt1 = DateTime-new( month = $month, year = 2002 );
 
   my $dt2 = $dt1-clone-add( months = 1 )-subtract( seconds = 1 );
 
  There are several variations on the above that'd work.

 Which yet again yields: 2003-01-01 00:00:-01

 Sorry for not reading the archives. I have no problem using something else
 (this is new code anyways, and it seemed intuitive to me, if a bit wierd.)

 All I'm looking for now is something that works.

Well, obviously this is a bug in the DateTime code, as that's not what
_anyone_ would expect as a result, right?


-dave

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


Re: XSLoader ignoring version?

2003-07-29 Thread Joshua Hoblitt
 I've gotten this as a test failure from one of the automated CPAN tester
 boxes, also running Solaris.  It could just be an @INC problem, in that
 it's finding the wrong .so file first.

It shouldn't be loading a .so file at all.  Isn't DynaLoader aware of versioning?

-J

--


Re: Constructor validation of parameters

2003-07-29 Thread Dave Rolsky
On Tue, 29 Jul 2003, Dan Sully wrote:

 * Dave Rolsky [EMAIL PROTECTED] shaped the electrons to say...

  Well, obviously this is a bug in the DateTime code, as that's not what
  _anyone_ would expect as a result, right?

 Just checking to make sure that I'm not the only anyone here. =)

Ah, looks like a bug in the pure Perl version of the code.

I'll fix it and release a new version soon.


-dave

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


Re: Constructor validation of parameters

2003-07-29 Thread Dan Sully
* Eugene van der Pijll [EMAIL PROTECTED] shaped the electrons to say...

 This solution, OTOH, should work:
 
 my $dt3 = DateTime-last_day_of_month( month = $month, year = 2002)
   -add( days = 1 )
   -subtract( seconds = 1 );
 
 And it does. (DT version 0.1402, perl 5.8.0, linux)

It's broken with 0.1402 under Solaris 8 (SPARC).

Works fine on HP-UX 11.00 and 11i

-D
-- 
Have the appropriate amount of fun.


Re: Constructor validation of parameters

2003-07-29 Thread Dan Sully
* Dave Rolsky [EMAIL PROTECTED] shaped the electrons to say...

 _If_ it can't find finite() or isfinite() macros/functions, a piece that
 can be done in XS is done in Perl (_normalize_tai_seconds).  Are you
 running on Win32 or HPUX?  I know on both those platforms it ends up using
 the Perl version of that method.

It works on HPUX.

Broken on Solaris 8

-D
-- 
Dondi5 I must keep track of all this cheese


ANNOUNCE: DateTime 0.15

2003-07-29 Thread Dave Rolsky
0.15   2003-07-29

[ IMPROVEMENTS ]

- The utc_rd_values() method now returns nanoseconds in addition, Rata
Die days and minutes.  Based on a patch by Joshua Hoblitt.

- The from_object() method expects objects to return the same values
from their utc_rd_values() methods.  Based on a patch by Joshua Hoblitt.

[ BUG FIXES ]

- Fixed a bug in the pure Perl version of _normalize_tai_seconds that
caused very weird results from datetime math.  This version may be
used on platforms where the XS code compiles, so it can affect quite a
number of systems.  Reported by Dan Sully.



-dave

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


Re: ANNOUNCE: DateTime 0.15

2003-07-29 Thread Joshua Hoblitt
On Tue, 29 Jul 2003, Dave Rolsky wrote:

 0.15   2003-07-29

 [ IMPROVEMENTS ]

 - The utc_rd_values() method now returns nanoseconds in addition, Rata
 Die days and minutes.  Based on a patch by Joshua Hoblitt.

Minutes? :)

-J

--


Re: Constructor validation of parameters

2003-07-29 Thread Dan Sully
* Dave Rolsky [EMAIL PROTECTED] shaped the electrons to say...

  It's broken with 0.1402 under Solaris 8 (SPARC).
 
  Works fine on HP-UX 11.00 and 11i
 
 Try 0.15

Works great. Thanks for the fast response.

-D
-- 
faisal my life is collapsing to what will soon be NEGATIVE INTEGER degrees of 
separation.


[ANNOUNCE] DateTime::Calendar::Mayan 0.06

2003-07-29 Thread Joshua Hoblitt
Released to CPAN.

Available immediately from:

http://kolea.ifa.hawaii.edu/~jhoblitt/pm/DateTime-Calendar-Mayan-0.06.tar.gz

Changes since 0.05

- add nanosecond preservation
- fix undef being returned from utc_rd_values for rd_secs when not preserving from 
an object

-J

--


Python's 'DateTime'

2003-07-29 Thread Joshua Hoblitt
Date/Time type announcement
http://www.python.org/doc/2.3/whatsnew/node18.html#SECTION000181

'DateTime' Object
http://www.python.org/doc/2.3/lib/module-datetime.html

Gregorian Calendar from Calendrical Calculations that requires 'DateTime'
http://www.python.org/doc/2.3/lib/module-calendar.html

'Duration' Object
http://www.python.org/doc/2.3/lib/datetime-timedelta.html

'TimeZone' Object (complete with the EST timezone)
http://www.python.org/doc/2.3/lib/datetime-tzinfo.html

'Incomplete' Date/Time Object
http://www.python.org/doc/2.3/lib/datetime-date.html

'Strftime'
http://www.python.org/doc/2.3/lib/node208.html

-J

--


Re: Python's 'DateTime'

2003-07-29 Thread Joshua Hoblitt
 Date/Time type announcement
 http://www.python.org/doc/2.3/whatsnew/node18.html#SECTION000181

 'DateTime' Object
 http://www.python.org/doc/2.3/lib/module-datetime.html

 Gregorian Calendar from Calendrical Calculations that requires 'DateTime'
 http://www.python.org/doc/2.3/lib/module-calendar.html

 'Duration' Object
 http://www.python.org/doc/2.3/lib/datetime-timedelta.html

 'TimeZone' Object (complete with the EST timezone)
 http://www.python.org/doc/2.3/lib/datetime-tzinfo.html

make that

'Incomplete' Date/Time Objects
http://www.python.org/doc/2.3/lib/datetime-date.html
http://www.python.org/doc/2.3/lib/datetime-time.html


 'Strftime'
 http://www.python.org/doc/2.3/lib/node208.html

-J

--


Re: Python's 'DateTime'

2003-07-29 Thread Dave Rolsky
On Tue, 29 Jul 2003, Joshua Hoblitt wrote:

 'DateTime' Object
 http://www.python.org/doc/2.3/lib/module-datetime.html

No leap seconds.  Years 1 -  only! (why?!).  microsecond resolution.

 Gregorian Calendar from Calendrical Calculations that requires 'DateTime'
 http://www.python.org/doc/2.3/lib/module-calendar.html

Sort of Gregorian, also a grab bag of random stuff, like monthcalendar,
which returns a matrix representing a month's calendar.

Actually, that latter bit is kind of neat.  Wonder if we need it.

 'Duration' Object
 http://www.python.org/doc/2.3/lib/datetime-timedelta.html

No support for months in durations.  lame.

 'TimeZone' Object (complete with the EST timezone)
 http://www.python.org/doc/2.3/lib/datetime-tzinfo.html

Bleah.  This is just an interface.  There's no implementation included,
though last I looked somebody had implemented something that did the _most
recent_ rules, ignoring all historical changes.

 'Incomplete' Date/Time Object
 http://www.python.org/doc/2.3/lib/datetime-date.html

Sort of.

 'Strftime'
 http://www.python.org/doc/2.3/lib/node208.html



They suck, we rule.


-dave

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


Re: Python's 'DateTime'

2003-07-29 Thread Joshua Hoblitt
 They suck, we rule.

I forgot the 'for entertainment purposes only' disclaimer. :)

-J

--


Re: Python's 'DateTime'

2003-07-29 Thread Joshua Hoblitt
Just to be clear - I intended this to be humorous.  I was not truly equating that 
'stuff' to one true DateTime {TM}. :)

Cheers,

-J

--
On Tue, 29 Jul 2003, Joshua Hoblitt wrote:

  Date/Time type announcement
  http://www.python.org/doc/2.3/whatsnew/node18.html#SECTION000181
 
  'DateTime' Object
  http://www.python.org/doc/2.3/lib/module-datetime.html
 
  Gregorian Calendar from Calendrical Calculations that requires 'DateTime'
  http://www.python.org/doc/2.3/lib/module-calendar.html
 
  'Duration' Object
  http://www.python.org/doc/2.3/lib/datetime-timedelta.html
 
  'TimeZone' Object (complete with the EST timezone)
  http://www.python.org/doc/2.3/lib/datetime-tzinfo.html
 
 make that

 'Incomplete' Date/Time Objects
 http://www.python.org/doc/2.3/lib/datetime-date.html
 http://www.python.org/doc/2.3/lib/datetime-time.html

 
  'Strftime'
  http://www.python.org/doc/2.3/lib/node208.html

 -J

 --