RFC: DateTime::TemporalValue

2003-10-22 Thread Dan Kubb
Hi,

I recently worked on a project where I had to keep track of data
that changed over time.  I needed to keep a history of the
changes, as well as allow values to be specified for future
time periods.

For example, a value could be set, and it would go into
effect starting now.  A second value could be set that
goes into effect in 2 weeks, and expires 2 weeks after
that.. after which time, the original value goes back
into effect.

Much of what I did I borrowed from Martin Fowler's ideas on the
pattern Temporal Property.  I found this approach came in
handy when I had to manage permissions that would change at
some point in the future.

After solving this problem a few times, I decided to compile it
into a CPAN module and get some feedback from the perl DateTime
list before releasing it.  I placed the module on my website
at the following location:

  http://www.onautopilot.com/oss

Here's a small snippet from my POD to give you and idea
what the interface looks like.  (The POD has a more in-depth
explanation of the main methods):

-

=head1 NAME

DateTime::TemporalValue - Represent any value that changes over time

=head1 SYNOPSIS

  use DateTime::TemporalValue;

  $tv = DateTime::TemporalValue-new;
  $tv = DateTime::TemporalValue-new($value);

  $tv-set($value);
  $tv-set($value, $dt);
  $tv-set($value, $dt = $dt-clone-add(months = 1));
  $tv-set($value, $dt_span);
  $tv-set($value, $dt_span_set);

  $tv-set($tv_other);
  
  $value = $tv-get;
  $value = $tv-get($dt);
  $value = $tv-get($dt-clone-add(months = 1));
  $value = $tv-get($dt-clone-subtract(months = 1));

  @temporal_values = $tv-temporal_values;

  #NOTE: the variables named above, prefixed with $dt, represent
  #objects created by DateTime::* modules:

  #  $dt  = DateTime
  #  $dt_span = DateTime::Span
  #  $dt_span_set = DateTime::SpanSet

-

I'm certainly open to suggestions, or criticism on the code or
interface.  I'm not even sure this belongs under the DateTime
namespace, but I figured this was the best place to start asking.

Thanks,

Dan Kubb
Autopilot Marketing Inc.



Re: Chinese Calendar Question (fwd)

2003-10-22 Thread Daisuke Maki

Absolutely.  I've suggested DateTime::Util for helpers before.  Astro::* makes sense for 'generic' astronomical calculations.  DateTime specific stuff should inhabit another namespace.
Okay, that makes more sense to me. How about:

  DateTime::Util::Calc
  DateTime::Util::Astro::Sun
  DateTime::Util::Astro::Moon
  DateTime::Util::Astro::Common
  DateTime::Util::Astro::Location
::Calc would contain things that are used for calculation, such as 
polynomial(). ::Sun will have solar longitude related stuff. ::Moon will 
have lunar longitude and new moon related calculations. ::Location is a 
simple class to encapsulate location on earth. ::Common will have things 
like nutation() and ephemeris_correction().

--d



[RFC] DateTime::Bundle::Minimal and DateTime::Bundle::Basic

2003-10-22 Thread Rick Measham
I just installed Bundle::DateTime on my Darwin machine ... I hadn't 
looked through the docs beforehand :)

Can I suggest two other bundles that I'm willing to maintain (they 
shouldn't need much alteration anyway. Not like the full bundle!)

Bundle::DateTime::Minimal is the minimum needed to install and use DateTime.pm

Bundle::DateTime::Basic contains the above, plus the extra modules 
required for Sets and Spans as well as the main Format modules

Maybe we could also look at Bundle::DateTime::Formatters to 
quick-install all the formatters and Bundle::DateTime::Events to 
quick-install all events and DateTime::Bundle::Calendars to install 
all the calendars. That's more work though ...



package Bundle::DateTime::Minimal;
Class::Factory::Util 1.3 - prereq's of DateTime
Params::Validate 0.52
Test::More 0
Time::Local 1.04
Class::Singleton 1.03 - prereq of DT::TimeZone
DateTime::Locale 0.03 - needed by DateTime
DateTime::TimeZone 0.25 - needed by DateTime
DateTime
package Bundle::DateTime::Basic;
Bundle::DateTime::Minimal;
DateTime::Set
DateTime::Format::Strptime -- needed by DT::F::Builder
DateTime::Format::Builder -- prereq of several other formats


Re: RFC: DateTime::TemporalValue

2003-10-22 Thread Flavio S. Glock
Dan Kubb wrote:
 
 I recently worked on a project where I had to keep track of data
 that changed over time.  I needed to keep a history of the
 changes, as well as allow values to be specified for future
 time periods.


DateTime::TemporalValue
082:  #Class::Multimethods could really clean this up, but it doesn't
work
083:  #under mod_perl yet, so I can't use it.
  
How about (untested):

  my $spanset = DT::SpanSet-empty_set-union( @_ );

from the docs:
 Set operations may be performed not only with 
 DateTime::SpanSet objects, but also with DateTime,
 DateTime::Set and DateTime::Span objects.

- Flavio S. Glock


Re: [RFC] DateTime::Bundle::Minimal and DateTime::Bundle::Basic

2003-10-22 Thread Eugene van der Pijll
Rick Measham schreef:
 I just installed Bundle::DateTime on my Darwin machine ... I hadn't 
 looked through the docs beforehand :)
 
 Can I suggest two other bundles that I'm willing to maintain (they 
 shouldn't need much alteration anyway. Not like the full bundle!)
 
 Bundle::DateTime::Minimal is the minimum needed to install and use 
 DateTime.pm
 
 Bundle::DateTime::Basic contains the above, plus the extra modules 
 required for Sets and Spans as well as the main Format modules

I would prefer just 1 more bundle, Bundle::DateTime, containing the
mimimum needed for DateTime.pm, and a few selected other modules that
don't introduce new prereq's:

DT prereq's:
Class::Factory::Util 1.3 - prereq's of DateTime
Params::Validate 0.52
Test::More 0
Time::Local 1.04
Class::Singleton 1.03 - prereq of DT::TimeZone
DateTime::Locale 0.03 - needed by DateTime
DateTime::TimeZone 0.25 - needed by DateTime
DateTime

your choices for basic:
DateTime::Set
DateTime::Format::Strptime -- needed by DT::F::Builder
DateTime::Format::Builder -- prereq of several other formats

my additions:
DateTime::Format::HTTP
DateTime::Format::ISO8601
DateTime::Format::Mail

 Maybe we could also look at Bundle::DateTime::Formatters to 
 quick-install all the formatters and Bundle::DateTime::Events to 
 quick-install all events and DateTime::Bundle::Calendars to install 
 all the calendars. That's more work though ...

I can't imagine anyone else but a kalendrophile installing all
calendars, or all events, and kalendrophiles can just install
Bundle::DateTime::Complete.

(I created Bundle::DateTime for myself, to have a simple method of
getting all DT modules; I don't think it's the best way to install
DateTime.pm, so I wouldn't mind renaming it to B::DT::Complete. With the
name as it is, a query for DateTime in the CPAN.pm shell will return
both DateTime.pm and Bundle/DateTime.pm, which is not good.)

Eugene


Re: [RFC] DateTime::Bundle::Minimal and DateTime::Bundle::Basic

2003-10-22 Thread Eugene van der Pijll
Dave Rolsky schreef:
 On Wed, 22 Oct 2003, Eugene van der Pijll wrote:
 
  DT prereq's:
  Class::Factory::Util 1.3 - prereq's of DateTime
  Params::Validate 0.52
  Test::More 0
  Time::Local 1.04
  Class::Singleton 1.03 - prereq of DT::TimeZone
  DateTime::Locale 0.03 - needed by DateTime
  DateTime::TimeZone 0.25 - needed by DateTime
  DateTime
 
 I don't get how this is useful.  If you use CPAN or CPANPLUS to install
 DateTime, it will tell you that you need these prereqs anyway.

The first few versions of Bundle::DateTime left out those prereqs.
As a result, the bundle was difficult to install for the first time:
I can't remember exactly what happened, but DateTime couldn't be
installed first time round because of its prereqs; the prereqs were
installed; then CPAN first tried to install all other
modules in Bundle::DateTime before installing DateTime itself, and each
installation failed of course...

The best solution seemed to be to include the prereqs in the Bundle.

Eugene


Re: [RFC] DateTime::Bundle::Minimal and DateTime::Bundle::Basic

2003-10-22 Thread rickmeasham
 
 
 
 
 Dave Rolsky schreef: 
  DateTime, it will tell you that you need these 
prereqs anyway. 
 
Eugene van der Pijll [EMAIL PROTECTED] wrote: 
 The first few versions of Bundle::DateTime left out 
those prereqs. 
 As a result, the bundle was difficult to install for the 
first time: 
 
A good point Dave, so there's really no need for 
Bundle::DateTime::Minimal, as you get the same thing 
by just installing DateTime with CPAN. 
 
So then we're left with the other bundle, which Eugene 
has suggested calling Bundle::DateTime, and moving 
the existing bundle to Bundle::DateTime::Complete. 
 
That sounds like a good idea, however I'm not sure 
about including DT::F::Mail and DT::F::HTTP. They 
seem to be fairly specific-task oriented modules. 
 
I admit that they're probably common tasks, but if I 
wanted a quick way to get up and going with 
DateTime, but it was for DBI, I'd be annoyed that I 
was getting net-related modules. 
 
I'm open to including them, just a little disinclined. 
 
Cheers! 
Rick 
 
P.S. Eugene: as you point out, you need to include all 
prerequisites in the bundle. It also seems that the 
order is of the utmost importance. I had to install the 
current bundle at least four times before it got 
everything installed. I wondered if that could be 
because it installs the modules in the order in the file 
rather than downloading them all and checking 
prereq's first. On the other hand I seem to recall 
CPAN.pm didn't fully install before it went on to the 
next one.. maybe I have an old CPAN. 
 
Cheers more! 
Rick 


Re: [RFC] DateTime::Bundle::Minimal and DateTime::Bundle::Basic

2003-10-22 Thread Iain Truskett

Also, regarding DTF::HTTP suitability, it has a requirement of
HTTP::Date which is part of LWP. This probably counts against it for
bundling (though most people using bundles probably have LWP already).


cheers,
-- 
Iain.  http://eh.org/~koschei/


pgp0.pgp
Description: PGP signature


[RFC] Astro related modules

2003-10-22 Thread Daisuke Maki
I've now re-organized the astronomical calculation portions of the
chinese calendar modules into the following. This should be nicer to the
namespace. Please let me know if they look ok:

   http://www.wafu.ne.jp/~daisuke/DateTime-Util-Calc-0.01.tar.gz
   http://www.wafu.ne.jp/~daisuke/DateTime-Util-Astro-0.01.tar.gz
   http://www.wafu.ne.jp/~daisuke/DateTime-Event-Lunar-0.01.tar.gz

I also plan to create Astro::Event::SolarTerm, which will allow me to
partition things nicely within my planned DT::C::Chinese and
DT::C::Japanese.


--d