BDE 4.14.0 Production release
|
Provide a test implementation of the baltzo::Loader
protocol.
baltzo::Loader
protocolThis component provides baltzo::TestLoader
, a concrete test implementation of the baltzo::Loader
protocol for loading a baltzo::Zoneinfo
object. The following inheritance hierarchy diagram shows the classes involved and their methods:
This test implementation maintains a mapping of time-zone identifiers to baltzo::Zoneinfo
objects. Clients can associate a time-zone object with a time-zone identifier using the setTimeZone
method. A subsequent call to the protocol method loadTimeZone
for that time-zone identifier will return the supplied baltzo::Zoneinfo
object.
The following examples demonstrate how to populate a baltzo::TestLoader
with time.zone information, and then access that information through the baltzo::Loader
protocol.
We start by creating a baltzo::Zoneinfo
object, which we will eventually populate with a subset of data for "America/New_York":
Next, we populate newYorkTimeZone
with the correct time-zone identifier and two types of local time (standard time, and daylight-saving time):
Then, we create a series of transitions between these local time descriptors for the years 2007-2011. Note that the United States transitions to daylight saving time on the second Sunday in March, at 2am local time (7am UTC), and transitions back to standard time on the first Sunday in November at 2am local time (6am UTC). Also note, that these rules for generating transitions was different prior to 2007, and may be changed at some point in the future.
Now, having created values representing the daylight saving time transitions (in UTC), we insert the transitions into the baltzo::Zoneinfo
object newYorkTimeZone
:
Now, we create a baltzo::TestLoader
object and configure it with newYorkTimeZone
, which the test loader will associate with the identifier newYorkTimeZone.identifier()
(whose value is "America/New_York"):
In the next example, we will use the baltzo::TestLoader
we initialized in the preceding example, to load time-zone information for New York via the baltzo::Loader
protocol.
We start by creating a baltzo::Loader
reference to testLoader
:
Now we used the protocol method loadTimeZone
to load time-zone information for New York:
Finally, we verify that the returned time-zone information, resultNewYork
, is equivalent to newYorkTimeZone
, which we we used to configure testLoader
: