[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Exporting dates in JS



PureBytes Links

Trading Reference Links

Hello,

Unfortunatelly JScript does not provide a nice way
to format strings like printf() in C/C++.

But you can write a function to format dates:

function FormatDate( d )
{
year = d.getFullYear();
month = d.getMonth() + 1;
day = d.getDate();

yearstr = String( year );
monthstr = ( month <= 9 ? "0" : "" ) + String( month );
daystr = ( day <= 9 ? "0" : "" ) + String( day );

return yearstr + monthstr + daystr;
}

and then use it here:
f.WriteLine( oStock.Ticker + "," +
FormatDate( oDate ) + "," +
FormatFloat( oQuote.Open ) + "," +
....



Best regards,
Tomasz Janeczko
===============
AmiBroker - the comprehensive share manager.
http://www.amibroker.com


----- Original Message -----
From: <jmp23834@xxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Wednesday, September 26, 2001 7:59 PM
Subject: [amibroker] Exporting dates in JS


> I am modifying the export.js to export all symbols in the data file
> for import into another system. It all seems to work fine with the
> exception of the date field. Can anyone explain how to modify the
> following code to always write YYYYMMDD. Example 20010901 instead of
> 200191
>
>
>
> f.WriteLine( oStock.Ticker + "," +
> oDate.getFullYear() + (oDate.getMonth()+1) + oDate.getDate
> () + "," +
> FormatFloat( oQuote.Open ) + "," +
> FormatFloat( oQuote.High ) + "," +
> FormatFloat( oQuote.Low ) + "," +
> FormatFloat( oQuote.Close ) + "," +
> Math.round( oQuote.Volume ) );
>
>
> John Pyle
>
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>