Login  Register

DateParser::parseFormatted(string, format) - Parsing dd/mm/yyyy ?

Posted by dom on Sep 07, 2016; 9:15am
URL: http://quantlib.414.s1.nabble.com/DateParser-parseFormatted-string-format-Parsing-dd-mm-yyyy-tp17693.html

I'm trying to parse the below date using the DateParser::parseFormatted method but I'm not having any luck.


I can use this method but for a date string formatted dd/mm/yyyy it outputs the wrong year.

How do I correct this. 


d.year should  equal 2016 but instead I get 2020 because the only date the date parser seems to take is dd/mm/yy



#include <iostream>
#include <ql/quantlib.hpp>
#include <ql/utilities/dataparsers.hpp>


using namespace std;
using namespace QuantLib;

int main()
{

    Calendar cal = Australia();
   
    // convert a string to a date.

    string mydate = "05/08/2016";
    const Date d = DateParser::parseFormatted(mydate,"%d/%m/%y");


    cout << "The year of this date is: " <<  d.year() << endl;


}



------------------------------------------------------------------------------

_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users