BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsls_timeinterval.h
Go to the documentation of this file.
1/// @file bsls_timeinterval.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bsls_timeinterval.h -*-C++-*-
8#ifndef INCLUDED_BSLS_TIMEINTERVAL
9#define INCLUDED_BSLS_TIMEINTERVAL
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bsls_timeinterval bsls_timeinterval
15/// @brief Provide a representation of a time interval.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bsls
19/// @{
20/// @addtogroup bsls_timeinterval
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bsls_timeinterval-purpose"> Purpose</a>
25/// * <a href="#bsls_timeinterval-classes"> Classes </a>
26/// * <a href="#bsls_timeinterval-description"> Description </a>
27/// * <a href="#bsls_timeinterval-representation"> Representation </a>
28/// * <a href="#bsls_timeinterval-user-defined-literals"> User-Defined Literals </a>
29/// * <a href="#bsls_timeinterval-usage"> Usage </a>
30/// * <a href="#bsls_timeinterval-example-1-creating-and-modifying-a-bsls-timeinterval"> Example 1: Creating and Modifying a bsls::TimeInterval </a>
31///
32/// # Purpose {#bsls_timeinterval-purpose}
33/// Provide a representation of a time interval.
34///
35/// # Classes {#bsls_timeinterval-classes}
36///
37/// - bsls::TimeInterval: time interval with nanosecond resolution
38///
39/// @see bdlt_time, bdlt_datetimeinterval
40///
41/// # Description {#bsls_timeinterval-description}
42/// This component provides a value-semantic type,
43/// `bsls::TimeInterval`, that is capable of representing a signed time
44/// interval with nanosecond resolution.
45///
46/// ## Representation {#bsls_timeinterval-representation}
47///
48///
49/// A time interval has a value that is independent of its representation.
50/// Conceptually, a time interval may be thought of as a signed,
51/// arbitrary-precision floating-point number denominated in seconds (or in
52/// days, or in fortnights, if one prefers). A `bsls::TimeInterval` represents
53/// this value as two fields: seconds and nanoseconds. In the "canonical
54/// representation" of a time interval, the `seconds` field may have any 64-bit
55/// signed integer value, with the `nanoseconds` field limited to the range
56/// `[ -999,999,999..999,999,999 ]`, and with the additional constraint that the
57/// two fields are either both non-negative or both non-positive. When setting
58/// the value of a time interval via its two-field representation, any integer
59/// value may be used in either field, with the constraint that the resulting
60/// number of seconds be representable as a 64-bit signed integer. Similarly,
61/// the two field values may be accessed in the canonical representation using
62/// the `seconds` and `nanoseconds` methods.
63///
64/// Binary arithmetic and relational operators taking two `bsls::TimeInterval`
65/// objects, or a `bsls::TimeInterval` object and a `double`, are provided. A
66/// `double` operand, representing a real number of seconds, is first converted
67/// to a `bsls::TimeInterval` object before performing the operation. Under
68/// such circumstances, the fractional part of the `double`, if any, is rounded
69/// to the nearest whole number of nanoseconds.
70///
71/// ## User-Defined Literals {#bsls_timeinterval-user-defined-literals}
72///
73///
74/// The user-defined literal `operator"" _h`, `operator"" _min`,
75/// `operator"" _s`, `operator"" _ms`, `operator"" _us` and `operator"" _ns` are
76/// declared for the `TimeInterval`. These suffixes can be applied to integer
77/// literals and allow to create an object, representing the specified number of
78/// hours, minutes, seconds, milliseconds, microseconds or nanoseconds
79/// respectively:
80/// @code
81/// using namespace bsls::TimeIntervalLiterals;
82///
83/// bsls::TimeInterval i0 = 10_h;
84/// assert(36000 == i0.seconds() );
85/// assert(0 == i0.nanoseconds());
86///
87/// bsls::TimeInterval i1 = 10001_ms;
88/// assert(10 == i1.seconds() );
89/// assert(1000000 == i1.nanoseconds());
90///
91/// bsls::TimeInterval i2 = 100_ns;
92/// assert(0 == i2.seconds() );
93/// assert(100 == i2.nanoseconds());
94/// @endcode
95/// The operators providing literals are available in the
96/// `BloombergLP::bsls::literals::TimeIntervalLiterals` namespace (where
97/// `literals` and `TimeIntervalLiterals` are both inline namespaces). Because
98/// of inline namespaces, there are several viable options for a using
99/// declaration, but *we* *recommend*
100/// `using namespace bsls::TimeIntervalLiterals`, which minimizes the scope of
101/// the using declaration.
102///
103/// Note that user defined literals can be used only if the compiler supports
104/// the C++11 standard.
105///
106/// ## Usage {#bsls_timeinterval-usage}
107///
108///
109/// This section illustrates intended use of this component.
110///
111/// ### Example 1: Creating and Modifying a bsls::TimeInterval {#bsls_timeinterval-example-1-creating-and-modifying-a-bsls-timeinterval}
112///
113///
114/// The following example demonstrates how to create and manipulate a
115/// `bsls::TimeInterval` object.
116///
117/// First, we default construct a `TimeInterval` object, `interval`:
118/// @code
119/// bsls::TimeInterval interval;
120///
121/// assert(0 == interval.seconds());
122/// assert(0 == interval.nanoseconds());
123/// @endcode
124/// Next, we set the value of `interval` to 1 second and 10 nanoseconds (a time
125/// interval of 1000000010 nanoseconds):
126/// @code
127/// interval.setInterval(1, 10);
128///
129/// assert( 1 == interval.seconds());
130/// assert(10 == interval.nanoseconds());
131/// @endcode
132/// Then, we add 3 seconds to `interval`:
133/// @code
134/// interval.addInterval(3, 0);
135///
136/// assert( 4 == interval.seconds());
137/// assert(10 == interval.nanoseconds());
138/// @endcode
139/// Next, we create a copy of `interval`, `intervalPrime`:
140/// @code
141/// bsls::TimeInterval intervalPrime(interval);
142///
143/// assert(intervalPrime == interval);
144/// @endcode
145/// Finally, we assign 3.14 seconds to `intervalPrime`, and then add 2.73
146/// seconds more:
147/// @code
148/// intervalPrime = 3.14;
149/// intervalPrime += 2.73;
150///
151/// assert( 5 == intervalPrime.seconds());
152/// assert(870000000 == intervalPrime.nanoseconds());
153/// @endcode
154/// @}
155/** @} */
156/** @} */
157
158/** @addtogroup bsl
159 * @{
160 */
161/** @addtogroup bsls
162 * @{
163 */
164/** @addtogroup bsls_timeinterval
165 * @{
166 */
167
168#include <bsls_assert.h>
170#include <bsls_keyword.h>
171#include <bsls_libraryfeatures.h>
172#include <bsls_preconditions.h>
173#include <bsls_types.h>
174
175#if BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
176#include <chrono>
177#include <type_traits>
178#endif // BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
179
180#include <iosfwd>
181#include <limits.h> // 'LLONG_MIN', 'LLONG_MAX'
182
183#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
184#include <bsls_nativestd.h>
185#endif // BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
186
187// BDE_VERIFY pragma: push
188// BDE_VERIFY pragma: -FABC01 // 'add*' operations are ordered by time unit
189
190#if BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
191#define BSLS_TIMEINTERVAL_PROVIDES_CHRONO_CONVERSIONS
192#endif // BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
193
194
195namespace bsls {
196
197#ifdef BSLS_TIMEINTERVAL_PROVIDES_CHRONO_CONVERSIONS
198
199 // =======================================
200 // template struct TimeInterval_IsDuration
201 // =======================================
202
203/// Template metafunction to determine if the specified `TYPE` is a
204/// `std::chrono::duration`.
205template <class TYPE>
206struct TimeInterval_IsDuration : std::false_type {
207};
208
209/// Template metafunction specialization for `std::chrono::duration` types.
210template <class REP, class PER>
211struct TimeInterval_IsDuration<std::chrono::duration<REP, PER> >
212 : std::true_type {
213};
214
215 // =============================
216 // struct TimeInterval_RepTraits
217 // =============================
218
219/// Trait metafunction that determines whether the specified `REP` type is
220/// considered a floating point type.
221template <class REP>
223
224 static const bool k_IS_FLOAT =
225 std::is_floating_point<REP>::value
226 || std::chrono::treat_as_floating_point<REP>::value;
227 // This compile time constant is 'true' if the 'REP' (template type
228 // argument) is indicated to be a floating point type by the underlying
229 // library. Otherwise, if the underlying library does not consider 'REP'
230 // floating point anywhere (see note), 'k_IS_FLOAT' is 'false'. Note that
231 // to cover all scenarios we need to examine *two* traits. The first one
232 // that tells if the representation type is a floating point (arithmetic)
233 // type or not (from '<type_traits>'), and another that tells that
234 // representation type is considered a floating point type from the
235 // 'std::chrono' perspective. Formally the second one just duplicates the
236 // first one, but *in theory* either can be specialized to be true,
237 // independently. Also note that conversions from 'std::chrono::duration'
238 // with a floating point representation to 'bsls::TimeInterval' are *not*
239 // supported for now.
240};
241
242 // ==================================
243 // struct TimeInterval_DurationTraits
244 // ==================================
245
246/// Trait metafunction that determines whether the
247/// `std::chrono::duration<REP, PERIOD>` object can be converted to
248/// `bsls::TimeInterval` either implicitly or explicitly.
249template <class REP, class PERIOD>
251
252 /// This compile time constant is `true` if the `REP` (template type
253 /// argument) is indicated to be a floating point type by the underlying
254 /// library. Otherwise, if the underlying library does not consider
255 /// `REP` floating point anywhere (see `TimeInterval_RepTraits`),
256 /// `k_IS_FLOAT` is `false`.
258
259 /// This compile time constant is `true` if any possible value of an
260 /// 'std::chrono::duration<REP, PERIOD> object will be represented by
261 /// integer nanoseconds (fractions of nanoseconds are not required).
262 /// Otherwise this value is `false`.
263 static const bool k_IS_IMPLICIT = (std::nano::den % PERIOD::den == 0);
264
265 /// This compile time constant is `true` if
266 /// `std::chrono::duration<REP, PERIOD>` objects will be implicitly
267 /// converted to `TimeInterval`, and `false` otherwise. This value is
268 /// intended to be used with `enable_if` to enable implicitly converting
269 /// function overloads. Note that this boolean value is mutually
270 /// exclusive with `k_EXPLICIT_CONVERION_ENABLED` as in they will never
271 /// be both `true` for the same `REP" and `PERIOD', but they may be both
272 /// `false` for floats.
275
276 /// This compile time constant is `true` if
277 /// `std::chrono::duration<REP, PERIOD>` objects can be explicitly
278 /// converted to `TimeInterval`, and `false` otherwise. This value is
279 /// intended to be used with `enable_if` to enable explicitly converting
280 /// function overloads. Note that this boolean value is mutually
281 /// exclusive with `k_IMPLICIT_CONVERION_ENABLED` as in they will never
282 /// be both `true` for the same `REP" and `PERIOD', but they may be both
283 /// `false` for floats.
286};
287
288#endif
289 // ==================
290 // class TimeInterval
291 // ==================
292
293/// Each instance of this value-semantic type represents a time interval
294/// with nanosecond resolution. In the "canonical representation" of a time
295/// interval, the `seconds` field may have any 64-bit signed integer value,
296/// with the `nanoseconds` field limited to the range
297/// `[ -999,999,999..999,999,999 ]`, and with the additional constraint that
298/// the two fields are either both non-negative or both non-positive.
299///
300/// See @ref bsls_timeinterval
302
303 // PRIVATE TYPES
304 enum {
305 k_MILLISECS_PER_SEC = 1000, // one thousand
306
307 k_MICROSECS_PER_SEC = 1000000, // one million
308
309 k_NANOSECS_PER_MICROSEC = 1000, // one thousand
310
311 k_NANOSECS_PER_MILLISEC = 1000000, // one million
312
313 k_NANOSECS_PER_SEC = 1000000000, // one billion
314
315 k_SECONDS_PER_MINUTE = 60,
316
317 k_SECONDS_PER_HOUR = 60 * k_SECONDS_PER_MINUTE,
318
319 k_SECONDS_PER_DAY = 24 * k_SECONDS_PER_HOUR
320 };
321
322 // DATA
323 bsls::Types::Int64 d_seconds; // field for seconds
324 int d_nanoseconds; // field for nanoseconds
325
326 // PRIVATE CLASS METHODS
327
328 /// Return `true` if the sum of the specified `lhs` and `rhs` can be
329 /// represented using a 64-bit signed integer, and `false` otherwise.
331 static bool isSumValidInt64(bsls::Types::Int64 lhs,
333
334 public:
335 // CLASS METHODS
336
337 /// Return `true` if a `TimeInterval` object can be constructed from the
338 /// specified `seconds` and `nanoseconds`, and `false` otherwise. A
339 /// time interval can be constructed from `seconds` and `nanoseconds` if
340 /// their sum results in a time interval whose total number of seconds
341 /// can be represented with a 64-bit signed integer.
344 int nanoseconds);
345
346#ifdef BSLS_TIMEINTERVAL_PROVIDES_CHRONO_CONVERSIONS
347 /// Return `true` if a `TimeInterval` object can be constructed from the
348 /// specified `duration`, and `false` otherwise. A time interval can be
349 /// constructed from `duration` if duration's value converted to seconds
350 /// can be represented with a 64-bit signed integer.
351 template <class REP, class PERIOD>
352 static bool isValid(const std::chrono::duration<REP, PERIOD>& duration);
353#endif
354
355 // Aspects
356
357 /// Return the maximum valid BDEX format version, as indicated by the
358 /// specified `versionSelector`, to be passed to the `bdexStreamOut`
359 /// method. Note that it is highly recommended that `versionSelector`
360 /// be formatted as "YYYYMMDD", a date representation. Also note that
361 /// `versionSelector` should be a *compile*-time-chosen value that
362 /// selects a format version supported by both externalizer and
363 /// unexternalizer. See the `bslx` package-level documentation for more
364 /// information on BDEX streaming of value-semantic types and
365 /// containers.
366 static int maxSupportedBdexVersion(int versionSelector);
367
368 // CREATORS
369
370 /// Create a time interval having the value of 0 seconds and 0
371 /// nanoseconds.
373 TimeInterval();
374
375 /// Create a time interval having the value given by the sum of the
376 /// specified integral number of `seconds` and `nanoseconds`. The
377 /// behavior is undefined unless the total number of seconds in the
378 /// resulting time interval can be represented with a 64-bit signed
379 /// integer (see `isValid`). Note that there is no restriction on the
380 /// sign or magnitude of either argument except that they must not
381 /// violate the method's preconditions.
384
385 /// Create a time interval having the value represented by the specified
386 /// real number of `seconds`. The fractional part of `seconds`, if any,
387 /// is rounded to the nearest whole number of nanoseconds. The
388 /// behavior is undefined unless the total number of seconds in the
389 /// resulting time interval can be represented with a 64-bit signed
390 /// integer.
391 explicit TimeInterval(double seconds);
392
393#ifdef BSLS_TIMEINTERVAL_PROVIDES_CHRONO_CONVERSIONS
394 /// Create a time interval having the value represented by the specified
395 /// `duration`. Only integer representations of `duration` are
396 /// supported (i.e. `REP_TYPE` is integer). If the `duration` can be
397 /// represented *exactly* by an integer nanoseconds this constructor
398 /// will be implicit. Otherwise, the constructor will be explicit. The
399 /// behavior is undefined unless the `duration` can be converted to a
400 /// valid `TimeInterval` object, whose `seconds` field may have any
401 /// 64-bit signed integer value and `nanoseconds` field limited to the
402 /// range `[ -999,999,999..999,999,999 ]`. Note that the current
403 /// implementation of the lossy conversions (e.g., fractions of a
404 /// nanosecond) truncates the values towards zero, however this behavior
405 /// may change without notice in the future, so *do not* rely on this.
406 template <class REP_TYPE, class PERIOD_TYPE>
408 const std::chrono::duration<REP_TYPE, PERIOD_TYPE>& duration,
409 typename std::enable_if<TimeInterval_DurationTraits<
410 REP_TYPE,
411 PERIOD_TYPE>::k_IMPLICIT_CONVERSION_ENABLED,
412 int>::type * = 0);
413 template <class REP_TYPE, class PERIOD_TYPE>
415 const std::chrono::duration<REP_TYPE, PERIOD_TYPE>& duration,
416 typename std::enable_if<TimeInterval_DurationTraits<
417 REP_TYPE,
418 PERIOD_TYPE>::k_EXPLICIT_CONVERSION_ENABLED,
419 int>::type * = 0);
420#endif
421
422 TimeInterval(const TimeInterval& original) = default;
423 // Create a time interval having the value of the specified 'original'
424 // time interval. Note that this trivial copy constructor is
425 // generated by the compiler.
426
427 ~TimeInterval() = default;
428 // Destroy this time interval object. Note that this trivial
429 // destructor is generated by the compiler.
430
431 // MANIPULATORS
432
433 // Operator Overloads
434
435 TimeInterval& operator=(const TimeInterval& rhs) = default;
436 // Assign to this time interval the value of the specified 'rhs' time
437 // interval, and return a reference providing modifiable access to this
438 // object. Note that this trivial assignment operation is generated by
439 // the compiler.
440
441 /// Assign to this time interval the value of the specified `rhs` real
442 /// number of seconds, and return a reference providing modifiable
443 /// access to this object. The fractional part of `rhs`, if any, is
444 /// rounded to the nearest whole number of nanoseconds. The behavior
445 /// is undefined unless `rhs` can be converted to a valid
446 /// `TimeInterval` object.
447 TimeInterval& operator=(double rhs);
448
449 /// Add to this time interval the value of the specified `rhs` time
450 /// interval, and return a reference providing modifiable access to
451 /// this object. The behavior is undefined unless the total number of
452 /// seconds in the resulting time interval can be represented with a
453 /// 64-bit signed integer.
455
456 /// Add to this time interval the value of the specified `rhs` real
457 /// number of seconds, and return a reference providing modifiable
458 /// access to this object. The fractional part of `rhs`, if any, is
459 /// rounded to the nearest whole number of nanoseconds before being
460 /// added to this object. The behavior is undefined unless `rhs` can
461 /// be converted to a valid `TimeInterval` object, and the total number
462 /// of seconds in the resulting time interval can be represented with a
463 /// 64-bit signed integer.
464 TimeInterval& operator+=(double rhs);
465
466 /// Subtract from this time interval the value of the specified `rhs`
467 /// time interval, and return a reference providing modifiable access to
468 /// this object. The behavior is undefined unless
469 /// `LLONG_MIN != rhs.seconds()`, and the total number of seconds in the
470 /// resulting time interval can be represented with a 64-bit signed
471 /// integer.
473
474 /// Subtract from this time interval the value of the specified `rhs`
475 /// real number of seconds, and return a reference providing modifiable
476 /// access to this object. The fractional part of `rhs`, if any, is
477 /// rounded to the nearest whole number of nanoseconds before being
478 /// subtracted from this object. The behavior is undefined unless
479 /// `rhs` can be converted to a valid `TimeInterval` object whose
480 /// `seconds` field is greater than `LLONG_MIN`, and the total number of
481 /// seconds in the resulting time interval can be represented with a
482 /// 64-bit signed integer.
483 TimeInterval& operator-=(double rhs);
484
485 // Add Operations
486
487 /// Add to this time interval the number of seconds represented by the
488 /// specified integral number of `days`, and return a reference
489 /// providing modifiable access to this object. The behavior is
490 /// undefined unless the number of seconds in `days`, and the total
491 /// number of seconds in the resulting time interval, can both be
492 /// represented with 64-bit signed integers. Note that `days` may be
493 /// negative.
496
497 /// Add to this time interval the number of seconds represented by the
498 /// specified integral number of `hours`, and return a reference
499 /// providing modifiable access to this object. The behavior is
500 /// undefined unless the number of seconds in `hours`, and the total
501 /// number of seconds in the resulting time interval, can both be
502 /// represented with 64-bit signed integers. Note that `hours` may be
503 /// negative.
506
507 /// Add to this time interval the number of seconds represented by the
508 /// specified integral number of `minutes`, and return a reference
509 /// providing modifiable access to this object. The behavior is
510 /// undefined unless the number of seconds in `minutes`, and the total
511 /// number of seconds in the resulting time interval, can both be
512 /// represented with 64-bit signed integers. Note that `minutes` may be
513 /// negative.
516
517 /// Add to this time interval the specified integral number of
518 /// `seconds`, and return a reference providing modifiable access to
519 /// this object. The behavior is undefined unless the total number of
520 /// seconds in the resulting time interval can be represented with a
521 /// 64-bit signed integer. Note that `seconds` may be negative.
524
525 /// Add to this time interval the specified integral number of
526 /// `milliseconds`, and return a reference providing modifiable access
527 /// to this object. The behavior is undefined unless the total number
528 /// of seconds in the resulting time interval can be represented with a
529 /// 64-bit signed integer. Note that `milliseconds` may be negative.
531
532 /// Add to this time interval the specified integral number of
533 /// `microseconds`, and return a reference providing modifiable access
534 /// to this object. The behavior is undefined unless the total number
535 /// of seconds in the resulting time interval can be represented with a
536 /// 64-bit signed integer. Note that `microseconds` may be negative.
538
539 /// Add to this time interval the specified integral number of
540 /// `nanoseconds`, and return a reference providing modifiable access to
541 /// this object. The behavior is undefined unless the total number of
542 /// seconds in the resulting time interval can be represented with a
543 /// 64-bit signed integer. Note that `nanoseconds` may be negative.
545
546 // Set Operations
547
548 /// Set the overall value of this object to indicate the specified
549 /// integral number of `days`. The behavior is undefined unless the
550 /// number of seconds in `days` can be represented with a 64-bit signed
551 /// integer. Note that `days` may be negative.
554
555 /// Set the overall value of this object to indicate the specified
556 /// integral number of `hours`. The behavior is undefined unless the
557 /// number of seconds in `hours` can be represented with a 64-bit signed
558 /// integer. Note that `hours` may be negative.
561
562 /// Set the overall value of this object to indicate the specified
563 /// integral number of `minutes`. The behavior is undefined unless the
564 /// number of seconds in `minutes` can be represented with a 64-bit
565 /// signed integer. Note that `minutes` may be negative.
568
569 /// Set the overall value of this object to indicate the specified
570 /// integral number of `seconds`. Note that `seconds` may be negative.
573
574 /// Set the overall value of this object to indicate the specified
575 /// integral number of `milliseconds`. Note that `milliseconds` may be
576 /// negative.
578 void setTotalMilliseconds(bsls::Types::Int64 milliseconds);
579
580 /// Set the overall value of this object to indicate the specified
581 /// integral number of `microseconds`. Note that `microseconds` may be
582 /// negative.
584 void setTotalMicroseconds(bsls::Types::Int64 microseconds);
585
586 /// Set the overall value of this object to indicate the specified
587 /// integral number of `nanoseconds`. Note that `nanoseconds` may be
588 /// negative.
591
592 // Time-Interval-Based Manipulators
593
594 /// Add to this time interval the specified integral number of
595 /// `seconds`, and the optionally specified integral number of
596 /// `nanoseconds`. If unspecified, `nanoseconds` is 0. Return a
597 /// reference providing modifiable access to this object. The behavior
598 /// is undefined unless `seconds() + seconds`, and the total number of
599 /// seconds in the resulting time interval, can both be represented with
600 /// 64-bit signed integers.
602
603#ifdef BSLS_TIMEINTERVAL_PROVIDES_CHRONO_CONVERSIONS
604 /// Add to this time interval the specified `duration`. Return a
605 /// reference providing modifiable access to this object. The behavior
606 /// is undefined unless the `duration` can be converted to a valid
607 /// `TimeInterval` object, whose `seconds` field may have any
608 /// 64-bit signed integer value and `nanoseconds` field limited to the
609 /// range `[ -999,999,999..999,999,999 ]`. Also the behavior is
610 /// undefined unless the total number of seconds in the resulting time
611 /// interval can be represented with 64-bit signed integer. Note that
612 /// this operation is allowed only if representation type of the
613 /// `duration` is not a floating point type and the `duration` itself
614 /// can be *exactly* represented by an integer nanoseconds.
615 template <class REP_TYPE, class PERIOD_TYPE>
617 addDuration(const std::chrono::duration<REP_TYPE, PERIOD_TYPE>& duration,
618 typename std::enable_if<
620 k_IMPLICIT_CONVERSION_ENABLED,
621 int>::type * = 0);
622#endif
623
624 /// Set this time interval to have the value given by the sum of the
625 /// specified integral number of `seconds`, and the optionally specified
626 /// integral number of `nanoseconds`. If unspecified, `nanoseconds` is
627 /// 0. The behavior is undefined unless the total number of seconds in
628 /// the resulting time interval can be represented with a 64-bit signed
629 /// integer (see `isValid`). Note that there is no restriction on the
630 /// sign or magnitude of either argument except that they must not
631 /// violate the method's preconditions.
634
635 /// Set this time interval to have the value given by the sum of the
636 /// specified integral number of `seconds`, and the optionally specified
637 /// integral number of `nanoseconds`, where `seconds` and `nanoseconds`
638 /// form a canonical representation of a time interval (see
639 /// {Representation}). If unspecified, `nanoseconds` is 0. The
640 /// behavior is undefined unless
641 /// `-999,999,999 <= nanoseconds <= +999,999,999` and `seconds` and
642 /// `nanoseconds` are either both non-negative or both non-positive.
643 /// Note that this function provides a subset of the defined behavior of
644 /// `setInterval` chosen to minimize runtime performance cost.
647
648 // Aspects
649
650 /// Assign to this object the value read from the specified input
651 /// `stream` using the specified `version` format, and return a
652 /// reference to `stream`. If `stream` is initially invalid, this
653 /// operation has no effect. If `version` is not supported, this object
654 /// is unaltered and `stream` is invalidated, but otherwise unmodified.
655 /// If `version` is supported but `stream` becomes invalid during this
656 /// operation, this object has an undefined, but valid, state. Note
657 /// that no version is read from `stream`. See the `bslx` package-level
658 /// documentation for more information on BDEX streaming of
659 /// value-semantic types and containers.
660 template <class STREAM>
661 STREAM& bdexStreamIn(STREAM& stream, int version);
662
663 // ACCESSORS
664#ifdef BSLS_TIMEINTERVAL_PROVIDES_CHRONO_CONVERSIONS
665 /// Return `true` if the value of this time interval is within the valid
666 /// range of the parameterized `DURATION_TYPE`, and `false` otherwise.
667 /// Note that this function does not participate in overload resolution
668 /// unless `DURATION_TYPE` is an instantiation of
669 /// `std::chrono::duration`.
670 template <class DURATION_TYPE>
672 typename std::enable_if<TimeInterval_IsDuration<DURATION_TYPE>::value,
673 int>::type * = 0) const;
674#endif
675
676 /// Return the nanoseconds field in the canonical representation of the
677 /// value of this time interval.
679 int nanoseconds() const;
680
681 /// Return the seconds field in the canonical representation of the
682 /// value of this time interval.
685
686 /// Return the value of this time interval as an integral number of
687 /// days, rounded towards zero. Note that the return value may be
688 /// negative.
691
692 /// Return the value of this time interval as an integral number of
693 /// hours, rounded towards zero. Note that the return value may be
694 /// negative.
697
698 /// Return the value of this time interval as an integral number of
699 /// minutes, rounded towards zero. Note that the return value may be
700 /// negative.
703
704 /// Return the value of this time interval as an integral number of
705 /// seconds, rounded towards zero. Note that the return value may be
706 /// negative. Also note that this method returns the same value as
707 /// `seconds`.
710
711 /// Return the value of this time interval as an integral number of
712 /// milliseconds, rounded towards zero. The behavior is undefined
713 /// unless the number of milliseconds can be represented with a 64-bit
714 /// signed integer. Note that the return value may be negative.
717
718 /// Return the value of this time interval as an integral number of
719 /// microseconds, rounded towards zero. The behavior is undefined
720 /// unless the number of microseconds can be represented with a 64-bit
721 /// signed integer. Note that the return value may be negative.
724
725 /// Return the value of this time interval as an integral number of
726 /// nanoseconds. The behavior is undefined unless the number of
727 /// nanoseconds can be represented using a 64-bit signed integer. Note
728 /// that the return value may be negative.
731
732#ifdef BSLS_TIMEINTERVAL_PROVIDES_CHRONO_CONVERSIONS
733 /// Return the value of this time interval as a `std::chrono::duration`
734 /// object. This function participates in overloading if
735 /// `DURATION_TYPE` is actually an `std::chrono::duration` instance, and
736 /// if it has *not* a floating point representation. The behavior is
737 /// undefined unless the total number of nanoseconds can be represented
738 /// using a `DURATION_TYPE`. Note that the return value may be
739 /// negative.
740 template <class DURATION_TYPE>
742 typename std::enable_if<
745 DURATION_TYPE>::type
746 asDuration() const;
747#endif
748
749 /// Return the value of this time interval as a real number of seconds.
750 /// Note that the return value may be negative and may have a fractional
751 /// part (representing the nanosecond field of this object). Also note
752 /// that the conversion from the internal representation to a `double`
753 /// may *lose* precision.
754 double totalSecondsAsDouble() const;
755
756 // Aspects
757
758 /// Write the value of this object, using the specified `version`
759 /// format, to the specified output `stream`, and return a reference to
760 /// `stream`. If `stream` is initially invalid, this operation has no
761 /// effect. If `version` is not supported, `stream` is invalidated, but
762 /// otherwise unmodified. Note that `version` is not written to
763 /// `stream`. See the `bslx` package-level documentation for more
764 /// information on BDEX streaming of value-semantic types and
765 /// containers.
766 template <class STREAM>
767 STREAM& bdexStreamOut(STREAM& stream, int version) const;
768
769 /// Write the value of this object to the specified output `stream` in a
770 /// human-readable format, and return a reference providing modifiable
771 /// access to `stream`. Optionally specify an initial indentation
772 /// `level`, whose absolute value is incremented recursively for nested
773 /// objects. If `level` is specified, optionally specify
774 /// `spacesPerLevel`, whose absolute value indicates the number of
775 /// spaces per indentation level for this and all of its nested objects.
776 /// If `level` is negative, suppress indentation of the first line. If
777 /// `spacesPerLevel` is negative, format the entire output on one line,
778 /// suppressing all but the initial indentation (as governed by
779 /// `level`). If `stream` is not valid on entry, this operation has no
780 /// effect. Note that the format is not fully specified, and can change
781 /// without notice.
782 std::ostream& print(std::ostream& stream,
783 int level = 0,
784 int spacesPerLevel = 4) const;
785
786#ifndef BDE_OPENSOURCE_PUBLICATION // pending deprecation
787 // DEPRECATED
788
789 /// @deprecated Use @ref maxSupportedBdexVersion(int) instead.
790 ///
791 /// Return the most current BDEX streaming version number supported by
792 /// this class.
793 static int maxSupportedBdexVersion();
794
795#endif // BDE_OPENSOURCE_PUBLICATION -- pending deprecation
796#ifndef BDE_OMIT_INTERNAL_DEPRECATED // BDE2.22
797
798 /// @deprecated Use @ref maxSupportedBdexVersion(int) instead.
799 ///
800 /// Return the most current BDEX streaming version number supported by
801 /// this class.
802 static int maxSupportedVersion();
803
804 /// @deprecated Use @ref print instead.
805 ///
806 /// Format this time to the specified output `stream`, and return a
807 /// reference to the modifiable `stream`.
808 template <class STREAM>
809 STREAM& streamOut(STREAM& stream) const;
810
811#endif // BDE_OMIT_INTERNAL_DEPRECATED -- BDE2.22
812
813};
814
815// FREE OPERATORS
816
817/// Return a `TimeInterval` value that is the sum of the specified `lhs` and
818/// `rhs` time intervals. The behavior is undefined unless (1) operands of
819/// type `double` can be converted to valid `TimeInterval` objects, and (2)
820/// the resulting time interval can be represented with a 64-bit signed
821/// integer.
823TimeInterval operator+(const TimeInterval& lhs, double rhs);
824TimeInterval operator+(double lhs, const TimeInterval& rhs);
825
826/// Return a `TimeInterval` value that is the difference between the
827/// specified `lhs` and `rhs` time intervals. The behavior is undefined
828/// unless (1) operands of type `double` can be converted to valid
829/// `TimeInterval` objects, (2) the value on the right-hand side
830/// (potentially after conversion to a `TimeInterval`) has a number of
831/// seconds that is not `LLONG_MIN`, and (3) the resulting time interval can
832/// be represented with a 64-bit signed integer.
834TimeInterval operator-(const TimeInterval& lhs, double rhs);
835TimeInterval operator-(double lhs, const TimeInterval& rhs);
836
837/// Return a `TimeInterval` value that is the negative of the specified
838/// `rhs` time interval. The behavior is undefined unless
839/// `LLONG_MIN != rhs.seconds()`.
841
842/// Return `true` if the specified `lhs` and `rhs` time intervals have the
843/// same value, and `false` otherwise. Two time intervals have the same
844/// value if their respective second and nanosecond fields have the same
845/// value. The behavior is undefined unless operands of type `double` can
846/// be converted to valid `TimeInterval` objects.
847bool operator==(const TimeInterval& lhs, const TimeInterval& rhs);
848bool operator==(const TimeInterval& lhs, double rhs);
849bool operator==(double lhs, const TimeInterval& rhs);
850
851/// Return `true` if the specified `lhs` and `rhs` time intervals do not
852/// have the same value, and `false` otherwise. Two time intervals do not
853/// have the same value if their respective second or nanosecond fields
854/// differ in value. The behavior is undefined unless operands of type
855/// `double` can be converted to valid `TimeInterval` objects.
856bool operator!=(const TimeInterval& lhs, const TimeInterval& rhs);
857bool operator!=(const TimeInterval& lhs, double rhs);
858bool operator!=(double lhs, const TimeInterval& rhs);
859
860/// Return `true` if the nominal relation between the specified `lhs` and
861/// `rhs` time interval values holds, and `false` otherwise. The behavior
862/// is undefined unless operands of type `double` can be converted to valid
863/// `TimeInterval` objects.
864bool operator< (const TimeInterval& lhs, const TimeInterval& rhs);
865bool operator< (const TimeInterval& lhs, double rhs);
866bool operator< (double lhs, const TimeInterval& rhs);
867bool operator<=(const TimeInterval& lhs, const TimeInterval& rhs);
868bool operator<=(const TimeInterval& lhs, double rhs);
869bool operator<=(double lhs, const TimeInterval& rhs);
870bool operator> (const TimeInterval& lhs, const TimeInterval& rhs);
871bool operator> (const TimeInterval& lhs, double rhs);
872bool operator> (double lhs, const TimeInterval& rhs);
873bool operator>=(const TimeInterval& lhs, const TimeInterval& rhs);
874bool operator>=(const TimeInterval& lhs, double rhs);
875bool operator>=(double lhs, const TimeInterval& rhs);
876
877/// Write the value of the specified `timeInterval` to the specified output
878/// `stream` in a single-line format, and return a reference providing
879/// modifiable access to `stream`. If `stream` is not valid on entry, this
880/// operation has no effect. Note that this human-readable format is not
881/// fully specified and can change without notice. Also note that this
882/// method has the same behavior as `object.print(stream, 0, -1)`.
883std::ostream& operator<<(std::ostream& stream,
884 const TimeInterval& timeInterval);
885
886#if defined(BSLS_COMPILERFEATURES_SUPPORT_INLINE_NAMESPACE) && \
887 defined(BSLS_COMPILERFEATURES_SUPPORT_USER_DEFINED_LITERALS)
888inline namespace literals {
889inline namespace TimeIntervalLiterals {
890
891/// This user defined literal operator converts the specified `hours` value
892/// to the respective `TimeInterval` value. The behavior is undefined
893/// unless the specified number of hours can be converted to valid
894/// `TimeInterval` object. (See the
895/// "User-Defined Literals" section in the component-level documentation.)
897TimeInterval operator ""_h( unsigned long long int hours);
898
899/// This user defined literal operator converts the specified `minutes`
900/// value to the respective `TimeInterval` value. The behavior is undefined
901/// unless the specified number of minutes can be converted to valid
902/// `TimeInterval` object. (See the
903/// "User-Defined Literals" section in the component-level documentation.)
905TimeInterval operator ""_min(unsigned long long int minutes);
906
907/// This user defined literal operator converts the specified `seconds`
908/// value to the respective `TimeInterval` value. The behavior is undefined
909/// unless the specified number of seconds can be converted to valid
910/// `TimeInterval` object. (See the
911/// "User-Defined Literals" section in the component-level documentation.)
913TimeInterval operator ""_s( unsigned long long int seconds);
914
915/// This user defined literal operator converts the specified `milliseconds`
916/// value to the respective `TimeInterval` value. (See the
917/// "User-Defined Literals" section in the component-level documentation.)
919TimeInterval operator ""_ms( unsigned long long int milliseconds);
920
921/// This user defined literal operator converts the specified `microseconds`
922/// value to the respective `TimeInterval` value. (See the
923/// "User-Defined Literals" section in the component-level documentation.)
925TimeInterval operator ""_us( unsigned long long int microseconds);
926
927/// This user defined literal operator converts the specified `nanoseconds`
928/// value to the respective `TimeInterval` value. (See the
929/// "User-Defined Literals" section in the component-level documentation.)
931TimeInterval operator ""_ns( unsigned long long int nanoseconds);
932
933} // close TimeIntervalLiterals namespace
934} // close literals namespace
935#endif // BSLS_COMPILERFEATURES_SUPPORT_INLINE_NAMESPACE &&
936 // BSLS_COMPILERFEATURES_SUPPORT_USER_DEFINED_LITERALS
937
938// ============================================================================
939// INLINE DEFINITIONS
940// ============================================================================
941
942 // ------------------
943 // class TimeInterval
944 // ------------------
945
946// PRIVATE CLASS METHODS
948bool TimeInterval::isSumValidInt64(bsls::Types::Int64 lhs,
950{
951 // {DRQS 164912552} Sun CC miscomplies this ternary operator when the
952 // function is invoked from the 'TimeInterval' constructor.
953 // return lhs > 0 ? LLONG_MAX - lhs >= rhs : LLONG_MIN - lhs <= rhs;
954 return (lhs > 0 && LLONG_MAX - lhs >= rhs) ||
955 (lhs <= 0 && LLONG_MIN - lhs <= rhs);
956}
957
958// CLASS METHODS
959inline
960int TimeInterval::maxSupportedBdexVersion(int /* versionSelector */)
961{
962 return 1;
963}
964
967 int nanoseconds)
968{
969 return isSumValidInt64(seconds, nanoseconds / k_NANOSECS_PER_SEC);
970}
971
972#ifdef BSLS_TIMEINTERVAL_PROVIDES_CHRONO_CONVERSIONS
973
974template <class REP, class PERIOD>
975bool TimeInterval::isValid(const std::chrono::duration<REP, PERIOD>& duration)
976{
977 std::chrono::duration<long double> minValue =
978 std::chrono::duration<long double>(LLONG_MIN);
979 --minValue;
980 std::chrono::duration<long double> maxValue =
981 std::chrono::duration<long double>(LLONG_MAX);
982 ++maxValue;
983 const std::chrono::duration<long double> safeDuration =
984 std::chrono::duration_cast<std::chrono::duration<long double> >(
985 duration);
986
987 return (safeDuration >= minValue && safeDuration <= maxValue);
988}
989#endif // BSLS_TIMEINTERVAL_PROVIDES_CHRONO_CONVERSIONS
990
991// CREATORS
994: d_seconds(0)
995, d_nanoseconds(0)
996{
997}
998
1001 int nanoseconds)
1002: d_seconds(0)
1003, d_nanoseconds(0)
1004{
1005 // A seemingly redundant initializer list is needed since members must be
1006 // initialized by mem-initializer in 'constexpr' constructor.
1007
1009}
1010
1011#ifdef BSLS_TIMEINTERVAL_PROVIDES_CHRONO_CONVERSIONS
1012template <class REP_TYPE, class PERIOD_TYPE>
1013inline
1016 const std::chrono::duration<REP_TYPE, PERIOD_TYPE>& duration,
1017 typename std::enable_if<TimeInterval_DurationTraits<
1018 REP_TYPE,
1019 PERIOD_TYPE>::k_IMPLICIT_CONVERSION_ENABLED,
1020 int>::type *)
1021{
1022 BSLS_ASSERT((isValid<REP_TYPE, PERIOD_TYPE>(duration)));
1023 using SecondsRatio = std::ratio<1>;
1024 using TimeIntervalSeconds =
1025 std::chrono::duration<bsls::Types::Int64, SecondsRatio>;
1026 using TimeIntervalNanoseconds = std::chrono::duration<int, std::nano>;
1027
1028 const bsls::Types::Int64 k_SECONDS =
1029 std::chrono::duration_cast<TimeIntervalSeconds>(duration).count();
1030 const int k_NANOSECONDS =
1031 std::chrono::duration_cast<TimeIntervalNanoseconds>(
1032 duration - TimeIntervalSeconds(k_SECONDS)).count();
1033 setInterval(k_SECONDS, k_NANOSECONDS);
1034}
1035
1036template <class REP_TYPE, class PERIOD_TYPE>
1037inline
1040 const std::chrono::duration<REP_TYPE, PERIOD_TYPE>& duration,
1041 typename std::enable_if<TimeInterval_DurationTraits<
1042 REP_TYPE,
1043 PERIOD_TYPE>::k_EXPLICIT_CONVERSION_ENABLED,
1044 int>::type *)
1045{
1046 BSLS_ASSERT((isValid<REP_TYPE, PERIOD_TYPE>(duration)));
1047 const bsls::Types::Int64 k_SECONDS =
1048 std::chrono::duration_cast<std::chrono::seconds>(duration).count();
1049 const int k_NANOSECONDS = static_cast<int>(
1050 std::chrono::duration_cast<std::chrono::nanoseconds>(
1051 duration - std::chrono::seconds(k_SECONDS)).count());
1052 setInterval(k_SECONDS, k_NANOSECONDS);
1053}
1054#endif
1055
1056// MANIPULATORS
1057inline
1059{
1060 *this = TimeInterval(rhs);
1061 return *this;
1062}
1063
1064inline
1066{
1067 return addInterval(rhs.d_seconds, rhs.d_nanoseconds);
1068}
1069
1070inline
1072{
1073 *this += TimeInterval(rhs);
1074 return *this;
1075}
1076
1077inline
1079{
1080 BSLS_ASSERT_SAFE(LLONG_MIN < rhs.seconds());
1081
1082 return addInterval(-rhs.d_seconds, -rhs.d_nanoseconds);
1083}
1084
1085inline
1087{
1088 *this -= TimeInterval(rhs);
1089 return *this;
1090}
1091
1092 // Add Operations
1093
1096{
1097 BSLS_ASSERT_SAFE(LLONG_MAX / k_SECONDS_PER_DAY >= days &&
1098 LLONG_MIN / k_SECONDS_PER_DAY <= days);
1099
1100 return addSeconds(days * k_SECONDS_PER_DAY);
1101}
1102
1105{
1106 BSLS_ASSERT_SAFE(LLONG_MAX / k_SECONDS_PER_HOUR >= hours &&
1107 LLONG_MIN / k_SECONDS_PER_HOUR <= hours);
1108
1109 return addSeconds(hours * k_SECONDS_PER_HOUR);
1110}
1111
1114{
1115 BSLS_ASSERT_SAFE(LLONG_MAX / k_SECONDS_PER_MINUTE >= minutes &&
1116 LLONG_MIN / k_SECONDS_PER_MINUTE <= minutes);
1117
1118 return addSeconds(minutes * k_SECONDS_PER_MINUTE);
1119}
1120
1123{
1124 BSLS_ASSERT_SAFE(isSumValidInt64(seconds, d_seconds));
1125
1126 d_seconds += seconds;
1127 if (d_seconds > 0 && d_nanoseconds < 0) {
1128 --d_seconds;
1129 d_nanoseconds += k_NANOSECS_PER_SEC;
1130 }
1131 else if (d_seconds < 0 && d_nanoseconds > 0) {
1132 ++d_seconds;
1133 d_nanoseconds -= k_NANOSECS_PER_SEC;
1134 }
1135
1136 return *this;
1137}
1138
1139inline
1141{
1142 return addInterval( milliseconds / k_MILLISECS_PER_SEC,
1143 static_cast<int>((milliseconds % k_MILLISECS_PER_SEC) *
1144 k_NANOSECS_PER_MILLISEC));
1145}
1146
1147inline
1149{
1150 return addInterval( microseconds / k_MICROSECS_PER_SEC,
1151 static_cast<int>((microseconds % k_MICROSECS_PER_SEC) *
1152 k_NANOSECS_PER_MICROSEC));
1153}
1154
1155inline
1157{
1158 return addInterval( nanoseconds / k_NANOSECS_PER_SEC,
1159 static_cast<int>(nanoseconds % k_NANOSECS_PER_SEC));
1160}
1161
1162 // Set Operations
1163
1166{
1167 BSLS_ASSERT_SAFE(LLONG_MAX / k_SECONDS_PER_DAY >= days &&
1168 LLONG_MIN / k_SECONDS_PER_DAY <= days);
1169
1170 return setTotalSeconds(days * k_SECONDS_PER_DAY);
1171}
1172
1175{
1176 BSLS_ASSERT_SAFE(LLONG_MAX / k_SECONDS_PER_HOUR >= hours &&
1177 LLONG_MIN / k_SECONDS_PER_HOUR <= hours);
1178
1179 return setTotalSeconds(hours * k_SECONDS_PER_HOUR);
1180}
1181
1184{
1185 BSLS_ASSERT_SAFE(LLONG_MAX / k_SECONDS_PER_MINUTE >= minutes &&
1186 LLONG_MIN / k_SECONDS_PER_MINUTE <= minutes);
1187
1188 return setTotalSeconds(minutes * k_SECONDS_PER_MINUTE);
1189}
1190
1193{
1194 d_seconds = seconds;
1195 d_nanoseconds = 0;
1196}
1197
1200{
1201 setInterval( milliseconds / k_MILLISECS_PER_SEC,
1202 static_cast<int>((milliseconds % k_MILLISECS_PER_SEC) *
1203 k_NANOSECS_PER_MILLISEC));
1204}
1205
1208{
1209 setInterval( microseconds / k_MICROSECS_PER_SEC,
1210 static_cast<int>((microseconds % k_MICROSECS_PER_SEC) *
1211 k_NANOSECS_PER_MICROSEC));
1212
1213}
1214
1217{
1218 setInterval( nanoseconds / k_NANOSECS_PER_SEC,
1219 static_cast<int>(nanoseconds % k_NANOSECS_PER_SEC));
1220}
1221
1222#ifdef BSLS_TIMEINTERVAL_PROVIDES_CHRONO_CONVERSIONS
1223template <class REP_TYPE, class PERIOD_TYPE>
1224inline
1227 const std::chrono::duration<REP_TYPE, PERIOD_TYPE>& duration,
1228 typename std::enable_if<TimeInterval_DurationTraits<
1229 REP_TYPE,
1230 PERIOD_TYPE>::k_IMPLICIT_CONVERSION_ENABLED,
1231 int>::type *)
1232{
1233 BSLS_ASSERT((isValid<REP_TYPE, PERIOD_TYPE>(duration)));
1234
1235 const bsls::Types::Int64 k_SECONDS =
1236 std::chrono::duration_cast<std::chrono::seconds>(duration).count();
1237 const int k_NANOSECONDS = static_cast<int>(
1238 std::chrono::duration_cast<std::chrono::nanoseconds>(
1239 duration - std::chrono::seconds(k_SECONDS)).count());
1240 return addInterval(k_SECONDS, k_NANOSECONDS);
1241}
1242#endif
1243
1246 int nanoseconds)
1247{
1251
1252 d_seconds = seconds;
1253 if (nanoseconds >= k_NANOSECS_PER_SEC
1254 || nanoseconds <= -k_NANOSECS_PER_SEC) {
1255 d_seconds += nanoseconds / k_NANOSECS_PER_SEC;
1256 d_nanoseconds = static_cast<int>(nanoseconds % k_NANOSECS_PER_SEC);
1257 }
1258 else {
1259 d_nanoseconds = static_cast<int>(nanoseconds);
1260 }
1261
1262 if (d_seconds > 0 && d_nanoseconds < 0) {
1263 --d_seconds;
1264 d_nanoseconds += k_NANOSECS_PER_SEC;
1265 }
1266 else if (d_seconds < 0 && d_nanoseconds > 0) {
1267 ++d_seconds;
1268 d_nanoseconds -= k_NANOSECS_PER_SEC;
1269 }
1270
1271}
1272
1275 int nanoseconds)
1276{
1277 BSLS_ASSERT_SAFE(-k_NANOSECS_PER_SEC < nanoseconds &&
1278 k_NANOSECS_PER_SEC > nanoseconds);
1279 BSLS_ASSERT_SAFE((seconds >= 0 && nanoseconds >= 0) ||
1280 (seconds <= 0 && nanoseconds <= 0));
1281
1282 d_seconds = seconds;
1283 d_nanoseconds = nanoseconds;
1284}
1285
1286 // Aspects
1287
1288template <class STREAM>
1289STREAM& TimeInterval::bdexStreamIn(STREAM& stream, int version)
1290{
1291 if (stream) {
1292 switch (version) { // switch on the schema version
1293 case 1: {
1295 int nanoseconds;
1296 stream.getInt64(seconds);
1297 stream.getInt32(nanoseconds);
1298
1299 if (stream && ( (seconds >= 0 && nanoseconds >= 0)
1300 || (seconds <= 0 && nanoseconds <= 0))
1301 && nanoseconds > -k_NANOSECS_PER_SEC
1302 && nanoseconds < k_NANOSECS_PER_SEC) {
1303 d_seconds = seconds;
1304 d_nanoseconds = nanoseconds;
1305 }
1306 else {
1307 stream.invalidate();
1308 }
1309 } break;
1310 default: {
1311 stream.invalidate(); // unrecognized version number
1312 }
1313 }
1314 }
1315 return stream;
1316}
1317
1318// ACCESSORS
1319#ifdef BSLS_TIMEINTERVAL_PROVIDES_CHRONO_CONVERSIONS
1320template <class DURATION_TYPE>
1322 typename std::enable_if<TimeInterval_IsDuration<DURATION_TYPE>::value,
1323 int>::type *) const
1324{
1325 using SecondsRatio = std::ratio<1>;
1326 using TimeIntervalSeconds =
1327 std::chrono::duration<bsls::Types::Int64, SecondsRatio>;
1328 using TimeIntervalNanoseconds = std::chrono::duration<int, std::nano>;
1329 using Period = typename DURATION_TYPE::period;
1330 using LongDoubleTo = std::chrono::duration<long double, Period>;
1331
1332 const LongDoubleTo MIN_VALUE =
1333 std::chrono::duration_cast<LongDoubleTo>(DURATION_TYPE::min());
1334
1335 const LongDoubleTo MAX_VALUE =
1336 std::chrono::duration_cast<LongDoubleTo>(DURATION_TYPE::max());
1337
1338 const LongDoubleTo value = std::chrono::duration_cast<LongDoubleTo>(
1339 TimeIntervalSeconds(seconds()))
1340 + std::chrono::duration_cast<LongDoubleTo>(
1341 TimeIntervalNanoseconds(nanoseconds()));
1342
1343 return (MIN_VALUE <= value && value <= MAX_VALUE);
1344}
1345#endif // BSLS_TIMEINTERVAL_PROVIDES_CHRONO_CONVERSIONS
1346
1349{
1350 return d_nanoseconds;
1351}
1352
1355{
1356 return d_seconds;
1357}
1358
1361{
1362 return d_seconds / k_SECONDS_PER_DAY;
1363}
1364
1367{
1368 return d_seconds / k_SECONDS_PER_HOUR;
1369}
1370
1373{
1374 return d_seconds / k_SECONDS_PER_MINUTE;
1375}
1376
1379{
1380 return d_seconds;
1381}
1382
1385{
1386 BSLS_ASSERT_SAFE(LLONG_MAX / k_MILLISECS_PER_SEC >= d_seconds &&
1387 LLONG_MIN / k_MILLISECS_PER_SEC <= d_seconds);
1388 BSLS_ASSERT_SAFE(isSumValidInt64(d_seconds * k_MILLISECS_PER_SEC,
1389 d_nanoseconds / k_NANOSECS_PER_MILLISEC));
1390
1391
1392 return d_seconds * k_MILLISECS_PER_SEC
1393 + d_nanoseconds / k_NANOSECS_PER_MILLISEC;
1394}
1395
1398{
1399 BSLS_ASSERT_SAFE(LLONG_MAX / k_MICROSECS_PER_SEC >= d_seconds &&
1400 LLONG_MIN / k_MICROSECS_PER_SEC <= d_seconds);
1401 BSLS_ASSERT_SAFE(isSumValidInt64(d_seconds * k_MICROSECS_PER_SEC,
1402 d_nanoseconds / k_NANOSECS_PER_MICROSEC));
1403
1404 return d_seconds * k_MICROSECS_PER_SEC
1405 + d_nanoseconds / k_NANOSECS_PER_MICROSEC;
1406}
1407
1410{
1411 BSLS_ASSERT_SAFE(LLONG_MAX / k_NANOSECS_PER_SEC >= d_seconds &&
1412 LLONG_MIN / k_NANOSECS_PER_SEC <= d_seconds);
1413 BSLS_ASSERT_SAFE(isSumValidInt64(d_seconds * k_NANOSECS_PER_SEC,
1414 d_nanoseconds));
1415
1416 return d_seconds * k_NANOSECS_PER_SEC + d_nanoseconds;
1417}
1418
1419#ifdef BSLS_TIMEINTERVAL_PROVIDES_CHRONO_CONVERSIONS
1420template <class DURATION_TYPE>
1421inline
1423typename std::enable_if<
1426 DURATION_TYPE>::type
1428{
1429 using SecondsRatio = std::ratio<1>;
1430 using TimeIntervalSeconds =
1431 std::chrono::duration<bsls::Types::Int64, SecondsRatio>;
1432 using TimeIntervalNanoseconds = std::chrono::duration<int, std::nano>;
1433
1434 BSLS_ASSERT(isInDurationRange<DURATION_TYPE>());
1435
1436 return (std::chrono::duration_cast<DURATION_TYPE>(TimeIntervalSeconds(
1437 d_seconds))
1438 + std::chrono::duration_cast<DURATION_TYPE>(TimeIntervalNanoseconds(
1439 d_nanoseconds)));
1440}
1441#endif
1442
1443inline
1445{
1446 return static_cast<double>(d_seconds) + d_nanoseconds /
1447 static_cast<double>(k_NANOSECS_PER_SEC);
1448}
1449
1450 // Aspects
1451
1452template <class STREAM>
1453STREAM& TimeInterval::bdexStreamOut(STREAM& stream, int version) const
1454{
1455 if (stream) {
1456 switch (version) { // switch on the schema version
1457 case 1: {
1458 stream.putInt64(d_seconds);
1459 stream.putInt32(d_nanoseconds);
1460 } break;
1461 default: {
1462 stream.invalidate(); // unrecognized version number
1463 }
1464 }
1465 }
1466 return stream;
1467}
1468
1469
1470#ifndef BDE_OPENSOURCE_PUBLICATION // pending deprecation
1471
1472// DEPRECATED METHODS
1473inline
1478
1479#endif // BDE_OPENSOURCE_PUBLICATION -- pending deprecation
1480#ifndef BDE_OMIT_INTERNAL_DEPRECATED // BDE2.22
1481inline
1486
1487template <class STREAM>
1488inline
1489STREAM& TimeInterval::streamOut(STREAM& stream) const
1490{
1491 return print(stream, 0, -1);
1492}
1493
1494#endif // BDE_OMIT_INTERNAL_DEPRECATED -- BDE2.22
1495
1496} // close package namespace
1497
1498// FREE OPERATORS
1499inline
1500bsls::TimeInterval bsls::operator+(const TimeInterval& lhs,
1501 const TimeInterval& rhs)
1502{
1503 TimeInterval result(lhs);
1504 return result.addInterval(rhs.seconds(), rhs.nanoseconds());
1505}
1506
1507inline
1508bsls::TimeInterval bsls::operator+(const TimeInterval& lhs, double rhs)
1509{
1510 return lhs + TimeInterval(rhs);
1511}
1512
1513inline
1514bsls::TimeInterval bsls::operator+(double lhs, const TimeInterval& rhs)
1515{
1516 return TimeInterval(lhs) + rhs;
1517}
1518
1519inline
1520bsls::TimeInterval bsls::operator-(const TimeInterval& lhs,
1521 const TimeInterval& rhs)
1522
1523{
1524 BSLS_ASSERT_SAFE(LLONG_MIN != rhs.seconds());
1525
1526 TimeInterval result(lhs);
1527 result.addInterval(-rhs.seconds(), -rhs.nanoseconds());
1528 return result;
1529}
1530
1531inline
1532bsls::TimeInterval bsls::operator-(const TimeInterval& lhs, double rhs)
1533{
1534 return lhs - TimeInterval(rhs);
1535}
1536
1537inline
1538bsls::TimeInterval bsls::operator-(double lhs, const TimeInterval& rhs)
1539{
1540 return TimeInterval(lhs) - rhs;
1541}
1542
1543inline
1544bsls::TimeInterval bsls::operator-(const TimeInterval& rhs)
1545{
1546 BSLS_ASSERT_SAFE(LLONG_MIN != rhs.seconds());
1547
1548 return TimeInterval(-rhs.seconds(), -rhs.nanoseconds());
1549}
1550
1551inline
1552bool bsls::operator==(const TimeInterval& lhs, const TimeInterval& rhs)
1553{
1554 return lhs.seconds() == rhs.seconds()
1555 && lhs.nanoseconds() == rhs.nanoseconds();
1556}
1557
1558inline
1559bool bsls::operator==(const TimeInterval& lhs, double rhs)
1560{
1561 return lhs == TimeInterval(rhs);
1562}
1563
1564inline
1565bool bsls::operator==(double lhs, const TimeInterval& rhs)
1566{
1567 return TimeInterval(lhs) == rhs;
1568}
1569
1570inline
1571bool bsls::operator!=(const TimeInterval& lhs, const TimeInterval& rhs)
1572{
1573 return lhs.seconds() != rhs.seconds()
1574 || lhs.nanoseconds() != rhs.nanoseconds();
1575}
1576
1577inline
1578bool bsls::operator!=(const TimeInterval& lhs, double rhs)
1579{
1580 return lhs != TimeInterval(rhs);
1581}
1582
1583inline
1584bool bsls::operator!=(double lhs, const TimeInterval& rhs)
1585{
1586 return TimeInterval(lhs) != rhs;
1587}
1588
1589inline
1590bool bsls::operator< (const TimeInterval& lhs, const TimeInterval& rhs)
1591{
1592 return lhs.seconds() < rhs.seconds()
1593 || (lhs.seconds() == rhs.seconds()
1594 && lhs.nanoseconds() < rhs.nanoseconds());
1595}
1596
1597inline
1598bool bsls::operator< (const TimeInterval& lhs, double rhs)
1599{
1600 return lhs < TimeInterval(rhs);
1601}
1602
1603inline
1604bool bsls::operator< (double lhs, const TimeInterval& rhs)
1605{
1606 return TimeInterval(lhs) < rhs;
1607}
1608
1609inline
1610bool bsls::operator<=(const TimeInterval& lhs, const TimeInterval& rhs)
1611{
1612 return lhs.seconds() < rhs.seconds()
1613 || (lhs.seconds() == rhs.seconds()
1614 && lhs.nanoseconds() <= rhs.nanoseconds());
1615}
1616
1617inline
1618bool bsls::operator<=(const TimeInterval& lhs, double rhs)
1619{
1620 return lhs <= TimeInterval(rhs);
1621}
1622
1623inline
1624bool bsls::operator<=(double lhs, const TimeInterval& rhs)
1625{
1626 return TimeInterval(lhs) <= rhs;
1627}
1628
1629inline
1630bool bsls::operator> (const TimeInterval& lhs, const TimeInterval& rhs)
1631{
1632 return lhs.seconds() > rhs.seconds()
1633 || (lhs.seconds() == rhs.seconds()
1634 && lhs.nanoseconds() > rhs.nanoseconds());
1635}
1636
1637inline
1638bool bsls::operator> (const TimeInterval& lhs, double rhs)
1639{
1640 return lhs > TimeInterval(rhs);
1641}
1642
1643inline
1644bool bsls::operator> (double lhs, const TimeInterval& rhs)
1645{
1646 return TimeInterval(lhs) > rhs;
1647}
1648
1649inline
1650bool bsls::operator>=(const TimeInterval& lhs, const TimeInterval& rhs)
1651{
1652 return lhs.seconds() > rhs.seconds()
1653 || (lhs.seconds() == rhs.seconds()
1654 && lhs.nanoseconds() >= rhs.nanoseconds());
1655}
1656
1657inline
1658bool bsls::operator>=(const TimeInterval& lhs, double rhs)
1659{
1660 return lhs >= TimeInterval(rhs);
1661}
1662
1663inline
1664bool bsls::operator>=(double lhs, const TimeInterval& rhs)
1665{
1666 return TimeInterval(lhs) >= rhs;
1667}
1668
1669#if defined(BSLS_COMPILERFEATURES_SUPPORT_INLINE_NAMESPACE) && \
1670 defined(BSLS_COMPILERFEATURES_SUPPORT_USER_DEFINED_LITERALS)
1671
1673bsls::TimeInterval bsls::TimeIntervalLiterals::operator"" _h(
1674 unsigned long long int hours)
1675{
1676 BSLS_ASSERT((LLONG_MAX/3600) >= hours);
1677 return TimeInterval(static_cast<bsls::Types::Int64>(hours*3600), 0);
1678}
1679
1681bsls::TimeInterval bsls::TimeIntervalLiterals::operator"" _min(
1682 unsigned long long int minutes)
1683{
1684 BSLS_ASSERT((LLONG_MAX/60) >= minutes);
1685 return TimeInterval(static_cast<bsls::Types::Int64>(minutes*60), 0);
1686}
1687
1689bsls::TimeInterval bsls::TimeIntervalLiterals::operator"" _s(
1690 unsigned long long int seconds)
1691{
1692 BSLS_ASSERT(LLONG_MAX > seconds);
1693 return TimeInterval(static_cast<bsls::Types::Int64>(seconds), 0);
1694}
1695
1697bsls::TimeInterval bsls::TimeIntervalLiterals::operator"" _ms(
1698 unsigned long long int milliseconds)
1699{
1700 const bsls::Types::Int64 k_MILLISECS_PER_SEC = 1000;
1701 const bsls::Types::Int64 k_NANOSECS_PER_MILLISEC = 1000000;
1702
1703 return TimeInterval(milliseconds / k_MILLISECS_PER_SEC,
1704 static_cast<int>((milliseconds % k_MILLISECS_PER_SEC) *
1705 k_NANOSECS_PER_MILLISEC));
1706}
1707
1709bsls::TimeInterval bsls::TimeIntervalLiterals::operator"" _us(
1710 unsigned long long int microseconds)
1711{
1712 const bsls::Types::Int64 k_MICROSECS_PER_SEC = 1000000;
1713 const bsls::Types::Int64 k_NANOSECS_PER_MICROSEC = 1000;
1714
1715 return TimeInterval(microseconds / k_MICROSECS_PER_SEC,
1716 static_cast<int>((microseconds % k_MICROSECS_PER_SEC) *
1717 k_NANOSECS_PER_MICROSEC));
1718}
1719
1721bsls::TimeInterval bsls::TimeIntervalLiterals::operator"" _ns(
1722 unsigned long long int nanoseconds)
1723{
1724 const bsls::Types::Int64 k_NANOSECS_PER_SEC = 1000000000;
1725
1726 return TimeInterval(nanoseconds / k_NANOSECS_PER_SEC,
1727 static_cast<int>(nanoseconds % k_NANOSECS_PER_SEC));
1728}
1729
1730#endif // BSLS_COMPILERFEATURES_SUPPORT_INLINE_NAMESPACE &&
1731 // BSLS_COMPILERFEATURES_SUPPORT_USER_DEFINED_LITERALS
1732
1733// BDE_VERIFY pragma: pop
1734
1735// IMPLEMENTATION NOTE: A 'is_trivially_copyable' trait declaration has been
1736// moved to 'bslmf_istriviallycopyable.h' to work around issues on the Sun CC
1737// 5.13 compiler. We had previously forward declared
1738// 'bsl::is_trivially_copyable' and specialized it for 'TimeInterval' here (see
1739// the 2.24 release tags).
1740//..
1741// namespace bsl {
1742// template <>
1743// struct is_trivially_copyable<BloombergLP::bsls::TimeInterval> :
1744// bsl::true_type {
1745// // This template specialization for 'is_trivially_copyable' indicates
1746// // that 'Date' is a trivially copyable type.
1747// };
1748// }
1749//..
1750
1751
1752
1753#undef BSLS_TIMEINTERVAL_PROVIDES_CHRONO_CONVERSIONS
1754
1755#endif
1756
1757// ----------------------------------------------------------------------------
1758// Copyright 2020 Bloomberg Finance L.P.
1759//
1760// Licensed under the Apache License, Version 2.0 (the "License");
1761// you may not use this file except in compliance with the License.
1762// You may obtain a copy of the License at
1763//
1764// http://www.apache.org/licenses/LICENSE-2.0
1765//
1766// Unless required by applicable law or agreed to in writing, software
1767// distributed under the License is distributed on an "AS IS" BASIS,
1768// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1769// See the License for the specific language governing permissions and
1770// limitations under the License.
1771// ----------------------------- END-OF-FILE ----------------------------------
1772
1773/** @} */
1774/** @} */
1775/** @} */
Definition bsls_timeinterval.h:301
BSLS_KEYWORD_CONSTEXPR bsls::Types::Int64 totalMinutes() const
Definition bsls_timeinterval.h:1372
BSLS_KEYWORD_CONSTEXPR TimeInterval()
Definition bsls_timeinterval.h:993
BSLS_KEYWORD_CONSTEXPR_CPP14 void setTotalHours(bsls::Types::Int64 hours)
Definition bsls_timeinterval.h:1174
TimeInterval & addMicroseconds(bsls::Types::Int64 microseconds)
Definition bsls_timeinterval.h:1148
BSLS_KEYWORD_CONSTEXPR_CPP14 void setTotalDays(bsls::Types::Int64 days)
Definition bsls_timeinterval.h:1165
BSLS_KEYWORD_CONSTEXPR int nanoseconds() const
Definition bsls_timeinterval.h:1348
~TimeInterval()=default
TimeInterval & operator-=(const TimeInterval &rhs)
Definition bsls_timeinterval.h:1078
TimeInterval & addNanoseconds(bsls::Types::Int64 nanoseconds)
Definition bsls_timeinterval.h:1156
BSLS_KEYWORD_CONSTEXPR_CPP14 std::enable_if< TimeInterval_IsDuration< DURATION_TYPE >::value &&!TimeInterval_RepTraits< typenameDURATION_TYPE::rep >::k_IS_FLOAT, DURATION_TYPE >::type asDuration() const
Definition bsls_timeinterval.h:1427
TimeInterval & addInterval(bsls::Types::Int64 seconds, int nanoseconds=0)
BSLS_KEYWORD_CONSTEXPR_CPP14 void setTotalNanoseconds(bsls::Types::Int64 nanoseconds)
Definition bsls_timeinterval.h:1216
BSLS_KEYWORD_CONSTEXPR_CPP14 void setTotalSeconds(bsls::Types::Int64 seconds)
Definition bsls_timeinterval.h:1192
BSLS_KEYWORD_CONSTEXPR bsls::Types::Int64 totalSeconds() const
Definition bsls_timeinterval.h:1378
TimeInterval & operator=(const TimeInterval &rhs)=default
TimeInterval & addMilliseconds(bsls::Types::Int64 milliseconds)
Definition bsls_timeinterval.h:1140
STREAM & bdexStreamIn(STREAM &stream, int version)
Definition bsls_timeinterval.h:1289
BSLS_KEYWORD_CONSTEXPR_CPP14 void setTotalMinutes(bsls::Types::Int64 minutes)
Definition bsls_timeinterval.h:1183
BSLS_KEYWORD_CONSTEXPR_CPP14 TimeInterval & addHours(bsls::Types::Int64 hours)
Definition bsls_timeinterval.h:1104
BSLS_KEYWORD_CONSTEXPR_CPP14 void setTotalMilliseconds(bsls::Types::Int64 milliseconds)
Definition bsls_timeinterval.h:1199
TimeInterval & operator+=(const TimeInterval &rhs)
Definition bsls_timeinterval.h:1065
BSLS_KEYWORD_CONSTEXPR_CPP14 bsls::Types::Int64 totalMicroseconds() const
Definition bsls_timeinterval.h:1397
bool isInDurationRange(typename std::enable_if< TimeInterval_IsDuration< DURATION_TYPE >::value, int >::type *=0) const
Definition bsls_timeinterval.h:1321
BSLS_KEYWORD_CONSTEXPR_CPP14 TimeInterval & addDuration(const std::chrono::duration< REP_TYPE, PERIOD_TYPE > &duration, typename std::enable_if< TimeInterval_DurationTraits< REP_TYPE, PERIOD_TYPE >::k_IMPLICIT_CONVERSION_ENABLED, int >::type *=0)
Definition bsls_timeinterval.h:1226
static BSLS_KEYWORD_CONSTEXPR bool isValid(bsls::Types::Int64 seconds, int nanoseconds)
Definition bsls_timeinterval.h:966
double totalSecondsAsDouble() const
Definition bsls_timeinterval.h:1444
STREAM & streamOut(STREAM &stream) const
Definition bsls_timeinterval.h:1489
STREAM & bdexStreamOut(STREAM &stream, int version) const
Definition bsls_timeinterval.h:1453
std::ostream & print(std::ostream &stream, int level=0, int spacesPerLevel=4) const
BSLS_KEYWORD_CONSTEXPR_CPP14 void setIntervalRaw(bsls::Types::Int64 seconds, int nanoseconds=0)
Definition bsls_timeinterval.h:1274
TimeInterval(double seconds)
static int maxSupportedBdexVersion()
Definition bsls_timeinterval.h:1474
BSLS_KEYWORD_CONSTEXPR_CPP14 bsls::Types::Int64 totalNanoseconds() const
Definition bsls_timeinterval.h:1409
BSLS_KEYWORD_CONSTEXPR bsls::Types::Int64 totalDays() const
Definition bsls_timeinterval.h:1360
BSLS_KEYWORD_CONSTEXPR bsls::Types::Int64 seconds() const
Definition bsls_timeinterval.h:1354
BSLS_KEYWORD_CONSTEXPR bsls::Types::Int64 totalHours() const
Definition bsls_timeinterval.h:1366
TimeInterval(const TimeInterval &original)=default
BSLS_KEYWORD_CONSTEXPR_CPP14 TimeInterval & addSeconds(bsls::Types::Int64 seconds)
Definition bsls_timeinterval.h:1122
BSLS_KEYWORD_CONSTEXPR_CPP14 TimeInterval & addMinutes(bsls::Types::Int64 minutes)
Definition bsls_timeinterval.h:1113
static int maxSupportedVersion()
Definition bsls_timeinterval.h:1482
BSLS_KEYWORD_CONSTEXPR_CPP14 bsls::Types::Int64 totalMilliseconds() const
Definition bsls_timeinterval.h:1384
BSLS_KEYWORD_CONSTEXPR_CPP14 TimeInterval & addDays(bsls::Types::Int64 days)
Definition bsls_timeinterval.h:1095
BSLS_KEYWORD_CONSTEXPR_CPP14 void setTotalMicroseconds(bsls::Types::Int64 microseconds)
Definition bsls_timeinterval.h:1207
BSLS_KEYWORD_CONSTEXPR_CPP14 void setInterval(bsls::Types::Int64 seconds, int nanoseconds=0)
Definition bsls_timeinterval.h:1245
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_KEYWORD_CONSTEXPR_CPP14
Definition bsls_keyword.h:595
#define BSLS_KEYWORD_CONSTEXPR
Definition bsls_keyword.h:588
#define BSLS_PRECONDITIONS_END()
Definition bsls_preconditions.h:131
#define BSLS_PRECONDITIONS_BEGIN()
Definition bsls_preconditions.h:130
Definition bdlt_iso8601util.h:691
TimeInterval operator+(const TimeInterval &lhs, const TimeInterval &rhs)
bool operator>=(const TimeInterval &lhs, const TimeInterval &rhs)
TimeInterval operator-(const TimeInterval &lhs, const TimeInterval &rhs)
bool operator==(const TimeInterval &lhs, const TimeInterval &rhs)
bool operator>(const TimeInterval &lhs, const TimeInterval &rhs)
bool operator!=(const TimeInterval &lhs, const TimeInterval &rhs)
bool operator<=(const TimeInterval &lhs, const TimeInterval &rhs)
std::ostream & operator<<(std::ostream &stream, const TimeInterval &timeInterval)
bool operator<(const TimeInterval &lhs, const TimeInterval &rhs)
Definition bdldfp_decimal.h:5188
Definition bsls_timeinterval.h:250
static const bool k_IMPLICIT_CONVERSION_ENABLED
Definition bsls_timeinterval.h:273
static const bool k_EXPLICIT_CONVERSION_ENABLED
Definition bsls_timeinterval.h:284
static const bool k_IS_IMPLICIT
Definition bsls_timeinterval.h:263
static const bool k_IS_FLOAT
Definition bsls_timeinterval.h:257
Definition bsls_timeinterval.h:206
Definition bsls_timeinterval.h:222
static const bool k_IS_FLOAT
Definition bsls_timeinterval.h:224
long long Int64
Definition bsls_types.h:132