2 *******************************************************************************
4 * Copyright (C) 2016 and later: Unicode, Inc. and others.
5 * License & terms of use: http://www.unicode.org/copyright.html#License
7 *******************************************************************************
8 *******************************************************************************
10 * Copyright (C) 2002-2003, International Business Machines
11 * Corporation and others. All Rights Reserved.
13 *******************************************************************************
16 #include "unicode/ucal.h"
24 UErrorCode status = U_ZERO_ERROR;
26 UCalendar *cal = ucal_open(NULL, -1, NULL, UCAL_GREGORIAN, &status);
27 if (U_FAILURE(status)) {
28 puts("Couldn't create GregorianCalendar");
32 ucal_set(cal, UCAL_YEAR, 2000);
33 ucal_set(cal, UCAL_MONTH, UCAL_FEBRUARY); /* FEBRUARY */
34 ucal_set(cal, UCAL_DATE, 26);
35 ucal_set(cal, UCAL_HOUR_OF_DAY, 23);
36 ucal_set(cal, UCAL_MINUTE, 0);
37 ucal_set(cal, UCAL_SECOND, 0);
38 ucal_set(cal, UCAL_MILLISECOND, 0);
39 /* Iterate through the days and print it out. */
40 for (i = 0; i < 30; i++) {
41 /* print out the date. */
42 /* You should use the udat_* API to properly format it */
43 printf("year: %d, month: %d (%d in the implementation), day: %d\n",
44 ucal_get(cal, UCAL_YEAR, &status),
45 ucal_get(cal, UCAL_MONTH, &status) + 1,
46 ucal_get(cal, UCAL_MONTH, &status),
47 ucal_get(cal, UCAL_DATE, &status));
48 if (U_FAILURE(status)) {
49 puts("Calendar::get failed");
52 /* Add a day to the date */
53 ucal_add(cal, UCAL_DATE, 1, &status);
54 if (U_FAILURE(status))
56 puts("Calendar::add failed");