Skip to content

Commit

Permalink
Chrome: Check more accurately the 12 hour time
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed May 24, 2017
1 parent cce5fdb commit b7e0954
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion editor/sidebar/post-schedule/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,16 @@ class PostSchedule extends Component {
const handleChange = ( newDate ) => {
onUpdateDate( newDate.format( 'YYYY-MM-DDTHH:mm:ss' ) );
};
const is12HourTime = settings.formats.time.indexOf( 'a' ) !== -1 || settings.formats.time.indexOf( 'A' ) !== -1;

// To know if the current timezone is a 12 hour time with look for "a" in the time format
// We also make sure this a is not escaped by a "/"
const is12HourTime = /a(?!\\)/i.test(
settings.formats.time
.toLowerCase() // Test only the lower case a
.replace( /\\\\/g, '' ) // Replace "//" with empty strings
.split( '' ).reverse().join( '' ) // Reverse the string and test for "a" not followed by a slash
);

return (
<div className="editor-post-schedule">
<span>{ __( 'Publish' ) }</span>
Expand Down
2 changes: 1 addition & 1 deletion editor/sidebar/post-schedule/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
.wp-core-ui .editor-post-schedule__clock-am-button.is-toggled,
.wp-core-ui .editor-post-schedule__clock-pm-button.is-toggled {
background: $light-gray-300;
border-color: $dark-gray-100;
border-color: $dark-gray-100;
box-shadow: inset 0 2px 5px -3px $dark-gray-500;
transform: translateY(1px);
}

0 comments on commit b7e0954

Please sign in to comment.