Creates a DateTime::Set object that contains random events.
The events occur at an average of once a day, forever.
You may give density parameters to change this. The density is specified as a duration:
If span parameters are given, then the set is bounded:
Note that the random values are generated on demand, which means that the values may not be repeateable between iterations. See the new_cached constructor for a solution.
A DateTime::Set object does not allow for the repetition of values. Each element in a set is different.
Creates a DateTime::Set object representing the set of random events.
If a set is created with new_cached, then once an value is seen, it is cached, such that all sequences extracted from the set are equal.
Cached sets are slower and take more memory than sets generated with the plain new constructor. They should only be used if you need unbounded sets that would be accessed many times and when you need repeatable results.
This method accepts the same parameters as the new method.
Returns a random DateTime object.
If a span is specified, then the returned value will be within the span:
Returns a random DateTime::Duration object.
If a duration is specified, then the returned value will be within the duration:
o _random_init o _random_duration
These methods are called by DateTime::Set to generate the random datetime sequence.
You can override these methods in order to make different random distributions. The default random distribution is uniform.
The internals API is not stable.
o Make a random datetime o Make a random datetime, today
This is another way to do it. It takes care of length of day problems, such as DST changes and leap seconds:
o Make a random sunday
o Make a random friday-13th
use DateTime::Event::Random; use DateTime::Event::Recurrence; my $day_13 = DateTime::Event::Recurrence->monthly( days => 13 ); my $friday = DateTime::Event::Recurrence->weekly( days => 6 ); my $friday_13 = $friday->intersection( $day_13 ); my $dt = $friday_13->next( DateTime::Event::Random->datetime ); print "datetime " . $dt->datetime . "\n"; print "weekday " . $dt->day_of_week . "\n"; print "month day " . $dt->day . "\n";
Flavio Soibelmann Glock email@example.com
Copyright (c) 2004 Flavio Soibelmann Glock. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
firstname.lastname@example.org mailing list
DateTime Web page at http://datetime.perl.org/
DateTime::Set - sets
|perl v5.20.3||DATETIME::EVENT::RANDOM (3)||2004-03-17|