Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


Calendar Conversion Overview

[Top]


Purpose

Converts dates between Gregorian and Chinese calendars.

[Top]


Architectural Relationships

The TDateTime class is used to represent the Gregorian calendar date. The class TChineseDate is used to represent the Chinese calendar date. CChineseCalendarConverter is used for conversion in either direction between a Gregorian date and a Chinese date.

[Top]


Description

The API consists of two calendar classes: TDateTime and CChineseCalendarConverter, which converts between TDateTime and TChineseDate formats in both directions. Chinese dates are calculated using the -2636 epoch. This is equivalent to 2637 BCE (Before Common Era).

[Top]


Example

The following code fragment converts a date stored in the Gregorian calendar into the Chinese calendar, using the DateTimeToChineseL() method:

CChineseCalendarConverter* calendarConverter = CChineseCalendarConverter::NewL();
CleanupStack::PushL(calendarConverter);

// Set up the date that you want to convert
// in this case 24th January 2001
TDateTime dateTime;
dateTime.SetYear(2001);
dateTime.SetMonth(January);
dateTime.SetDay(23);

// Create the chinese date for the result to be stored in
TChineseDate chineseDate;

// Do the conversion
calendarConverter->DateTimeToChineseL(dateTime, chineseDate);

// New year's day!
chineseDate.iCycle      // 78
chineseDate.iDay        // 1
chineseDate.iLeapMonth  // boolean
chineseDate.iMonth      // 1
chineseDate.iYear       // 18

CleanupStack::PopAndDestroy(calendarConverter);

To convert from the Chinese calendar to the Gregorian use the method ChineseToDateTimeL().