Jonas B.Nielsen wrote: > > Well I really the general idea of a DateTime::Calc::Namespace, but I > think the case of DateTime::Pregnancy (Date::Pregnancy now) really > shows the difficulty of generalizing such a thing. > > In calculating a date a of birth I currently have knowledge of 3 > different methods. They all differ at bit but all calculate from the > first day of the last period and from the you can somewhat deduct the > conception date. > > So the conception date indicating the start of the pregnancy is > something, which is not known when initializing the DateTime object > calling the constructor. This could of just be documented, but I think > it conflicts a bit with the idea of a start and an end, also since the > main functionality in Date::Pregnancy is calculating the end date. > > So a DateTime::Calculate::Pregnancy could be used to measure the length > of a pregnancy for comparison etc. I am not saying that it would be > impossible to implement DateTime::Calc::Pregnancy based in > Date::Pregnancy, but the world of pregnancy calculation is a bit > upside-down compared to normal calendar usage if you get my point. >
This could be implemented as a DateTime::Event::Spreadsheet "bidirectional calculator" - from the docs: # - given a birthday, calculate the age; # - given an age, calculate the birthday. use DateTime::Event::Spreadsheet; # setup the Spreadsheet [ ... some initialization hidden ... ] # test the Spreadsheet $dtes->set( birthday => DateTime->new( year=>1964, month=>12, day=>14 ) ); my @age = $dtes->get( 'age' )->deltas; print "Age is @age\n"; $dtes->set( age => DateTime::Duration->new( years => 20 ) ); my $birthday = $dtes->get( 'birthday' )->datetime; print "Birthday was $birthday\n"; For example, you could add 'conception' and 'last period' cells to this spreadsheet. (DateTime::Event::Spreadsheet is in DateTime CVS) - Flavio S. Glock