End of Service calculation

Dear All,
I would like to know the basis of gratuity calculation. I know that it is basic salary for 21 days for every year completed.
Will the gratuity be paid as per the number of years completed or number of days completed?
For example, I joined my company on Jan 1, 2012 and planning to resign and go back to my home couuntry on December 10, 2013.
In this case since I have not yet completed 2 years will I be paid gratuity only for 1 year (21 days) or will I be paid for 23 months (40 days)?
Please let me know the formula for calculation of gratuity.
you will be paid based on no of days. your gratuity calculation period from 01.01.2012 to 10.12.2013 = 710 Days .
and you will get 41 days on your BASIC Salary ie., 21 days p.a
Formula:
YOUR BASIC SALARY PER MONTH X 12 / 365 X 41