|
BDE 4.14.0 Production release
|
Provide non-primitive operations on bdlt::DatetimeInterval.
bdlt::DatetimeIntervalThis component provides non-primitive operations on bdlt::DatetimeInterval objects. In particular, bdlt::DatetimeIntervalUtil supplies factory methods for bdlt::DatetimeInterval objects.
This utility component provides the following (static) methods:
This section illustrates intended use of this component.
This example shows how we can create a bdlt::DatetimeInterval objects having values of 1 day, 2 hours, 3 minutes, 4 seconds, 5 millisecond, and 6 microseconds by using the bdlt::DatetimeInterval constructor and, more readably, by using the make* functions.
First, start with a default (0) bdlt::DatetimeInterval:
Next, add 1 day to it, and assert that both objects are equal:
Then, add 2 hours to it, and assert that both objects are equal:
Next, add 3 minutes to it, and assert that both objects are equal:
Then, add 4 seconds to it, and assert that both objects are equal:
Next, add 5 milliseconds to it, and assert that both objects are equal:
Then, add 6 microseconds to it, and assert that both objects are equal:
Finally, we create an create a DatetimeInterval with the final value and compare to the objects built in steps:
This example shows how we can create a bdlt::Datetime objects having a value of now + 2 hours and 30 minutes by using the bdlt::DatetimeInterval constructor and, more readably, by using the make* functions.
First, create a bdlt::Datetime object having the current time:
Now, create the bdlt::DatetimeInterval objects and assign the desired values to them using the makeHours and makeMinutes functions, and using the bdlt::DatetimeInterval constructor:
Finally, assert that both results are equal: