• Hi,

    One of my plugin load the JQuery regional (FR) datepicker jquery.ui.datepicker-fr.js?ver=1.11.1 and for some reason it makes problem with the plugin.

    What happen is that the date & time of the event becomes the current date & time during the creation process, so that the event is seen as a past event.

    I notice this after I add these few lines in the archive loop :

    $meta = get_post_meta($post->ID );
    			echo date('d F Y H i', $meta['event-unix'][0]);
    			</br>
    			<?php echo current_time( 'mysql' );

    As soon as I remove the file jquery.ui.datepicker-fr.js the new event created appear as upcoming… but the datepicker remains in english.

    jQuery(function($){
    	$.datepicker.regional['fr'] = {
    		closeText: 'Fermer',
    		prevText: 'Précédent',
    		nextText: 'Suivant',
    		currentText: 'Aujourd \'hui',
    		monthNames: ['Janvier','Février','Mars','Avril','Mai','Juin',
    		'Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
    		monthNamesShort: ['Janv.','Févr.','Mars','Avril','Mai','Juin',
    		'Juil.','Août','Sept.','Oct.','Nov.','Déc.'],
    		dayNames: ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
    		dayNamesShort: ['Dim.','Lun.','Mar.','Mer.','Jeu.','Ven.','Sam.'],
    		dayNamesMin: ['D','L','M','M','J','V','S'],
    		weekHeader: 'Sem.',
    		dateFormat: 'dd/mm/yy',
    		firstDay: 1,
    		isRTL: false,
    		showMonthAfterYear: false,
    		yearSuffix: ''};
    	$.datepicker.setDefaults($.datepicker.regional['fr']);
    });

    I’ve try to modify this JS file in order to match with the original JQuery file that as a different dateFormat and firstDay or replacing with regional file from JQuery website but still the same and it is not clear for me what can cause this between the two.

    It looks like $event_unix in $event_unix = get_post_meta( $post_id, 'event-unix', true ); returns empty value which cause $timestamp to be equal to current time.

    private function save_timestamp() {
    
    		$date_flag = false;
    		$date = date_parse( $this->date );
    
    		if( $date["error_count"] == 0 && checkdate( $date["month"], $date["day"], $date["year"] ) )
    			$date_flag = true;
    
    		$time_flag = false;
    		$time = date_parse( $this->time );
    
    		if( $time["error_count"] == 0 )
    			$time_flag = true;
    
    		if( $date_flag && $time_flag ) {
    			$date_time = $this->date . ' ' . $this->time;
    			$timestamp = strtotime( $date_time );
    		}
    		elseif( $date_flag ) {
    			$timestamp = strtotime( $this->date );
    		}
    		else {
    
    			$event_unix = get_post_meta( $post_id, 'event-unix', true );
    
    			if( ! empty( $event_unix ) ) {
    				$timestamp = $event_unix;
    				}
    			else
    				$timestamp = current_time( 'timestamp' );
    		}
    
    		update_post_meta( $this->post_id, 'event-unix', $timestamp );
    
    	}

    Did you already have this plugin working with JQuery datepickers for others regions ?

    https://wordpress.org/plugins/buddypress-simple-events/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author shanebp

    (@shanebp)

    I do not have it working with datepickers for other regions.

    In function save_timestamp(), have you tried changing or removing this:
    checkdate( $date["month"], $date["day"], $date["year"] ) )

    I think $date_flag is never set to true and therefore $timestamp defaults to current_time. You could test by just hard-coding $date_flag to true.

    Also you may need to adjust dateFormat: 'DD, MM d, yy' in js/events.js.

    Thanks for raising this issue.

    Thread Starter Florent

    (@frappi)

    In function save_timestamp(), have you tried changing or removing this:
    checkdate( $date[“month”], $date[“day”], $date[“year”] ) )

    I do but still the problem. I hard coded $date_flag and $time_flag to true

    Also you may need to adjust dateFormat: ‘DD, MM d, yy’ in js/events.js.

    This test I didn’t try but after I modified dateFormat to 'dd/mm/yy' it changes the date format in the form as expected but still the problem. Unbelievable. I also kept the original dateFormat: 'DD, MM d, yy' and modify the jquery.ui.datepicker-fr.js for both format to match together but no luck.

    I notice that in the admin page and archive page newly created events have correct Date and Time (i.e. event-date and event-time) like this :

    Date: Vendredi, Janvier 29, 2016
    Time: 4:40 PM
    Location: Draveil, France

    But the problem is with event-unix that returns current day and time, I didn’t mentioned it, like this (same event as above) :

    2016-01-15 11:06:09

    Code I use to output this event-unix :

    $meta = get_post_meta($post->ID );
    echo date('d F Y H i', $meta['event-unix'][0]);

    This is very strange.

    Thread Starter Florent

    (@frappi)

    When $date_flag and $time_flag are set to true then the command :

    $meta = get_post_meta($post->ID );
    echo date('d F Y H i', $meta['event-unix'][0]);

    returns an error because $meta['event-unix'][0] doesn’t exist. That is weird because it execute

    if( $date_flag && $time_flag ) {
    			$date_time = $this->date . ' ' . $this->time;
    			$timestamp = strtotime( $date_time );
    		}

    Then

    update_post_meta( $this->post_id, 'event-unix', $timestamp );

    Problem may comes from $date_time = $this->date . ' ' . $this->time; but I’m not familiar why this $this of Javascript. All ideas are appreciate, thanks.

    Hello,

    Did you came to a solution on this?

    Also, shouldn’t
    $event_unix = get_post_meta( $post_id, 'event-unix', true );*
    be
    $event_unix = get_post_meta( $this->post_id, 'event-unix', true );

    *pp-events-create-class.php, lines 315 and 444 (Pro version)

    Thank you,
    Javier

    Plugin Author shanebp

    (@shanebp)

    Yes it should be $this->post_id.
    Fixed in this version and Pro.

    Thanks, @shanebp.

    Unfortunately, this still ain’t solving the regional issue (at least in Pro version), so events are set as past.

    I’m having the same problem with the PRO version of this plugin in WordPress 4.6. Have a dutch website. From peeking events-data in the database I can see that unix event-time is set to creation date and not to the correct (dutch) date that appears on the event screen after creating an event. Because of this all events are considered to lie in the past as of their moment of creation and they only appear in the event archive (ordered by creation date). Upcoming events list remains empty.
    Because of the changes in WP 4.6 (as mentioned in https://make.wordpress.org/core/2016/07/06/jquery-ui-datepicker-localization-in-4-6/ ) I downgraded to WP4.5.7 to check.
    In WP4.5.7 the plugin works right, but datepicker and time are in english, just as the date and time in the eventual event screen.
    Is there any chance the plugin can be updated to work correct under WP4.6 and coming WP-versions?
    I don’t like to be stuck with an outdated version of WP.
    Thanx in advance.

    • This reply was modified 7 years, 5 months ago by fredricq.
    Plugin Author shanebp

    (@shanebp)

    These forums are only for supporting the free version of this plugin. Providing support here for the Pro version is not allowed.

    From the moderator for these forums:

    1. Full stop: the author cannot support any questions about the “pro” version here. That’s all there is to it and I’m closing this and your other topic. You are having a problem with the “pro” version.

    Any author who routinely replies to their customers in these forums will be in for a rude shock. That needs to stop.

    Support for the Pro version of this plugin is available here.

    @fredricq
    You have contacted me privately and we are working on a solution for this issue.

    Plugin Author shanebp

    (@shanebp)

    For this free version, for non-English languages, the regional jquery datepicker requires you to make a small change manually.

    Open this file: buddypress-simple-events\inc\js\events.js

    And change this line to the format used by your region:
    dateFormat: 'DD, MM d, yy'

    For Europe, change it to: dateFormat: 'dd-mm-yy'

    • This reply was modified 7 years, 4 months ago by shanebp.
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Problem with regional JQuery datepicker ?’ is closed to new replies.