Rick Measham wrote:
>
> @PUBLICHOLIDAYS = [
> { month=>1, day=>26 }, #Australia Day
> { month=>4, day=>25 }, #ANZAC Day
> { month=>12, day=>25 }, #Christmas Day
> { DateTime::Event::Easter->new( day=> -2) }, #Good
Friday
> { DateTime::Event::Easter->new( day=> 0) }
This code resembles a standard DateTime::Event module
implementation.
http://datetime.perl.org/developer/event.html
I think 95% of the work could be done by reusing one
of these modules:
DateTime::Set "from_recurrence" method
- to start from scratch
DateTime::Event::Recurrence
DateT
Dave Rolsky wrote:
> One possibility is to simply return undef for
> methods that might cause
> infinite loops when we don't know for certain they
> won't.
>
> Calculating whether or not this can happen is
> probably possible in some
> cases (defined start & end), and in others we can
> offe
> > On Wed, 6 Apr 2005 [EMAIL PROTECTED] wrote:
> >
> > > Yes - if the set has up to 200 elements (that's
> > > an internal hard limit),
[...]
> >
> > Why the internal hard limit? If people want to
> > use up all their memory,
> > that's their problem. A warning in the docs is
> > good, but
> On Wed, 6 Apr 2005 [EMAIL PROTECTED] wrote:
>
> > Yes - if the set has up to 200 elements (that's
> > an internal hard limit),
> > DateTime::Format::ICal should do the right thing:
>
> Why the internal hard limit? If people want to use
> up all their memory,
> that's their problem. A warni
> > I am trying to write a converter for crontab
entries into another format
> > (iCal). Unfortunately I need a limited
recurrence set as the output
> > module does not allow infinite sets. I thought
that using the %parms or
> > the %set_parms I would be able to limit the Set
produced using from_
> On 3/15/05 11:54 PM, Cees Hek wrote:
> > I sent a bug report and patch to this list back
in January [1]
> > regarding DateTime::Format::Pg, and I never
received a response. Just
> > wondering if this slipped through the cracks. In
the meantime, I have
> > logged this as a bug in rt.cpan.org [2]
> On Mon, 28 Feb 2005 [EMAIL PROTECTED] wrote:
>
> >> On Mon, 28 Feb 2005, John Siracusa wrote:
> >>
> >>> Can't you just nuke the giant DT:TZ ref before
> > freezing and have it
> >>> auto-re-vivify when first used after it's thawed?
> > IOW, save the TZ string
> >>> ("floating", "local", "Americ
> On Mon, 28 Feb 2005, John Siracusa wrote:
>
> > Can't you just nuke the giant DT:TZ ref before
freezing and have it
> > auto-re-vivify when first used after it's thawed?
IOW, save the TZ string
> > ("floating", "local", "America/Chicago") and then
re-grab a ref to the
> > DT::TZ singleton as ne
On Sat, 26 Feb 2005, Dave Rolsky wrote:
> - Uses much newer (August, 2004) data from ICU.
> I just noticed that this causes a DT::Set test to
> fail, because the pt_BR locale data changed.
> Flavio, I checked in a fix for this (to use en_US,
> which hasn't ever changed).
I sent DateTime::Se
Flavio said:
> WKST has two parts: the algorithm
> specification, and the day name.
>
I'm reading rfc2445 again.
I'm wrong - WKST is just a normal weekday.
There is one algorithm for year recurrences, and
another one for monthly recurrences.
- Flavio S. Glock
Dave Rolsky said:
> DT already supports both of these, doesn't it?
>
DateTime.pm only supports the ISO standard.
It is missing iCal's optional "week start day"
specification ("WKST").
WKST has two parts: the algorithm
specification, and the day name.
There are two different algorithms for
There is some math in DateTime::Event::Recurrence
that could be moved into a DateTime::Util::* module.
Most of this math is related to "week of year" and
"week of month".
I'd like to know if anyone can see some use for these
subroutines outside of DateTime::Event::Recurrence:
as_number( $datetim
New "developer version" modules in CPAN:
DateTime::Event::Recurrence - 0.15_02
- all parameters are validated (and it runs a bit
slower)
- POD was updated
- some bugfixes
DateTime::Set - 0.19_01
- optimizations:
start_set; end_set; contains($dt); intersects($dt)
- POD was updated
-
David Nicol wrote:
>
> looks like you want to test definedness rather
> than truth:
>
>defined($count = $set->count) or die "can't count";
>
> in one line.
>
Thanks! I added this example to the docs:
-
=item * count
Returns a count of C objects in the set.
my $n = $set->count( span
DT::Set count() currently returns "undef" on error,
and "0" for empty sets.
Should it return "zero-but-true" (0e0) for empty sets?
Such that you could write:
$count = $set->count or die "can't count";
instead of:
$count = $set->count;
die "can't count" unless defined $count;
- Flavio S. Gl
Yitzchak wrote:
>
> YMMV, but I find something like this more clear:
>
> @args = sort { ($a < 0) <=> ($b < 0) || $a <=> $b }
@args;
>
> (literally, sort first by positive/negative, then
by value).
>
Very nice - thanks!
Actually, I'm planning to rewrite this part of the
program, because it ca
Daisuke wrote:
>
> +sub _sort_positive_first
> +{
> +my @sorted = sort { $a <=> $b } @_;
> +# put positive values first
> +my @ret = grep { $_ >= 0 } @sorted;
> +push @ret, $_ for grep { $_ < 0 } @sorted;
> +
> +return @ret;
> +}
I rewrote the sort:
@args = sort {
$a
I once wrote a module to do this (long before DateTime).
Note that in the second case the result is exact.
Date::Tie is _very_ careful to round errors correctly.
use Date::Tie;
tie my %date, 'Date::Tie', frac_hour => 2.67;
print $date{frac_hour}, "\n";
print $date{hour}, ":",
$d
"DateTime::Format::Duration" may be what you need for
this specific problem. Can you show us a few lines of
your template?
- Flavio S. Glock
> I am running into a snag with using
DateTime::Duration and TT. I think
> it's an important issue and am surprised that there
is no info on this
> on Goo
Rick:
- You can't use map to count elements.
From the docs:
The callback subroutine may be called later
in the program, due to lazy evaluation. So
don't count on subroutine side-effects. For
example, a "print" inside the subroutine may
happen later than you expect.
- The reason w
Rick wrote:
>
> It would be helpful to note which methods are
> affected by the limit. e.g., map and grep.
> Since only iterate handles large/unbounded
> sets, maybe it shouldn't be marked "deprecated".
Only count() and as_list() are limited, as it is
documented.
map() and grep() are no
Ron Hill wrote:
>
> Actually I run the reports on the first of the
month for the previous
> month so I had to do this
> my $month = DateTime->today->truncate( to =>
'month' )->subtract( months =>1);
>
> >
> >$dt_span = DateTime::Span->from_datetimes(
> > start => $month->cl
> On Wed, 1 Dec 2004, John Siracusa wrote:
>
> > On Wed, 1 Dec 2004 12:21:11, Dave Rolsky
<[EMAIL PROTECTED]> wrote:
> >> http://perladvent.org/2004/1st/
> >
> >> From the article:
> >
> ># what year are we in?
> >my $year = DateTime->now->year;
> >
> > Another victim of the failure to (at
Ron Hill wrote:
>
> Do you think we can add to the docs to state these
> are "getter" methods? something like
>
> * min / max
[...]
> These methods are "getter" methods meaning you
> can't use it to set/change the value.
How about:
These methods return a copy of the actual
boundary v
Ron Hill said:
>
> I would like to be able to change
> the max and min values that are in a DateTime Set
> object. Here is a test script that demonstrates
> my problem.
>
[...]
>
> #generate a monthly set object that has min set to
the first day of the month
> # max set to last day of the month
> There's some example code in the FAQ which fails
> its tests, but presumably once passed. It's for
> spansets.
I think the example was meant to be:
# Make the set representing the work start times:
# Mon-Fri morning 9:00, and afternoon 13:00
my $start = DateTime::Event::Recurrence->
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
> diffe
> On Fri, 2 Jul 2004, Rick Measham wrote:
> > I'd also like to see a class based (rather
> > than object based) ability
> > to set the local time zone, probably through
> > the import:
> >
> > use DateTime local => 'Australia/Melbourne';
> >
> > Then all constructors would use that as the
> > lo
Tim Müller-Seydlitz said:
> there is bug in DateTime::Set that was
> revealed with an application using
> DateTime::Events::Cron.
> I would like to know whether I can expect an
> update of the module or whether I rather set
> up a work-around.
This "bug" was stated as:
If you ask for the next cr
Matt Sisk wrote:
> So why have the guard clause in the simple
> examples presented in the DateTime::Set docs?
Because I was not sure those examples would work
without the test :)
The examples were written before the code was
finished.
I guess I'll update the docs.
So this is my TODO list for
This works fine, actually:
use DateTime::Set;
print $DateTime::Set::VERSION, "\n";
$months = DateTime::Set->from_recurrence(
recurrence => sub {
return $_[0]->truncate(
to => 'month' )->add( months => 1 )
},
);
print $months->next( DateTime->n
Tim müller-Seydlitz wrote:
> In my opinion this should give 18:15:00 GMT/BST
> whatever the time_zone of now is. (As long as it
> is less than or equal to a +/- 12 hours shift)
This is discussed here:
http://datetime.perl.org/developer/event.html
> Could you please explain this to me?
It look
Dave Rolsky wrote:
> But DateTime.pm already has a set_time_zone()
> method, and people are likely going to be exposed
> to that before DateTime::Set, so I think
> keeping them consistent is more important.
how about to emit a warning and "usage"
if a DateTime::Set method is used in an
unexpected
Dave Rolsky wrote:
> OTOH, set_time_zone() doesn't seem like it should
> be creating a new set.
How about removing "set" from the method name -
$br_set = $set->with_time_zone('America/Sao Paulo');
$br_set = $br_set->with_locale('pt_BR');
The mutators, if any, could be:
$set->change_time_zon
> On Fri, 18 Jun 2004, Matt Sisk wrote:
> > 2) are datetimes from other time zones
> > converted to the DT::S default
> > time zone before computations are performed?
>
> I think Flavio uses the DateTime.pm object
> internals, for which he will be
> duly punished when I change them.
"No inte
Matt Sisk wrote:
> what is the midpoint of a span?
With DateTime::Span:
$mid_point =
$span->start->add_duration(
seconds => $span->duration->seconds / 2
);
With DateTime:
$mid_point =
$start->add_duration(
seconds => $end->subtract_datetime_absolute(
DateTime::Set
0.15 2004-03-28
[ ENHANCEMENTS from version 0.14 ]
- Both "Makefile.PL" and "Build.PL" are provided.
- New methods:
DateTime::SpanSet::current
DateTime::Spanset::closest
DateTime::Set::map / grep
DateTime::SpanSet::map / grep
DateTime::SpanSet::intersected_spans
Da
"t/20infinite.t" fails, and I don't think
there is an easy way to fix this.
How about wrapping these tests in a
"TODO" block, under Windows?
--- DateTime-0.20, Perl 5.6.1 ---
not ok 12 - infinity - infinity = nan (days)
# Failed test (t/20infinite.t at line 61)
# got: '0'
# expec
* Changes for DateTime::Set
- Recurrence functions can be used to generate
_bounded_ sets.
See: t/16bounded_recurrence.t
Note: all modules that create their own
recurrences must now be able to respond to
DateTime::Infinite::Future and
DateTime::Infinite::Past parameters. The easies
This version has a few changes in the API.
Comments are welcome - module name, methods,
optimizations ...
http://www.geocities.com/fglock/DateTime-Event-
Spreadsheet-0.00_07.pl
- Flavio S. Glock
NAME
DateTime::Event::Spreadsheet - A collection of named DateTime events
SYNOPSIS
use
Eric Belpaire wrote:
>
> I'd like to install DateTime on Windows.
> Windows 2000 with Perl 5.6
>
> >From previous messages on this list, I understand
> >that some of you have already done this with Perl
> >5.8.x.
>
> Can someone provide me with guidance?
> How should I go about it?
This i
Andrew Pimlott wrote:
>
> Dave Rolsky wrote:
> > Actually, this doesn't encourage it and we
> > _still_ need iterate() for sure. We can have
> > set_map() only be used to create a new set, and
> > iterate() only be used to alter the current set
> > in place.
>
> To clarify, do you mean that iter
> Flavio S. Glock wrote:
> > * iterate
[...]
> > # assign a timezone to the spanset
> > $set->iterate( \&callback );
[...]
> >
> > If the callback returns undef, the span is
> > removed from the set.
Andrew Pimlott wrote:
[...]
> One, it's too easy for someone who only skims
Dave Rolsky wrote:
> Why not just offer an explicit to_set method for
> DateTime::SpanSet, that "does the right thing"
> (whatever that may be ;)
>
# 'the right thing'
my $start_set = $spanset->to_set;
# but then:
my $end_set =
$spanset->clone->iterate(
sub {
t_set1 );
print "\n\nDateTime::SpanSet\n\n";
print Dumper( $spanset );
---
The "recurrence" is the part that says:
'param' => [
sub { ...
sub { ...
sub { ...
],
See also:
http://search.cpan.org/~fglock/Set-Inf
> On Mon, 1 Mar 2004, Flavio S. Glock wrote:
>
> > How about this API (almost the same as
> > Date::Set's):
> >
> >my $start_set =
> >$spanset->iterate(
> >sub { $_[0]->start }
> >);
> >my $end_set =
> >$spanset->iterate(
> >sub { $_[0]->end
DateTime.pm 0.20 works in Windows NT, with
this patch:
15a16,17
> eval
> {
26a29
> };
35a39,40
> require DateTimePP
> unless defined &DateTime::_ymd2rd;
There are a few errors left:
t\20infiniteNOK 12# Failed test
(t\20infinite.t at line 61)
#
You can also do that with a single
DateTime::Incomplete object!
---
use strict;
use DateTime::Incomplete;
# blackout is at 10 o'clock
my $blackout =
DateTime::Incomplete->new(
hour => 22,
);
print "blackout time is ",
$blackout->datetime, "\n";
test( DateTime->now );
test( D
This bug report is a documented behaviour, but when I
was
investigating it, I found that subtracting
DT::Infinite objects
gives a strange result ("nan" in diferent places):
---
use DateTime::Infinite;
my $future = DateTime::Infinite::Future->new;
my $past = DateTime::Infinite::Past->new;
my $du
Another way to do it:
---
use strict;
use DateTime::Incomplete;
use DateTime::SpanSet;
my $blackout_start =
DateTime::Incomplete->new(
hour => 22,
minute => 0,
second => 0,
);
my $blackout_end =
DateTime::Incomplete->new(
hour => 23,
minute
--- sample program ---
use strict;
use DateTime::Event::Recurrence;
my $blackout_start =
DateTime::Event::Recurrence->daily(
hours => 22
);
my $blackout_end =
DateTime::Event::Recurrence->daily(
hours => 23
);
my $blackout =
DateTime::SpanSet->from_sets
There was some talk about this style a while ago,
and I would like to know what you think about this
syntax:
$set->union( $set2 );
it would be the same as:
$set = $set->union( $set2 );
but if you write it this way:
$set3 = $set->union( $set2 );
it doesn't mutate $set.
In other words, i
0.0103 2003-11-06
- start, end, to_span
- requires DateTime::Set 0.1401
Now you can do this:
$dti = DateTime::Incomplete->new( year => 2004 );
print "Starts in ",
$dti->start->datetime,
", ends in ",
$dti->end->datetime;
# Starts in 2004-01-01T00:00:00, ends in
20
How about:
$dti = DateTime::Incomplete->new( year => 2003 );
$dt1 = $dti->start; # 2003-01-01T00:00:00
$dt2 = $dti->end;# 2003-12-31T23:59:59
$span = $dti->span;
If there is no 'year', then start,end,span return
undef.
- Flavio S. Glock
> DateTime-Set 0.13
oops - it is 0.14
- Flavio S. Glock
DateTime-Set 0.13
bugfix: duration() should never return an
error message
- Flavio S. Glock
DateTime::Incomplete 0.01 is on CPAN
=head1 NAME
DateTime::Incomplete - An incomplete datetime, like
January 5
=head1 SYNOPSIS
my $dti = DateTime::Incomplete->new( year => 2003 );
# 2003-xx-xx
$dti->set( month => 12 );
# 2003-12-xx
$dt = $dti->to_datetime( base => DateTime->n
A shorter one:
---
my $from_rd =
DateTime->new(year => 1)->add(days => $rd_days);
---
A shorter class for Dave's program:
---
sub DateTime::RataDie::utc_rd_values { @{$_[0]} }
---
- Flavio S. Glock
DateTime::Set in cvs:
=item * iterate
Experimental method - subject to change.
This method apply a callback subroutine to all
elements of a set.
sub callback {
$_[0]->add( hours => 1 );
}
# offset $set elements by one hour
$set->iterate( \&callback );
# $set2 ele
Ronald Hill said:
>
> This will not preserve the class information,
> I tried Flavio's suggestion of
>
> my $tmp_dt1 = $dt->
> clone->
> set_time_zone( 'UTC' )->
> truncate( to => 'day' );
>
> instead of creating a new object however,
> I was always getting the incorre
I've done some diagrams, in order to check if
you agree with the semantics of these SpanSet
functions.
Some of these operations can be interpreted
in more than one way. If you think something
should be different, please let me know.
This is the notation used:
[aaa] - a closed spanset or span
> For example, the Wednesday of the current week is:
>
> my $today = DateTime->today;
>
> my $wednesday = $today - ( $today->day_of_week - 3 );
How about adding a 'week' parameter
to the 'truncate' method:
print DateTime->today
->truncate( to => 'week' )
->a
# Some examples for the FAQ
use DateTime::Event::Recurrence;
{
# 6.2: How do I check whether two dates and times lie
more or less than a given time interval apart?
my $dt1 = DateTime->new(year => 2002, month => 3,
day => 1);
my $dt2 = DateTime->new(year => 2002, month => 2,
day => 11);
$inter
I've got a report that Perl 5.9.0 stringifies
infinity and minus infinity with extra spaces,
like this:
" -Inf"
"Inf"
Is this a bug?
- Flavio S. Glock
> David Dyck wrote:
> in Set-Infinite-0.51 make test fails with perl,
> v5.9.0 built for i686-linux
> Flavio, is there already a method to determine
> the number of elements in a DateTime::Set?
>
> If not, I can currently make it as_list, and then
> get the length of the list, but it would be
> cleaner to have a method to do this.
What would be a name for this method?
There is no accessor ye
> DateTime->now( time_zone => 'local' );
It already works this way.
now() accepts:
locale
language
time_zone
Although this is not well documented.
- Flavio S. Glock
There is no DateTime::Locale::en_US in the CPAN
version. Is this a bug or I'm using it the wrong way?
- Flavio S. Glock
How about DateTime::Incomplete::Agnostic ?
You can convert it to Christian, Jewish, ... :)
- Flavio S. Glock
Dave Rolsky wrote:
>
> > DateTime::Incomplete::Agnostic - base class
> >
> > to_datetime
> > next / previous / etc.
> >
> > Another approach: the API would remember what
methods were
Joshua Hoblit wrote:
>
> > I'm trying to figure out how to allow
> > for incomplete year/month/day, year/week/day,
> > or year/day in DT::I.
> >
> > One way is to have a separate implementation
> > for each case:
>
> Is it possible express all of these as:
>
> If year is known:
>
> a DateTime +
I'm trying to figure out how to allow
for incomplete year/month/day, year/week/day,
or year/day in DT::I.
One way is to have a separate implementation
for each case:
DateTime::Incomplete
year / set_year
month / set_month
day / set_day
DateTime::Incomplete::YearWeekDay
week_year / set
Flavio S. Glock wrote
> There are a few missing bits:
>
> no has_month() - but has('month') is ok.
Now month() and has_month() are ok!
- Flavio S. Glock
- DateTime::Incomplete 0.00_03
Most functionality discussed in the DT::Complex
thread is implemented.
Mayan calendar datetimes should work, but it
has not been tested!
There are a few missing bits:
no has_month() - but has('month') is ok.
no fields()
no base_class()
there is no def
Eugene van der Pijll wrote:
>
> I would prefer if this:
>
> DateTime::Incomplete->new( year => 2003 );
>
> would create the incomplete dt
> 2003-xx-xxTxx:xx:xx; that is: the
> defaults of the DT::I constructor should be
> 'unknown'. That simplifies the creation of DT::I
> objects, and is t
The idea is: you call DT::LS from _DateTime_
Makefile.PL, and it generates C source code
that compiles with DT XS - it makes a C
include file - it is not a DT::LS XS library.
Dave Rolsky wrote:
>
> On Sun, 13 Jul 2003 [EMAIL PROTECTED] wrote:
>
> > It would be easy to change the
It would be easy to change the Perl code generator
into a C code generator. Then you could use
DT::LeapSecond at compile time, if they are using
XS, or at runtime, if they are using pure Perl.
- Flavio S. Glock
> Maybe there is something fundamental we can boil
> out of DT::E::R. hmmm...
I found out a way to get a duration-set out
of DT::E::R:
$dt_set = new DT::E::R( %param ); # datetimes
$dur_set = $dt_set - $dt; # durations!
It will not work under the current implementation,
but it can be done.
Dave:
I think it would be good to integrate
DT::Event::ICal,
DT::Format::ICal and
DT::Set::ICal in a single distribution.
This would make it easier to manage dependencies
and version checking between them, and we would
have a single, comprehensive test suite.
It would make it easier to in
That's all correct, and the implementation is
cut-and-paste DT::Set/DT::E::Recurrence code.
Dave wants to know _why_ we want this!
- Flavio S. Glock
> > Of course, this will not allow for
duration-recurrences.
>
> Aren't recurrences basically a set of durations at
fixed intervals? Could durat
> I assume that this only works for things created by
> ICal...
Right now it works for:
- any _bounded_ set, spanset, span, datetime
- any unbounded DT:E:ICal set
- union()s of those objects
- union()s followed by complement()s
Other unbounded set operations are not
representable with ICal, but
Ok, I've got DateTime::Set::ICal implemented under
DT:E:Recurrence. It's an 'internal use' class for
recurrences that can be represented using ICal
statements.
DT::Format::ICal can now format pretty complex sets
as ICal statements:
example from t/04recurrence.t:
..
my $exclude = $union2->union(
We could add an optional parameter to DateTime::Set
recurrence constructor:
$r = new DT::Set {
recurrence => sub { next_day($_) },
as_ical_string => "RRULE:FREQ=DAILY",
}
DT::E:Cron, DT::E:Recurrence, DT::E:ICal can use
this to setup a valid ICal string.
In some case
They are documented in CVS version.
> Is there some reason the parse/format routines for
recurrences in DT::F::ICal
> are not documented in the POD? Is there anyhing
wrong with these methods or is
> the lack of documentation an oversight?
> [EMAIL PROTECTED]:
> > Why not:
> >
> > $dur1 = new DT::Dur( days => 2 );
> > $dur2 = new DT::Dur( months => 1 );
> > $dur3 = $dur1 - $dur2;
> > $dur3->add( days => 3 );
> >
> > If you add $dur3 to a date, it would add 2 days and
> > subtract a month, then add 3 days again.
>
> I love that thi
Why not:
$dur1 = new DT::Dur( days => 2 );
$dur2 = new DT::Dur( months => 1 );
$dur3 = $dur1 - $dur2;
$dur3->add( days => 3 );
If you add $dur3 to a date, it would add 2 days and
subtract a month, then add 3 days again.
This is not too difficult to implement.
Is it too confusing?
- Flavio S. G
Here is my ICS file parser prototype,
using Text::vFile.
I think it can't go into DT::Format::ICal,
because it would cause a circular dependency
through Text::vFile. Is this a problem?
I implemented just enough for it to
understand the ics files from
http://www.apple.com/ical/library/
- Flavio
Jay Lawrence _is_ working on the .ics file parser:
package Text::vFile::Base;
...
=item load_singleDate
Loads a date creating a DateTime::Format::ICal
object. Thanks Dave!
=cut
...
=item load_singleDuration
Loads a data duration using DateTime::Format::ICal.
=cut
(from Text:
Thanks Eugene.
I'll try to rephrase this, because it
would be good to have it in the FAQ.
If somebody can explain it better, or
more correctly, please help me!
What's up with GMT, TAI, UTC, and UT1?
Before 1972, the "international time" reference
was GMT. In GMT, all days have the same number
http://hpiers.obspm.fr/eop-pc/earthor/utc/leapsecond.
html
"... Since the system was introduced in 1972, "
The table starts in 1972. Before that, GMT was
in use - not UT1!
- Flavio S. Glock
Joshua Hoblitt said:
> There must be a way to express the same semantic
> meaning with fewer lines of code
A slightly smaller version - specify days and hours
in the same constructor.
- Flavio S. Glock
---
#!/usr/local/bin/perl -w
use strict;
use DateTime;
use DateTime::Span;
use DateTime::Span
In DateTime::Duration:
sub new():
...
unless ( grep { $self->{$_} } qw( months days ...
{
$self->{sign} = 0;
}
and then:
sub is_positive { $_[0]->{sign} == 1 ? 1 : 0 }
which makes a zero-duration be "not positive",
because sign is zero.
- Flavio S. Glock
> Please could you tell me what the dates for Rosh
> Hashana are for the
> next 3 years?
>
> Thanks
> B Hyman
Start with:
use Date::Passover;
($month, $day ) = roshhashanah( 2003 );
- Flavio S. Glock
Bruce Van Allen wrote:
>
> 1. This is one reason some us have argued for the
capability of caching
> recurrence sets (which Flavio implemented!).
I'm not done yet - but I've got it started.
> Brad suggests another way
> to accomplish this, which would have application in
some uses:
> > In any
> >
> > Just out of curiosity, how come DateTime has + and
> - overloaded, but
> > DateTime::Duration doesn't?
>
> Because I didn't need it :)
> I only implemented multiplication.
> Put it on my TODO list...
I just checked it - it _does_ overload + and - !
- Flavio S. Glock
>
> Just out of curiosity, how come DateTime has + and
- overloaded, but
> DateTime::Duration doesn't?
Because I didn't need it :)
I only implemented multiplication.
Put it on my TODO list...
- Flavio S. Glock
May I import Date::Leapsecond into
"modules/DateTime.pm/lib/DateTime/Leapsecond.pm"?
I could then make the changes in DateTime to use it.
- Flavio S. Glock
Dave Rolsky wrote:
> I thought about this a
> bit more and realized I don't really like it,
because it special cases one
> number, zero. But comparing it to other numbers
wouldn't make sense.
Ok. Maybe a $dt_dur->is_zero() method instead?
- Flavio S.
Glock
.. or maybe "DateTime::Event::Base"
Dave wrote:
> I think the problem is that this (AFAICT) forces
> all events to be dealt with as sets internally,
> which may not be what many module authors want
> to do.
No, that's not the idea.
What I propose is a common API.
If the module author wants to
I noticed DateTime::Duration <=> is not
checking the 'reverse' flag.
Also, it would be useful to be able to
compare a duration to zero, in order to check if
it is negative, positive or null.
I could do that, just tell me if it is ok.
- Flavio S. Glock
1 - 100 of 169 matches
Mail list logo