On Sunday, 15 November 2020 at 03:15:29 UTC, Anonymouse wrote:
On Sunday, 15 November 2020 at 03:08:48 UTC, Marcone wrote:
On Sunday, 15 November 2020 at 02:29:20 UTC, Anonymouse wrote:
On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote:
auto mytime = Clock.currTime().toUnixTime()

writeln(strftime("%Hh:%Mm:%Ss", mytime)); How can I make some like this in D?

auto mytime = Clock.currTime;
writefln("%02dh:%02dm:%02ds", mytime.hour, mytime.minute, mytime.second);

auto mytimeFromUnix = SysTime.fromUnixTime(1234567890);
writefln("%02dh:%02dm:%02ds", mytimeFromUnix.hour, mytimeFromUnix.minute, mytimeFromUnix.second);

https://run.dlang.io/is/TAO6Q9

Your code get wrong hour result: 21hours, only minuts and seconds correct.

If you're looking at the run.dlang.io output, the server is probably in a different timezone than yours.

Tested locally at 04:14 instead of sleeping:

$ dmd -run mytime.d
04h:14m:06s
00h:31m:30s

See my program for you understand better:
Here is the picture of my program, see red mark: https://i.imgur.com/D5nsNHM.png

Reply via email to