Login  Register

todaysDate in localtime ?

Posted by Dirk Eddelbuettel on Apr 18, 2009; 2:22am
URL: http://quantlib.414.s1.nabble.com/todaysDate-in-localtime-tp12737.html


In ql/time/date.cpp we have

    Date Date::todaysDate() {
        std::time_t t;

        if (std::time(&t) == std::time_t(-1)) // -1 means time() didn't work
            return Date();
        std::tm *gt = std::gmtime(&t);
        return Date(Day(gt->tm_mday),
                    Month(gt->tm_mon+1),
                    Year(gt->tm_year+1900));
    }

I'd like to be able to use std::localtime instead as I just got bitten when I
asked for todaysDate() here in UTC+6 and got tomorrow's date instead.  

Shall I add that with a binary toggle to turn localtime on/off with a default
to off, i.e. existing behaviour?

Other suggestions?  I'd also love a Date() constructor from "yyyymmdd" or
(long) yyyymmdd as just relying on the Applix/Excel number is a tad
restrictive.

Dirk

--
Three out of two people have difficulties with fractions.

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev