Wrong 12h/24h time format detection

Home Forums Calendar Products Community Events Wrong 12h/24h time format detection

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #109855
    Grégory
    Participant

    Hello.<br/><br/>

    It seems TEC and Community Events don’t handle correctly the 24h time format.
    Seen in <b>the-event-calendar/lib/tribe-view-helpers.class.php</b>, line 441, <b>TribeEventsViewHelpers::hours()</b>:

    $rangeMax = ( strstr(get_option('time_format', TribeDateUtils::TIMEFORMAT), 'H') ) ? 23 : 12;

    <br/>

    Also seen in <b>the-events-calendar-community-events/lib/tribe-community-events-template-tags.php</b>, lines 196 and 223, <b>tribe_community_events_form_start_time_selector()</b> and <b>tribe_community_events_form_end_time_selector()</b>:

    if ( !strstr( get_option( 'time_format', TribeDateUtils::TIMEFORMAT ), 'H' ) ) {

    <br/>

    The problem is that <b>G</b> is also a “24h format”, and, no luck, the default format in French is <b>G \h i \m\i\n</b> for example.
    My way (one among many others) to detect 12h/24h format:

    function is_12hours_format() {
    	static $is = null;
    	if ( is_null($is) ) {
    		$format = get_option( 'time_format', TribeDateUtils::TIMEFORMAT );
    		$is     = substr_count( $format, 'H' ) == substr_count( $format, '\H' ) && substr_count( $format, 'G' ) == substr_count( $format, '\G' );
    	}
    	return $is;
    }

    <br/>

    This way I check for <b>G</b> and <b>H</b> and possible escaped characters (same count = they’re all escaped), and not only the first character of the string.

    Cheers 🙂

    #109857
    Grégory
    Participant

    This reply is private.

    #110106
    Barry
    Member

    This reply is private.

    #118243
    Barry
    Member

    This reply is private.

    #123989
    Barry
    Member

    Hmm, a bug with the forum may have prevented you from seeing my posts. However, I wanted you to know this is still on our radar though we didn’t quite manage to squeeze it into the upcoming 3.5 release – so stay tuned and we’ll hopefully get a fix factored into the subsequent release. Thanks again for your support and patience.

    #768948
    Leah
    Member

    Hi there,

    I just wanted to let you know that we were able to work on this issue for our upcoming 3.8 release. Keep an eye out on your site for an update announcement! If you update and are still seeing this problem, please post a new thread so we can check it out. Thank you for your patience while we got this fix in place.

    Best,
    Leah
    and the team at Modern Tribe

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Wrong 12h/24h time format detection’ is closed to new replies.