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/unistr.h"
13 #include "unicode/calendar.h"
14 #include "unicode/datefmt.h"
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include "util.h"
18 #include "unaccent.h"
19
main(int argc,char ** argv)20 int main(int argc, char **argv) {
21
22 Calendar *cal;
23 DateFormat *fmt;
24 DateFormat *defFmt;
25 UErrorCode status = U_ZERO_ERROR;
26 Locale greece("el", "GR");
27 UnicodeString str, str2;
28
29 // Create a calendar in the Greek locale
30 cal = Calendar::createInstance(greece, status);
31 check(status, "Calendar::createInstance");
32
33 // Create a formatter
34 fmt = DateFormat::createDateInstance(DateFormat::kFull, greece);
35 fmt->setCalendar(*cal);
36
37 // Create a default formatter
38 defFmt = DateFormat::createDateInstance(DateFormat::kFull);
39 defFmt->setCalendar(*cal);
40
41 // Loop over various months
42 for (int32_t month = Calendar::JANUARY;
43 month <= Calendar::DECEMBER;
44 ++month) {
45
46 // Set the calendar to a date
47 cal->clear();
48 cal->set(1999, month, 4);
49
50 // Format the date in default locale
51 str.remove();
52 defFmt->format(cal->getTime(status), str, status);
53 check(status, "DateFormat::format");
54 printf("Date: ");
55 uprintf(escape(str));
56 printf("\n");
57
58 // Format the date for Greece
59 str.remove();
60 fmt->format(cal->getTime(status), str, status);
61 check(status, "DateFormat::format");
62 printf("Greek formatted date: ");
63 uprintf(escape(str));
64 printf("\n\n");
65 }
66
67 // Clean up
68 delete fmt;
69 delete cal;
70
71 printf("Exiting successfully\n");
72 return 0;
73 }
74