1/*
2*******************************************************************************
3*
4*   Copyright (C) 2002-2012, International Business Machines
5*   Corporation and others.  All Rights Reserved.
6*
7*******************************************************************************
8*/
9
10#include "unicode/calendar.h"
11#include "unicode/gregocal.h"
12#include <stdio.h>
13
14extern "C" void c_main();
15
16void cpp_main()
17{
18  UErrorCode status = U_ZERO_ERROR;
19  puts("C++ sample");
20  GregorianCalendar* gc = new GregorianCalendar(status);
21  if (U_FAILURE(status)) {
22    puts("Couldn't create GregorianCalendar");
23    return;
24  }
25  /* set up the date */
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))
41      {
42        puts("Calendar::get failed");
43        return;
44      }
45    /* Add a day to the date */
46    gc->add(UCAL_DATE, 1, status);
47    if (U_FAILURE(status)) {
48      puts("Calendar::add failed");
49      return;
50    }
51  }
52  delete gc;
53}
54
55
56/* Creating and using text boundaries */
57int main( void )
58{
59  puts("Date-Calendar sample program");
60
61  cpp_main();
62
63  c_main();
64
65  return 0;
66}
67
68