Simple examples of Date input/output in QuantLib

Following a discussion on the QuantLib users mailing list, here is a quick and very short program illustrating input and output of Date objects in QuantLib:

/**
   Copyright (C) 2010 Bojan Nikolic <bojan@bnikolic.co.uk>

   This program is distributed in the hope that it will be useful, but WITHOUT
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   FOR A PARTICULAR PURPOSE.

   Illustrations for input/output of QuantLib dates
*/

#include <iostream>
#include <sstream>

#include "ql/time/date.hpp"
#include "ql/utilities/dataparsers.hpp"

int main(int, char* [])
{
  /// Create a fixed date and print it
  QuantLib::Date d1(1, QuantLib::January, 2010);
  std::cout<<d1<<std::endl;

  /// Create date based on today and print
  QuantLib::Date today=QuantLib::Date::todaysDate();
  std::cout<<today<<std::endl;

  /// Print today in other formats:
  // Erm, short format
  std::cout<<QuantLib::io::short_date(today)<<std::endl;
  // This is in fact the default format
  std::cout<<QuantLib::io::long_date(today)<<std::endl;
  // ISO date format
  std::cout<<QuantLib::io::iso_date(today)<<std::endl;

  // Store ISO date format in a string stream
  std::ostringstream so;
  so<<QuantLib::io::iso_date(today);

  // Load it back in and print to check it was loaded fine
  QuantLib::Date newtoday=QuantLib::DateParser::parseISO(so.str());
  std::cout<<newtoday<<std::endl;

}