Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Product cycles use dates not as a pickable single entry, but as integers representing day and month of a year:
image-20240215-080635.pngImage Removed

...

Because of this, no changes are needed on the frontend to support different types of calendar (TBC - if it can support calendar with 13 months). This feature is locale agnostic.

On the backend side, we have a setting in the core module called secondary_calendar. This setting is a string only and tells us which calendar should be selected by product cycles method if any is needed.

Code for product cycles looks like this:

Code Block
    if CoreConfig.secondary_calendar == 'Nepal':
        import nepali_datetime
        nepali_start = nepali_datetime.datetime.strptime("%s-%s" % (c, nepali_datetime.date.today().year), '%d-%m-%Y')
        start = nepali_start.to_datetime_date()
    else:
        start = py_datetime.datetime.strptime("%s-%s" % (c, ref_date.year), '%d-%m-%Y')

Which allows developer to add support for additional calendar in a easy way - just add another if statement that will convert date value stored as a pair of two strings to a date valid for a current year and convert it to values interpreted in gregorian date, so the rest of the business logic does not have to be changed.

Reports (back-end)

ReportBro does not seem to support it. I’ve opened an inssue on github - https://github.com/jobsta/reportbro-lib/issues/36 . We may have to add this support ourselves (reporbro is opensource).

...