Question to the Leap function in the Date class

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Question to the Leap function in the Date class

Alexander_Lotter
Hello all,
 
I've got an exception using the Date class Leap function. I've checked the code and found out that the function is limited to the range 1900..2200. The implementation of the leap function is quite simple. Is there a performance reason to implement it like this? If it is possible I would like to extend this function.
 
Cheers
 
Alexander

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Question to the Leap function in the Date class

Ferdinando M. Ametrano-3
Hi Alexander

> I've got an exception using the Date class Leap function. I've checked the
> code and found out that the function is limited to the range 1900..2200. The
> implementation of the leap function is quite simple. Is there a performance
> reason to implement it like this? If it is possible I would like to extend
> this function.

I suggest you to just replace the current implementation with

#include <boost/date_time/gregorian/gregorian.hpp>
[...]
namespace QuantLib {
[...]
   bool Date::isLeap(Year y) {

       return boost::gregorian::gregorian_calendar::is_leap_year(y);
   }
[...]
}


I will commit this change unless objections are raised

ciao -- Nando

PS any volunteer for QuantLib::Date boostification, i.e. usage of boost::gregorian in the implementation of QuantLib::Date ?

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Question to the Leap function in the Date class

Luigi Ballabio
On Wed, 2009-10-21 at 11:50 +0200, Ferdinando Ametrano wrote:

> I suggest you to just replace the current implementation with
>
> #include <boost/date_time/gregorian/gregorian.hpp>
> [...]
> namespace QuantLib {
> [...]
>    bool Date::isLeap(Year y) {
>        return boost::gregorian::gregorian_calendar::is_leap_year(y);
>    }
> [...]
> }
>
> I will commit this change unless objections are raised

Ok, but wait until after we branch for release.

Luigi


--

The doctrine of human equality reposes on this: that there is no man
really clever who has not found that he is stupid.
-- Gilbert K. Chesterson



------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Question to the Leap function in the Date class

Luigi Ballabio
In reply to this post by Ferdinando M. Ametrano-3
On Wed, 2009-10-21 at 11:50 +0200, Ferdinando Ametrano wrote:

> I suggest you to just replace the current implementation with
>
> #include <boost/date_time/gregorian/gregorian.hpp>
> [...]
>    bool Date::isLeap(Year y) {
>        return boost::gregorian::gregorian_calendar::is_leap_year(y);
>    }
> [...]
>
> I will commit this change unless objections are raised

Nando,
        with this change, one need to link the binary Boost.Date library with
QuantLib (whereas before this, the library only needed the Boost
headers.)

I might be fine with this if we used Boost.Date to implement most of our
Date class, but I wouldn't introduce the dependency just for checking
leap years beyond 2200...

Luigi



--

I hate quotations.
-- Ralph Waldo Emerson



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Question to the Leap function in the Date class

Ferdinando M. Ametrano-3
>        with this change, one need to link the binary Boost.Date library with
> QuantLib (whereas before this, the library only needed the Boost
> headers.)
>
> I might be fine with this if we used Boost.Date to implement most of our
> Date class, but I wouldn't introduce the dependency just for checking
> leap years beyond 2200...

I agree. I didn't notice the (auto-)linking.
Actually I jumped to this modification in the hope to trigger further
boostification, but this is another issue and would require a stronger
determination

ciao -- Nando

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Question to the Leap function in the Date class

Nicolai Lassesen
> I agree. I didn't notice the (auto-)linking.
> Actually I jumped to this modification in the hope to trigger further
> boostification, but this is another issue and would require a stronger
> determination

I would be happy to help boostify QL. How would you go about doing it? Use the
Boost date class and give up Quantlib date?

Br,
Nicolai


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev