WordPress.org

Ready to get started?Download WordPress

Forums

The Events Calendar
[resolved] Adding Lunar Dates to Calendar (12 posts)

  1. SerenaG
    Member
    Posted 1 year ago #

    I would like to display chinese lunar dates alongside the western dates.
    An example would look like this:

    http://www.btrts.org.sg/images/chi/montly/jul.jpg

    Anyone has any idea how this can be achieved? I'm a novice PHP programmer, is this attainable via the WordPress dashboard?

    http://wordpress.org/extend/plugins/the-events-calendar/

  2. bolide
    Member
    Posted 1 year ago #

    You can format the Date & Time as you wish by editing the PHP to display in the format you like.:
    http://codex.wordpress.org/Formatting_Date_and_Time

    Displaying the results in Chinese pictograms is another matter, I suspect. More help on localising & translating dates is available about half way through this page:
    http://codex.wordpress.org/Translating_WordPress

    Understanding how to format Date & Time (first link) is key

    These approaches should work for all languages

    Nick Froome

  3. SerenaG
    Member
    Posted 1 year ago #

    Thank you Nick! :)

    The tricky bit for my project is displaying both the Chinese lunar dates next to Gregorian ones, both in the same calendar (I'm using the Events Caldendar plugin), so changing locale doesn't help.
    And the Chinese lunar dates are not a translation of Gregorian dates, which means I need to add codes to calculate the lunar dates. Would appreciate if anyone can point me to a good place to add this function for this plugin... I'm having some difficulty pinpointing the exact location for my codes.

    Cheers!
    Serena

  4. bolide
    Member
    Posted 1 year ago #

    OK, if Chinese lunar dates are not a direct translation of Gregorian dates then finding a way of displaying them via PHP formatting dates won't help

    How about this: add a custom field of Chinese lunar date. Change the encoding of the SQL database for that field to be appropriate for Chinese characters. Then enter the Chinese dates directly into the custom field and simply display them next to the Gregorian date or as required

    Calculating them will be relatively simple (I smile even as I write that!) once you can determine the calculation that refers one to another. Outputting that calculation as Chinese characters via PHP may be a whole other thing. For that reason, and assuming you don't have thousands of dates, I suggest you enter the dates by hand

    You could do this temporarily while researching a programmatic solution or permanently do it manually

    Nick Froome

  5. bolide
    Member
    Posted 1 year ago #

    See also cdate.zip on this page:
    http://www.china-on-site.com/flexphpsite/downloads.html

    It seems I was born in the year of the dog so I may be barking up the wrong tree here

    Nick Froome

  6. roblagatta
    Modern Tribe Support
    Plugin Author

    Posted 1 year ago #

    Thanks a lot for the tips here, Nick, and for the added comedy bonus at the end there :)

    SerenaG: this give you what you need to move forward?

  7. SerenaG
    Member
    Posted 1 year ago #

    lol Nick! :D
    thanks for cdate, the algo looks good.

    roblagatta - hmmm not quite... :( or i'm missing something here.

    "How about this: add a custom field of Chinese lunar date. Change the encoding of the SQL database for that field to be appropriate for Chinese characters. Then enter the Chinese dates directly into the custom field and simply display them next to the Gregorian date or as required"

    I wish for the date to appear next to the Gregorian date, in the header of each cell. Not to be entered via a custom field. Any idea where I can add codes to display them (which php file)? The dates should be auto-generated, just like the gregorian ones.

  8. SerenaG
    Member
    Posted 1 year ago #

    I have traced through the php codes for this plugin, but still cannot locate the part to customize monthly and daily headers... Would appreciate any help, cheers!

  9. bolide
    Member
    Posted 1 year ago #

    Go right back to my first post about formatting Date & Time. That shows how to force PHP to display the date the way you want. The date is stored in SQL in one format and rendered by PHP in another and the PHP formatting tags determine how it is displayed

    An example taken from my events-list-load-widget-display.php file is

    <h4 class="event-day"><?php echo tribe_get_start_date( null, false,'jS F Y'); ?></h4>

    ( null, false,'jS F Y') is the date formatting and a look at the PHP reference will let you decode it

    The rest of it will require quite a bit of work I expect. I can't help feeling someone will have done it before but a Google search turns up lots of unhelpful results!

    Nick Froome

  10. roblagatta
    Modern Tribe Support
    Plugin Author

    Posted 1 year ago #

    Thanks for all your help on this, Nick!

  11. bolide
    Member
    Posted 1 year ago #

    A few more notes for you:

    http://chinesenotes.com/chinese_text_dates.php

    Nick Froome

  12. roblagatta
    Modern Tribe Support
    Plugin Author

    Posted 1 year ago #

    You rock, Nick. Thanks again for your continued contributions :) We'll get you on our Happiness Engineer team yet!

    SerenaG: are you all set here? Can we mark this issue resolved? Let me know if you still have any concerns.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic