]>
git.saurik.com Git - apple/icu.git/blob - icuSources/samples/datecal/cal.cpp
2 *******************************************************************************
4 * Copyright (C) 2002-2012, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
10 #include "unicode/calendar.h"
11 #include "unicode/gregocal.h"
14 extern "C" void c_main();
18 UErrorCode status
= U_ZERO_ERROR
;
20 GregorianCalendar
* gc
= new GregorianCalendar(status
);
21 if (U_FAILURE(status
)) {
22 puts("Couldn't create GregorianCalendar");
26 gc
->set(2000, UCAL_FEBRUARY
, 26);
27 gc
->set(UCAL_HOUR_OF_DAY
, 23);
28 gc
->set(UCAL_MINUTE
, 0);
29 gc
->set(UCAL_SECOND
, 0);
30 gc
->set(UCAL_MILLISECOND
, 0);
31 /* Iterate through the days and print it out. */
32 for (int32_t i
= 0; i
< 30; i
++) {
33 /* print out the date. */
34 /* You should use the DateFormat to properly format it */
35 printf("year: %d, month: %d (%d in the implementation), day: %d\n",
36 gc
->get(UCAL_YEAR
, status
),
37 gc
->get(UCAL_MONTH
, status
) + 1,
38 gc
->get(UCAL_MONTH
, status
),
39 gc
->get(UCAL_DATE
, status
));
40 if (U_FAILURE(status
))
42 puts("Calendar::get failed");
45 /* Add a day to the date */
46 gc
->add(UCAL_DATE
, 1, status
);
47 if (U_FAILURE(status
)) {
48 puts("Calendar::add failed");
56 /* Creating and using text boundaries */
59 puts("Date-Calendar sample program");