https://issues.dlang.org/show_bug.cgi?id=15137
Issue ID: 15137 Summary: core.time: Support Duration/Duration and Duration%Duration Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: druntime Assignee: nob...@puremagic.com Reporter: thecybersha...@gmail.com CC: issues.dl...@jmdavisprog.com Currently porting some D1 code to D2, and some of the D1 code is quite annoying as rewritten to use core.time. Example 1: auto units = [ "days" : TicksPerDay, "hours" : TicksPerHour, "seconds" : TicksPerSecond, ]; d_time d = 1234567890; foreach (name, duration; units) writefln("%d %s", d/duration, name); Converting between time units when you don't know the unit during compilation using core.time is excessively verbose - you have to use something like: duration.total!"hnsecs" / unit.total!"hnsecs". This is also leaking a low-level detail (that Duration is internally represented as hnsecs). Example 2: fiveMinuteTotals[delta % TicksPerDay / (5*TicksPerMinute)]++; This calculates collective frequency when during the day events occur, with five-minute granularity. With core.time, this becomes something like... fiveMinuteTotals[delta.split!("days", "hnsecs").hnsecs / 5.minutes.total!"hnsecs"]++; I really don't see any reason why Duration should not support binary / and % with two Durations. --