summaryrefslogtreecommitdiff
path: root/ACE/ace/Time_Value.inl
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/ace/Time_Value.inl')
-rw-r--r--ACE/ace/Time_Value.inl20
1 files changed, 16 insertions, 4 deletions
diff --git a/ACE/ace/Time_Value.inl b/ACE/ace/Time_Value.inl
index a4b095033e7..98459b47713 100644
--- a/ACE/ace/Time_Value.inl
+++ b/ACE/ace/Time_Value.inl
@@ -70,10 +70,22 @@ ACE_INLINE void
ACE_Time_Value::set (double d)
{
// ACE_OS_TRACE ("ACE_Time_Value::set");
- time_t l = (time_t) d;
- this->tv_.tv_sec = l;
- this->tv_.tv_usec = (suseconds_t) ((d - (double) l) * ACE_ONE_SECOND_IN_USECS + .5);
- this->normalize ();
+ if (d < ACE_Numeric_Limits<time_t>::min())
+ {
+ this->tv_.tv_sec = ACE_Numeric_Limits<time_t>::min();
+ this->tv_.tv_usec = -ACE_ONE_SECOND_IN_USECS + 1;
+ }
+ else if (d > ACE_Numeric_Limits<time_t>::max())
+ {
+ this->tv_.tv_sec = ACE_Numeric_Limits<time_t>::max();
+ this->tv_.tv_usec = ACE_ONE_SECOND_IN_USECS - 1;
+ }
+ else
+ {
+ time_t l = (time_t) d;
+ this->tv_.tv_sec = l;
+ this->tv_.tv_usec = (suseconds_t) ((d - (double) l) * ACE_ONE_SECOND_IN_USECS + (d < 0 ? -0.5 : 0.5));
+ }
}
/// Initializes a timespec_t. Note that this approach loses precision