Home › Forums › Calendar Products › Community Events › Wrong 12h/24h time format detection
- This topic has 5 replies, 3 voices, and was last updated 9 years, 7 months ago by Leah.
-
AuthorPosts
-
February 26, 2014 at 3:07 pm #109855GrégoryParticipant
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 🙂
February 26, 2014 at 3:09 pm #109857GrégoryParticipantThis reply is private.
February 26, 2014 at 8:11 pm #110106BarryMemberThis reply is private.
March 13, 2014 at 8:23 am #118243BarryMemberThis reply is private.
March 27, 2014 at 3:09 pm #123989BarryMemberHmm, 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.
September 26, 2014 at 12:00 pm #768948LeahMemberHi 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 -
AuthorPosts
- The topic ‘Wrong 12h/24h time format detection’ is closed to new replies.