Date and time calculations are quite slow so I am exploring ways to minimize the number of calculations performed. As an example:
msft = FinancialData["MSFT", "Jan 1, 2005"]
Timing[DateListPlot[msft]]
{0.253632, *picture*}
whereas
Timing[
msft1 = msft;
msft1[[All, 1]] = AbsoluteTime /@ msft[[All, 1]];
DateListPlot[msft1]
]
{0.214658, *picture*}
So it is faster to convert to AbsoluteTime
and make a plot than to stick with date lists (as a side issue this can actually be done even faster with ListPlot
or ListLinePlot
and a tick function).
When wanting to work with date lists to select subsets of data you will typically choose a search criteria in which the absolute time of elements is tested against some condition. So this is another example where it is useful to already have the data in absolute time.
So the question is whether it is possible to import dates directly into Mathematica and have them as absolute times rather than date lists. My two specific examples would be FinancialData
as per the example above -- can this be made to output absolute times via some configuration rather than having to convert the data post import? Also for Excel spreadsheets containing columns with dates (i.e. date strings as per Excel formats) and data. Can these be imported and converted to absolute times during the import process instead of converted to, and output as, date lists?
(If solutions to this problem means that Import
and FinancialData
internals take date lists and convert to absolute time then I don't really see that as a solution. I am seeking ways to go direct to absolute time.)
Trace[Import["test.xls"]]
but it is too big and locks up the FrontEnd. $\endgroup$