Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product
Vanilla 2.6 is here! It includes security fixes and requires PHP 7.0. We have therefore ALSO released Vanilla 2.5.2 with security patches if you are still on PHP 5.6 to give you additional time to upgrade.

How to convert Vanilla date to Jalali (Shamsi)

Hi
does it possible to convert the Vanilla date to Jalali (Shamsi) date ?

Comments

  • businessdadbusinessdad Stealth contributor MVP

    I just learnt about Jalali calendar, now I know something new. As for how to display dates in such format, I'm afraid it can be a complicate task.

    To achieve such result, some issues have to be solved:

    • Conversion: Gregorian dates must converted into their Jalali counterpart. This could be done by using one of the many libraries available on the Internet. Conversion should be bidirectional, i.e. Gregorian->Jalali for the output and Jalali->Gregorian for the input.
    • Formatting: Vanilla makes extensive use of Gdn_Format::Date(), which uses the locale file to determine how to format the date. As far as I could see, the format constants used by the class, which correspond to the ones used by PHP function strftime(), don't support the formatting of these dates.

    In short, the objective would be converting every output date to Jalali before printing, and converting every Jalali input to Gregorian before passing it to Vanilla engine. Perhaps it may be easier than I think, but I'm afraid that some core functions would have to be modified.

    Keyvan
  • perhaps javascript could be used

    look at this script
    https://github.com/farhadi/JalaliJSCalendar/blob/master/jalali.js#L72

    you could parse the date on the page, which would require little detection, manipulation, conversion and replace.

    Historical Jalali is complicated becuase it has no leap years.

    grep is your friend.

    Keyvan
  • businessdadbusinessdad Stealth contributor MVP

    @x00 That could also be a clean option. The OP would just have to make sure that the Users have JavaScript enabled.

    Keyvan
  • well it is a compromise solution obviously not full proof.

    I doubt that the users are unfamiliar with Gregorian.

    grep is your friend.

    Keyvan
  • good idea to use livequery given that comment are added dynamically.

    grep is your friend.

    Keyvan
Sign In or Register to comment.