Is there any function to directly convert Unix Time Stamp (returned by time() [ctime library]) to a struct tm or something that holds the date and time in Jalali format?
And I'm not looking for a way to convert Gregorian to Jalali. I'm looking for an algorithm to convert what time(NULL) returns directly to the Jalali calendar.
I've developed a similar algorithm to convert Julian Day Number to Solar Hijri (~= Jalali) calendar date. The principles are same: take a reference point in time (in your case 1970-01-01 which is equal to JDN #2440587) and calculate how many years, month and days are past since then. My algorithm is based on Akramis's mean-year calculation which has a good conformance to Official Iranian Calendar (same in near past).
The C implementation is available here:
https://github.com/soroush/libcalendars/blob/dev/lib/src/cl-solar-hijri.c
Note that you can convert unix time to JDN only by adding 2440587 offset. So you will need to:
int16_t year;
uint8_t month;
int16_t day;
jdn_to_sh(unix_time + 2440587, &year, &month, &date);