Skip to content

Commit 995bb12

Browse files
committed
Chrome: Check more accurately the 12 hour time
1 parent 3afd891 commit 995bb12

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

editor/sidebar/post-schedule/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,16 @@ class PostSchedule extends Component {
4848
const handleChange = ( newDate ) => {
4949
onUpdateDate( newDate.format( 'YYYY-MM-DDTHH:mm:ss' ) );
5050
};
51-
const is12HourTime = settings.formats.time.indexOf( 'a' ) !== -1 || settings.formats.time.indexOf( 'A' ) !== -1;
51+
52+
// To know if the current timezone is a 12 hour time with look for "a" in the time format
53+
// We also make sure this a is not escaped by a "/"
54+
const is12HourTime = /a(?!\\)/i.test(
55+
settings.formats.time
56+
.toLowerCase() // Test only the lower case a
57+
.replace( /\\\\/g, '' ) // Replace "//" with empty strings
58+
.split( '' ).reverse().join( '' ) // Reverse the string and test for "a" not followed by a slash
59+
);
60+
5261
return (
5362
<div className="editor-post-schedule">
5463
<span>{ __( 'Publish' ) }</span>

editor/sidebar/post-schedule/style.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
.wp-core-ui .editor-post-schedule__clock-am-button.is-toggled,
9191
.wp-core-ui .editor-post-schedule__clock-pm-button.is-toggled {
9292
background: $light-gray-300;
93-
border-color: $dark-gray-100;
93+
border-color: $dark-gray-100;
9494
box-shadow: inset 0 2px 5px -3px $dark-gray-500;
9595
transform: translateY(1px);
9696
}

0 commit comments

Comments
 (0)