added a comment - - edited
ok, Ive attached patches to moodlelib.php and testmoodlelib.php for everyone to have a look at. Let me know if I've done anything silly
I added some unit tests. The changes I made to usergetdate() itself were a little more invasive than I expected. I wrote the unit tests testing the return array with and without a time zone then modified usergetdate() as necessary to get the returned array to be basically identical.
The core of moodle shouldn't be affected at all by these changes. I've looked through every call and they're all accessing the array using keys like this...
$thisdate = usergetdate(time());
The alternative is something like this.
list($seconds,$minutes,$hours,$mday,$wday,$mon,$year,$yday,$weekday,$month) = usergetdate(time());
I would recommend NOT doing it this way. Any changes in the array order will cause the wrong values to wind up in the wrong variables which could have all sorts of hard to track down side effects. The unit tests should catch that but... Note that the unit tests do it this way so that they document the order of things if you are going to do it this way.