On Tue, 22 Dec 2009 10:14:40 +0100, Tadej Borovšak <tadeboro gmail com> wrote:
GLib already has a function to do this: g_date_set_time_t(). I don't know why it isn't wrapped in Vala, but I've been using it in C and it works like a charm.
Poking around a little more, I finally found it. Time. Du'h. Time time = Time.local(time_t timep); time_t timep = time.mktime(); string tstr = time.format("..."); Some things that were kind of annoying; Time doesn't seem to have date/time manipulation commands (what IS the point of having separate Date and Time classes, anyhow?!?). Time also appears to lack a to_date function (alternatively, a Date.from_time() would work just as well, along with a few other constructors). Further Date, quite irritatingly, seems to lack a format() function, and Vala doesn't like casting from time.day to DateDay which makes using date.set_dmy() rather difficult. So I ended using a round trip though Time to wind the initial time_t back to the prior midnight, and then repeatedly updating the time_t (adding 43200 seconds) and re-generating the Time object, for each 12-hour period along the data set. Not the cleanest way I can imagine, but it appears to work. -- Fredderic Take your Axe, Bobs your Auntie, and All that Jazz. Debian/unstable (LC#384816) on 2.6.30-i686 2009 (up 23 days, 3:36)
Attachment:
signature.asc
Description: PGP signature