Thread overview
Formatted date
Mar 22, 2023
Alexander Zhirov
Mar 22, 2023
Anonymouse
Mar 22, 2023
Anonymouse
Mar 22, 2023
Alexander Zhirov
March 22, 2023

Tell me, how can I use such a date conversion mechanism? I didn't find something similar on the forum.

Convert date from received time

Clock.currTime().toSimpleString()

So that i can get a more readable look:

2023-Mar-22 16:53:42.2507395 => 2023.03.22 16:53:42

March 22, 2023

On Wednesday, 22 March 2023 at 14:02:53 UTC, Alexander Zhirov wrote:

>

So that i can get a more readable look:

2023-Mar-22 16:53:42.2507395 => 2023.03.22 16:53:42

Maybe there's a better way but I just do this.

import std;

void main()
{
    const now = Clock.currTime();
    enum pattern = "%d.%02d.%02d %02d:%02d:%02d";
    writefln(pattern, now.year, now.month, now.day, now.hour, now.minute, now.second);
}

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

March 22, 2023

On Wednesday, 22 March 2023 at 14:02:53 UTC, Alexander Zhirov wrote:

>

Convert date from received time

Clock.currTime().toSimpleString()

I missed the part about receiving the time, so ignore my previous post.

March 22, 2023

On 3/22/23 10:02 AM, Alexander Zhirov wrote:

>

Tell me, how can I use such a date conversion mechanism? I didn't find something similar on the forum.

Convert date from received time

Clock.currTime().toSimpleString()

So that i can get a more readable look:

2023-Mar-22 16:53:42.2507395 => 2023.03.22 16:53:42

D's datetime intentionally does not tackle formatting -- it's a huge undertaking.

There is an option on code.dlang.org: https://code.dlang.org/packages/datefmt

-Steve

March 22, 2023

On Wednesday, 22 March 2023 at 17:53:39 UTC, Steven Schveighoffer wrote:

>

D's datetime intentionally does not tackle formatting -- it's a huge undertaking.

There is an option on code.dlang.org: https://code.dlang.org/packages/datefmt

-Steve

I'll try it tomorrow, thanks!