On 15/01/2017 9:40 PM, Nestor wrote:
I cleaned up the function a little, but it still feels like a hack:

uint getAge(uint yyyy, uint mm, uint dd) {
  import std.datetime;
  SysTime t = Clock.currTime;
  ubyte correction = 0;
  if(
    (t.month < mm) ||
    ( (t.month == mm) && (t.day < dd) )
  ) correction += 1;
  return (t.year - yyyy - correction);
}

Isn't there anything better?

The problem with this is that it won't take into account leap years.

Reply via email to