|
BDE 4.14.0 Production release
|
Provide an attribute class for time-zone-aware datetime values.
This component provides a single, unconstrained (value-semantic) attribute class, baltzo::LocalDatetime, that is used to encapsulate a date, time, offset from UTC (Coordinated Universal Time), and a time zone (string) identifier. The date, time, and offset from UTC are contained within a bdlt::DatetimeTz object, which together represents a wall-clock time in a given time zone. This component differs from bdlt_datetimetz in that it provides, as part of the value, a string identifier for the corresponding time zone.
datetimeTz: date, time, and offset from UTC of the local time.timeZoneId: unique identifier representing the local time zone.For example, in New York on January 1, 2011, at 10 a.m. the local offset from UTC is -5 hours, and a standard time zone identifier for New York is "America/New_York". We can represent this information using a baltzo::LocalDatetime object whose datetimeTz attribute is "01JAN2011_10:00:00.000-0005" and whose timeZoneId attribute is "America/New_York".
Note that it is up to the user to ensure that the datetimeTz and timeZoneId attributes are consistent as the baltzo::LocalDatetime object itself does not maintain any invariants with respect to their values.
This section illustrates intended use of this component.
First, we default-construct a baltzo::LocalDatetime object:
Next, we update the time referred to by localDatetime to the New York time "December 25, 2009, 11:00" with the time-zone identifier set to "America/New_York":
Now, we change the time-zone identifier to another string, for example "Europe/Berlin":
Finally, we stream localDatetime to bsl::cout:
This statement produces the following output on stdout: