]>
git.saurik.com Git - apple/icu.git/blob - icuSources/samples/datefmt/answers/main_1.cpp
1 /********************************************************************
3 * Copyright (c) 1999-2002, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
7 #include "unicode/unistr.h"
8 #include "unicode/calendar.h"
9 #include "unicode/datefmt.h"
15 * If the ID supplied to TimeZone is not a valid system ID,
16 * TimeZone::createTimeZone() will return a GMT zone object. In order
17 * to detect this error, we check the ID of the returned zone against
18 * the ID we requested. If they don't match, we fail with an error.
20 TimeZone
* createZone(const UnicodeString
& id
) {
22 TimeZone
* zone
= TimeZone::createTimeZone(id
);
23 if (zone
->getID(str
) != id
) {
25 printf("Error: TimeZone::createTimeZone(");
27 printf(") returned zone with ID ");
35 int main(int argc
, char **argv
) {
37 UErrorCode status
= U_ZERO_ERROR
;
40 // The languages in which we will display the date
41 static char* LANGUAGE
[] = {
44 static const int32_t N_LANGUAGE
= sizeof(LANGUAGE
)/sizeof(LANGUAGE
[0]);
46 // The time zones in which we will display the time
47 static char* TIMEZONE
[] = {
48 "America/Los_Angeles",
53 static const int32_t N_TIMEZONE
= sizeof(TIMEZONE
)/sizeof(TIMEZONE
[0]);
55 for (int32_t i
=0; i
<N_LANGUAGE
; ++i
) {
56 Locale
loc(LANGUAGE
[i
]);
58 // Display the formatted date string
59 printf("Date (%s)\n", LANGUAGE
[i
]);
62 printf("Exiting successfully\n");