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.
