On Sunday, 15 November 2020 at 03:14:07 UTC, Marcone wrote:
I want to convert seconds to hour, minut and second.
Do you want to convert a *duration* into hours/minutes/seconds,
or format a UNIX *timestamp* to hours/minutes/seconds? These are
conceptually two different things.
`Clock.currTime` will return a `SysTime` (a point in time) in
your local timezone. If you want to get the hour/minute/second
parts of a duration of time (for instance, in seconds), use a
`Duration` and `split`.
// Função strftime()
string strftime(string fmt, int tempo){
long H, M, S;
tempo.seconds.split!("hours", "minutes", "seconds")(H, M, S);
return fmt.replace("%H", H.text).replace("%M",
M.text).replace("%S", S.text);
}
writeln(strftime("%H:%M:%S", 4783)); // 1:19:43
https://run.dlang.io/is/0L5yqP
https://dlang.org/articles/intro-to-datetime.html