Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
May 13, 2015 SysTime object from unixtime | ||||
---|---|---|---|---|
| ||||
As strange as it sounds, after 20 minutes reading the docs about std.datetime I could not figure out how to get a SysTime object starting from a long unixtime. I'm sure I'm missing something obvious, any tips? Thanks, dat |
May 13, 2015 Re: SysTime object from unixtime | ||||
---|---|---|---|---|
| ||||
Posted in reply to dat | The "interfacing to C" header of this page talks about it: http://dlang.org/intro-to-datetime.html import std.datetime; import core.stdc.time; void main() { time_t unixTime = core.stdc.time.time(null); auto stdTime = unixTimeToStdTime(unixTime); auto st = SysTime(stdTime); } I wish std.datetime made this a bit easier but that's how to do it. |
May 13, 2015 Re: SysTime object from unixtime | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Wednesday, 13 May 2015 at 01:40:04 UTC, Adam D. Ruppe wrote:
> The "interfacing to C"
Sorry, "interfacing with C", search for those words on that page
and it will bring you to the header.
|
May 13, 2015 Re: SysTime object from unixtime | ||||
---|---|---|---|---|
| ||||
Posted in reply to dat | see import std.stdio; import std.datetime; import std.process; void main() { auto ct = Clock.currTime; write("\n\n\tData: ",ct.day," / ",ct.month," / ",ct.year,".\n"); auto tv = Clock.currTime; write("\tHour: ", tv.hour,":", tv.minute,":", tv.second,".", tv.fracSec,"\n "); writeln("\n"); wait(spawnShell("pause")); } |
May 15, 2015 Re: SysTime object from unixtime | ||||
---|---|---|---|---|
| ||||
Posted in reply to Cassio Butrico | thanks, that did the trick! |
Copyright © 1999-2021 by the D Language Foundation