On Tuesday, 12 June 2012 at 17:40:40 UTC, Jonathan M Davis wrote:
On Tuesday, June 12, 2012 19:28:38 TJB wrote:
I am working with some financial data that comes in binary files.
It has two fields in particular that I am trying to convert to
human readable formats. The first is a date string like
"20060621", which I am able to work with just fine. But then it
has a field called ttim, which is the number of seconds from
midnight at which a trade occurred. For example, a trade
occurring at 28824 seconds in the day would have taken place at
"8:00:24" (only resolution to the second).

My question is: how do I convert the number of seconds (like
28824) to a formatted time string (like 08:00:24)? I looked in
std.datetime, but it isn't obvious which functions I should use.

You help and suggestions are much appreciated!

import std.datetime;
import std.stdio;

void main()
{
 auto ttm = 28824;
 auto duration = dur!"seconds"(ttm);
 auto time = TimeOfDay.init + duration;
 writeln(time.toISOExtString());
}

- Jonathan M Davis

Awesome! In the D community you get questions answered by the library writers! Thanks so much! This was perfect.

TJB


Reply via email to