On Tuesday, 9 July 2019 at 08:51:59 UTC, Mitacha wrote:
I've managed to make it work using 'alias this' and wrapper struct.
https://run.dlang.io/is/3SMEFZ
It's not an elegant solution, there could be a better way to do this.

Yea, a wrapper struct with custom `toString` seems the most obvious way forward. No need to bother with `alias this`, though, since one only needs the wrapper struct at the point where one wants to format the datetime info. A wrapper struct like this:

    struct ISOExtSysTime
    {
        private SysTime systime;

        public void toString (Output) (ref Output output)
            if (isOutputRange!(Output, char))
        {
            this.systime.toISOExtString(output);
        }
    }

allows easy usage along the lines of:

    writefln!"%s"(ISOExtSysTime(sys_time));

... and one could easily write a small factory function to shorten the code if needed.

Reply via email to