1/********************************************************************
2 * COPYRIGHT:
3 * Copyright (c) 1999-2002, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
6
7#include "unicode/unistr.h"
8#include "unicode/calendar.h"
9#include "unicode/datefmt.h"
10#include <stdio.h>
11#include <stdlib.h>
12#include "util.h"
13
14/**
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.
19 */
20TimeZone* createZone(const UnicodeString& id) {
21    UnicodeString str;
22    TimeZone* zone = TimeZone::createTimeZone(id);
23    if (zone->getID(str) != id) {
24        delete zone;
25        printf("Error: TimeZone::createTimeZone(");
26        uprintf(id);
27        printf(") returned zone with ID ");
28        uprintf(str);
29        printf("\n");
30        exit(1);
31    }
32    return zone;
33}
34
35int main(int argc, char **argv) {
36
37    UErrorCode status = U_ZERO_ERROR;
38    UnicodeString str;
39
40    // The languages in which we will display the date
41    static char* LANGUAGE[] = {
42        "en", "de", "fr"
43    };
44    static const int32_t N_LANGUAGE = sizeof(LANGUAGE)/sizeof(LANGUAGE[0]);
45
46    // The time zones in which we will display the time
47    static char* TIMEZONE[] = {
48        "America/Los_Angeles",
49        "America/New_York",
50        "Europe/Paris",
51        "Europe/Berlin"
52    };
53    static const int32_t N_TIMEZONE = sizeof(TIMEZONE)/sizeof(TIMEZONE[0]);
54
55    for (int32_t i=0; i<N_LANGUAGE; ++i) {
56        Locale loc(LANGUAGE[i]);
57
58        // Display the formatted date string
59        printf("Date (%s)\n", LANGUAGE[i]);
60    }
61
62    printf("Exiting successfully\n");
63    return 0;
64}
65