Skip to content

Commit

Permalink
Merge pull request #2241 from jmdavis/duration
Browse files Browse the repository at this point in the history
Fix deprecation messages caused by recent changes to Duration.
  • Loading branch information
monarchdodra committed Jun 12, 2014
2 parents 04d4617 + 73cf168 commit f1f6b75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 4 additions & 5 deletions std/datetime.d
Expand Up @@ -27217,11 +27217,10 @@ private:
immutable absOffset = abs(utcOffset);
enforceEx!DateTimeException(absOffset < dur!"minutes"(1440),
"Offset from UTC must be within range (-24:00 - 24:00).");

if(utcOffset < Duration.zero)
return format("-%02d:%02d", absOffset.hours, absOffset.minutes);

return format("+%02d:%02d", absOffset.hours, absOffset.minutes);
int hours;
int minutes;
absOffset.split!("hours", "minutes")(hours, minutes);
return format(utcOffset < Duration.zero ? "-%02d:%02d" : "+%02d:%02d", hours, minutes);
}

unittest
Expand Down
8 changes: 4 additions & 4 deletions std/socket.d
Expand Up @@ -3109,8 +3109,7 @@ public:
else version (Posix)
{
_ctimeval tv;
tv.tv_sec = to!(typeof(tv.tv_sec ))(value.total!"seconds");
tv.tv_usec = to!(typeof(tv.tv_usec))(value.fracSec.usecs);
value.split!("seconds", "usecs")(tv.tv_sec, tv.tv_usec);
setOption(level, option, (&tv)[0 .. 1]);
}
else static assert(false);
Expand Down Expand Up @@ -3185,9 +3184,10 @@ public:
//Winsock: possibly internally limited to 64 sockets per set
static int select(SocketSet checkRead, SocketSet checkWrite, SocketSet checkError, Duration timeout)
{
auto vals = timeout.split!("seconds", "usecs")();
TimeVal tv;
tv.seconds = to!(tv.tv_sec_t )(timeout.total!"seconds");
tv.microseconds = to!(tv.tv_usec_t)(timeout.fracSec.usecs);
tv.seconds = cast(tv.tv_sec_t )vals.seconds;
tv.microseconds = cast(tv.tv_usec_t)vals.usecs;
return select(checkRead, checkWrite, checkError, &tv);
}

Expand Down

0 comments on commit f1f6b75

Please sign in to comment.