1

I am building a Django application in which I need to store date information, but I'm working with Ethiopian data and the default date time/calendar in Python/Django is Gregorian.

Is there a way I can create custom date time object that matches the Ethiopic calendar, and configure it as a default date time object?

karel
  • 5,489
  • 46
  • 45
  • 50
Daniel
  • 11
  • 1

1 Answers1

1

I know almost nothing about the ethiopic calendar, but maybe I can help with some starting points and ideas.

You should probably use the gregorian based datetime objects internally and convert from and to the ethiopic calendar before displaying or after receiving input from the user. This is assuming all dates in the ethiopic calendar can be represented in the gregorian and vice versa.

You can maybe use a package from PyPI like this: ethiopian-date-converter

If you really need to use ethiopic dates internally in your code, you would probably need to roll your own datetime-like object, ModelField, FormField etc. Storing ethiopic dates in a database is probably also an adventurous task. It might not be worth it, depending on the task you are trying to solve.

If you can get away with gregorian dates internally (in the database, in your algorithms etc.), you might only need to build a template filter for output and a custom Field for input.

I hope this will get you started.

rincewind
  • 2,502
  • 19
  • 26
  • Yes, internally dates should probably be in Gregorian Calendar dates. In your case, I think it is enough to write a utility function which converts ethiopian date to gregorian date and vice versa. That is not simple task by the way. If your requirement is to input a managable data set, you may even consider to to convert all the dates using online tools like this https://www.ethcalendar.com/ethiopiancalendar/ethiopian_date_converter – yibe Jan 11 '20 at 23:04