D-Programming-Language/phobos — pull request #2219 by jmdavis (2014-05-31 20:38:27+00:00)
Title: Fix issue 12828: Fix return type of SimpleTimeZone.utcOffset.

A longer explanation is in the bug report ( https://issues.dlang.org/show_bug.cgi?id=12828 ) but basically what it comes down to is that `SimpleTimeZone.utcOffset` should be a `Duration` like every other `utcOffset` is, particularly since we're not supposed to have any time values be naked integral values in druntime or Phobos. I got that right everywhere but in this case, where I guess I was being stupid when I wrote it. I fixed the setter some time ago, but I haven't fixed the getter before now, because I was holding out on getting multiple alias thises in the hope that that could be used to make this change without immediately breaking any code, but it's looking like we're never going to get that feature, and depending on how it's implemented, it might not fix the problem anyway due to a conflict between `core.time.minutes` and `core.time.Duration.minutes`. So, I'm proposing that we simply make the change now and deal with the relatively small amount of code that it breaks rather than waiting for a feature that may never come and letting more code be written which has to deal with `utcOffset` being the wrong type. And while this _is_ unfortunately a breaking change, the fix is fortunately very simple. A line like

auto foo = stz.utcOffset;

becomes

auto foo = cast(int)stz.utcOffset.total!"minutes"();

and a line like

auto foo = minutes(stz.utcOffset);

becomes

auto foo = stz.utcOffset;

I'm not enthused about breaking code like this, but I am convinced that the amount of code broken will be relatively small and easily fixed, and I think that we're worse off if we leave this wart in Phobos. So, I think that this change is worth making.