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