Re: R: converting QuantLib date back to mm/dd/yyyy

Posted by Pavan Shah-2 on
URL: http://quantlib.414.s1.nabble.com/converting-QuantLib-date-back-to-mm-dd-yyyy-tp13961p13984.html

sorry Luigi, peter
but which header file do I need to have as my include directive?

thanks
pavan


On Wed, Jan 30, 2013 at 6:06 AM, Luigi Ballabio <[hidden email]> wrote:
or

outfile << io::short_date(d);

as Piter suggested earlier. Internally, it uses manipulators like you
did (and restores their status after it's done).

Luigi


On Wed, Jan 30, 2013 at 2:54 PM, Ballabio Gerardo
<[hidden email]> wrote:
> Da: Oleg Goldshmidt [mailto:[hidden email]]
>> It's not a QuantLib-specific question - it looks like basic C/C++ ?
>
> Since when is Date part of standard C/C++?
>
> Also, snprintf is the C way to print things. Sure you can use it in C++, too, but if you'd like to do things "in the C++ style", you should use streams:
>
>   std::ofstream outfile("...");
>   outfile << d.month() << "/" << d.dayOfMonth() << "/" << d.year();
>
> This won't give you trailing zeros, i.e., 1 January 2013 will show up as 1/1/2013 rather than 01/01/2013. If you need the zeros, you can use manipulators. Something like this:
>
>   #include <iomanip>
>   outfile << std::setwidth(2) << std::setfill('0') << d.month() << "/" << std::setwidth(2) << std::setfill('0') << d.dayOfMonth() << "/" << d.year();
>
> but check the syntax because I don't use these very often and I'm not sure this is correct. I'm not sure either that the second setfill is required (I am quite sure the setwidth is).
>
> Gerardo
>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head></head>
> <body>
> <div style="font-family:Calibri;font-size:10px">
> Banca Profilo S.p.A.
> Corso Italia, 49 - 20122 Milano - Tel. 02 58408.1, Fax 02 5831 6057
> Capitale Sociale Euro 136.794.106,00 i.v.
> Iscrizione al Registro Imprese di Milano, C.F. e P.IVA 09108700155 - [hidden email]
> Iscritta all’Albo delle Banche e dei Gruppi bancari
> Aderente al Fondo Interbancario di Tutela dei depositi
> Aderente al Conciliatore Bancario Finanziario e all’Arbitro Bancario Finanziario
> Appartenente al Gruppo bancario Banca Profilo e soggetta all’attività di direzione e coordinamento di Arepo BP S.p.A.
>
>
> DISCLAIMER:
> The information transmitted may contain confidential and/or privileged material.
> Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon,
> this information by persons or entities other than the intended recipient is prohibited.
> If you received this in error, please contact the sender and delete the material from any computer.
> </div>
> </body>
> </html>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_jan
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_jan
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users