BDE 4.14.0 Production release
|
Provide a type describing local time over a time period.
This component provides a single, complex-constrained (value-semantic) attribute class, baltzo::LocalTimePeriod
, that describes a period of time over which a local time description (UTC offset, DST status, and a descriptive string) is in effect.
localTimeDescriptor
: a description of local time that applies during the interval defined by startUtcTime
and endUtcTime
.utcStartTime
: UTC representation of the start of the time interval over which localTimeDescriptor
applies.utcEndTime
: UTC representation of the moment immediately after the end of the time interval over which localTimeDescriptor
applies.For example, in New York in 2010, the local time was Eastern Daylight Time ("EDT") from March 14, 2010 to November 7, 2010, and during Eastern Daylight Time, Daylight-Saving Time (DST) was in effect, and the offset from UTC was -4 hours. We can represent this information using a baltzo::LocalTimePeriod
object whose utcStartTime
is "Mar 14, 2010 07:00
UTC" (2AM EST), utcEndTime
is "Nov 7, 2010 06:00 UTC" (1AM EST, what would have been 2AM EDT), and localTimeDescriptor
has a description
of "EDT", dstInEffectFlag
of true
, and a utcOffsetInSeconds
of -14,400 (-4 * 60 * 60).
This section illustrates intended use of this component.
In this example we illustrate how to use a local time period to convert a UTC time to the corresponding local time in some time zone.
First, we define a function that performs a conversion from UTC time to local time:
Then, we create a baltzo::LocalTimePeriod
object, edt2010
, that describes New York Daylight-Saving Time in 2010:
Next, we create a bdlt::Datetime
, utcDatetime
, representing the (UTC) time "Jul 20, 2010 11:00":
Now, we use the convertUtcToLocalTime
function we defined earlier to convert utcDatetime
into its local time in Eastern Daylight Time (as described by edt2010
):
Finally, we verify that the result corresponds to the expected local time in New York, "Jul 20, 2010 7:00":