by richard on Sat, 11/19/2011 - 12:13

So, I've been working on a program that provides atmospheric sounds (rain, thunder, owls, that kind of thing). All well and good, got the system playing sounds (through a nice audio library that was actually written by some of the members of Radio at Warwick a couple of years ago - http://www.broadcastsoftware.org/), and I have a nice data structure layout all sorted for random sounds playing between specific times and the such.

Which is where it all falls down. I don't know how to do times in C++.

I do a quick Google, and find that there is a header file which includes time stuff. All well and good, import it, and do a quick cout of the time that it's returning (it returns seconds since the epoch). Randomly, it's giving me the time from 6 hours ago.

Turns out that there's another function (localtime) which then converts it into local time.

No idea what timezone it's working on though (as my hardware clock is set to UTC, which we should be on at the moment, what with it not being summer).

Hohum, localtime here I come!