Home | History | Annotate | Download | only in answers
      1 /***********************************************************************
      2  *  2016 and later: Unicode, Inc. and others.
      3  * License & terms of use: http://www.unicode.org/copyright.html#License
      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 
     21 int main(int argc, char **argv) {
     22 
     23     Calendar *cal;
     24     DateFormat *fmt;
     25     DateFormat *defFmt;
     26     UErrorCode status = U_ZERO_ERROR;
     27     Locale greece("el", "GR");
     28     UnicodeString str, str2;
     29 
     30     // Create a calendar in the Greek locale
     31     cal = Calendar::createInstance(greece, status);
     32     check(status, "Calendar::createInstance");
     33 
     34     // Create a formatter
     35     fmt = DateFormat::createDateInstance(DateFormat::kFull, greece);
     36     fmt->setCalendar(*cal);
     37 
     38     // Create a default formatter
     39     defFmt = DateFormat::createDateInstance(DateFormat::kFull);
     40     defFmt->setCalendar(*cal);
     41 
     42     // Loop over various months
     43     for (int32_t month = Calendar::JANUARY;
     44          month <= Calendar::DECEMBER;
     45          ++month) {
     46 
     47         // Set the calendar to a date
     48         cal->clear();
     49         cal->set(1999, month, 4);
     50 
     51         // Format the date in default locale
     52         str.remove();
     53         defFmt->format(cal->getTime(status), str, status);
     54         check(status, "DateFormat::format");
     55         printf("Date: ");
     56         uprintf(escape(str));
     57         printf("\n");
     58 
     59         // Format the date for Greece
     60         str.remove();
     61         fmt->format(cal->getTime(status), str, status);
     62         check(status, "DateFormat::format");
     63         printf("Greek formatted date: ");
     64         uprintf(escape(str));
     65         printf("\n\n");
     66     }
     67 
     68     // Clean up
     69     delete fmt;
     70     delete cal;
     71 
     72     printf("Exiting successfully\n");
     73     return 0;
     74 }
     75