From e3456971d225f625b0a96c5ebcce1c47b796e34d Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 5 May 2005 07:56:24 +0000 Subject: [PATCH] fix and simplify GetDayInYearAndYear --- stepmania/src/DateTime.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/stepmania/src/DateTime.cpp b/stepmania/src/DateTime.cpp index f7574dc978..d8c0d9d50b 100644 --- a/stepmania/src/DateTime.cpp +++ b/stepmania/src/DateTime.cpp @@ -236,13 +236,17 @@ tm GetNextSunday( tm start ) tm GetDayInYearAndYear( int iDayInYearIndex, int iYear ) { - tm when = GetLocalTime(); - - when.tm_mday = iDayInYearIndex; + /* If iDayInYearIndex is 200, set the date to Jan 200th, and let mktime + * round it. This shouldn't suffer from the OSX mktime() issue described + * above, since we're not giving it negative values. */ + tm when; + ZERO( when ); + when.tm_mon = 0; + when.tm_mday = iDayInYearIndex+1; when.tm_year = iYear - 1900; time_t then = mktime( &when ); - when = *localtime( &then ); + localtime_r( &then, &when ); return when; }