]>
Commit | Line | Data |
---|---|---|
1 | /******************************************************************** | |
2 | * COPYRIGHT: | |
3 | * Copyright (c) 1999-2002, International Business Machines Corporation and | |
4 | * others. All Rights Reserved. | |
5 | ********************************************************************/ | |
6 | ||
7 | #include "unicode/translit.h" | |
8 | #include "unicode/rbt.h" | |
9 | #include "unicode/unistr.h" | |
10 | #include "unicode/calendar.h" | |
11 | #include "unicode/datefmt.h" | |
12 | #include <stdio.h> | |
13 | #include <stdlib.h> | |
14 | #include "util.h" | |
15 | #include "unaccent.h" | |
16 | ||
17 | int main(int argc, char **argv) { | |
18 | ||
19 | Calendar *cal; | |
20 | DateFormat *fmt; | |
21 | DateFormat *defFmt; | |
22 | Transliterator *greek_latin; | |
23 | UErrorCode status = U_ZERO_ERROR; | |
24 | Locale greece("el", "GR"); | |
25 | UnicodeString str, str2; | |
26 | ||
27 | // Create a calendar in the Greek locale | |
28 | cal = Calendar::createInstance(greece, status); | |
29 | check(status, "Calendar::createInstance"); | |
30 | ||
31 | // Create a formatter | |
32 | fmt = DateFormat::createDateInstance(DateFormat::kFull, greece); | |
33 | fmt->setCalendar(*cal); | |
34 | ||
35 | // Create a default formatter | |
36 | defFmt = DateFormat::createDateInstance(DateFormat::kFull); | |
37 | defFmt->setCalendar(*cal); | |
38 | ||
39 | // Create a Greek-Latin Transliterator | |
40 | greek_latin = Transliterator::createInstance("Greek-Latin"); | |
41 | if (greek_latin == 0) { | |
42 | printf("ERROR: Transliterator::createInstance() failed\n"); | |
43 | exit(1); | |
44 | } | |
45 | ||
46 | // Loop over various months | |
47 | for (int32_t month = Calendar::JANUARY; | |
48 | month <= Calendar::DECEMBER; | |
49 | ++month) { | |
50 | ||
51 | // Set the calendar to a date | |
52 | cal->clear(); | |
53 | cal->set(1999, month, 4); | |
54 | ||
55 | // Format the date in default locale | |
56 | str.remove(); | |
57 | defFmt->format(cal->getTime(status), str, status); | |
58 | check(status, "DateFormat::format"); | |
59 | printf("Date: "); | |
60 | uprintf(escape(str)); | |
61 | printf("\n"); | |
62 | ||
63 | // Format the date for Greece | |
64 | str.remove(); | |
65 | fmt->format(cal->getTime(status), str, status); | |
66 | check(status, "DateFormat::format"); | |
67 | printf("Greek formatted date: "); | |
68 | uprintf(escape(str)); | |
69 | printf("\n"); | |
70 | ||
71 | // Transliterate result | |
72 | greek_latin->transliterate(str); | |
73 | printf("Transliterated via Greek-Latin: "); | |
74 | uprintf(escape(str)); | |
75 | printf("\n\n"); | |
76 | } | |
77 | ||
78 | // Clean up | |
79 | delete fmt; | |
80 | delete cal; | |
81 | delete greek_latin; | |
82 | ||
83 | printf("Exiting successfully\n"); | |
84 | return 0; | |
85 | } |