QCustomPlot Discussion and Comments

Change time data from Gregorian calendar to Hijri calenderReturn to overview

hi
I wanna change (QCPAxisTickerDateTime) time data to show my hijri calender for example (years 2019 change to 1400) and also for months and day.
please help if you have any ideas
thanks alots.

my guess is you would need to create your own ticker and then use some sort of conversion method to convert between the two.

If it were me, I'd just concern myself with converting the date string to a date data type, then the output could be represented in whichever calendar format is desired at a later point in time. As such:

to_date(date_string,'mm/dd/rrrr','nls_calendar=''English Hijrah''')

should be sufficient to convert the date string from Hijrah to the internal date data type. The typical NLS date settings are for a Gregorian 2023 calendar, so once converted to the interal date data type the actual displaying of the date would match the NLS settings which would be Gregorian unless it's been changed for some specific reason.

To display the Hijri calendar dates in QCustomPlot instead of the Gregorian dates, you'll need to handle the conversion yourself before passing the dates to QCPAxisTickerDateTime.

The Qt Framework has some functions that can help with converting Gregorian to Hijri dates:

Use QDate::toHijri() to convert a QDate object to a Hijri formatted string
Use QLocale::toHijriDate() to convert a year/month/day to a Hijri QDate
So you could do something like:

QDate gregDate(2019, 5, 15);

QString hijriDate = gregDate.toHijri(); // "10 Ramadan 1440"

QDate hijriQDate = QLocale().toHijriDate(2019, 5, 15); // QDate(1440, 8, 10)

Then pass those Hijri dates to QCPAxisTickerDateTime instead of Gregorian dates.

This should allow displaying a Hijri formatted date axis while still keeping your core date data in the Gregorian calendar 2024. Let me know if you have any other questions!