Alternate Calendar Formats for CommCare Android

Use of the Alternate Calendar Systems in CommCare Android

CommCare's Android client supports hooks for manipulating dates in select calendar systems other than Gregorian (i.e. Nepali and Ethiopian). 

Dates are always stored inside of the form as ISO8601 compliant Gregorian dates, so exports and incoming data will need to handle data in that format.

During form entry dates can be both collected and displayed in alternate calendars using two mechanisms. In each system a key is provided from the following table to request that specific calendar



Calendar Key

Description

Calendar Key

Description

ethiopian

Ethiopian Calendar (Supports Amharic fonts if the phone's locale is set appropriately)

nepali

Nepali Calendar (CommCare Android 2.19+)



Collecting a date using the date question type

Setting a date question's appearance attribute to one of the supported keys will result in date entry being performed using that calendar. Note again that the date stored in the form is a standard Gregorian date, so any calculations you will do will be in that format and exports will contain a standard Gregorian date.

In CommCareHQ you can accomplish this by setting the key in the Advanced -> Appearance Attribute field for the date question (see below).



Displaying a Date in an Alternative Format

When dates are displayed in a form, the date can be passed to the format-date-for-calendar() function to return a string which prints the date in the appropriate calendar. The first argument to the function should be a standard date, and the second should be the key of that calendar, passed as a string.