From 09bece8f8e8c4a0dae9bb6b49ecedc94f9091f1a Mon Sep 17 00:00:00 2001 From: Frank Dillon Date: Mon, 1 May 2006 16:42:06 +0000 Subject: [PATCH] Added getMonthsInInterval method analogous to getDaysInInterval method --- lib/WebGUI/Session/DateTime.pm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/WebGUI/Session/DateTime.pm b/lib/WebGUI/Session/DateTime.pm index 45100e1b6..8b71cacb4 100644 --- a/lib/WebGUI/Session/DateTime.pm +++ b/lib/WebGUI/Session/DateTime.pm @@ -463,6 +463,29 @@ sub getMonthName { } } +#------------------------------------------------------------------- +=head2 getMonthsInInterval ( start, end ) + +Returns the number of months between two epoch dates. + +=head3 start + +An epoch date. + +=head3 end + +An epoch date. + +=cut + +sub getMonthsInInterval { + my $self = shift; + my $start = DateTime->from_epoch( epoch =>shift); + my $end = DateTime->from_epoch( epoch =>shift); + my $duration = $end - $start; + return $duration->delta_months; +} + #------------------------------------------------------------------- =head2 getSecondsFromEpoch ( epoch )