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