PublishDate: make widget follow the 24h format setting (#1776)

Closes 1738
This commit is contained in:
infinite-persistence 2022-06-29 20:34:32 +08:00 committed by GitHub
parent 70ea3f0812
commit 4569a4f9f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View file

@ -1,12 +1,15 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import * as SETTINGS from 'constants/settings';
import { makeSelectPublishFormValue } from 'redux/selectors/publish'; import { makeSelectPublishFormValue } from 'redux/selectors/publish';
import { doUpdatePublishForm } from 'redux/actions/publish'; import { doUpdatePublishForm } from 'redux/actions/publish';
import { selectClientSetting } from 'redux/selectors/settings';
import PublishReleaseDate from './view'; import PublishReleaseDate from './view';
const select = (state) => ({ const select = (state) => ({
releaseTime: makeSelectPublishFormValue('releaseTime')(state), releaseTime: makeSelectPublishFormValue('releaseTime')(state),
releaseTimeEdited: makeSelectPublishFormValue('releaseTimeEdited')(state), releaseTimeEdited: makeSelectPublishFormValue('releaseTimeEdited')(state),
releaseTimeError: makeSelectPublishFormValue('releaseTimeError')(state), releaseTimeError: makeSelectPublishFormValue('releaseTimeError')(state),
clock24h: selectClientSetting(state, SETTINGS.CLOCK_24H),
}); });
const perform = (dispatch) => ({ const perform = (dispatch) => ({

View file

@ -17,18 +17,21 @@ const RESET_TO_ORIGINAL = 'reset-to-original';
const FUTURE_DATE_ERROR = 'Cannot set to a future date.'; const FUTURE_DATE_ERROR = 'Cannot set to a future date.';
type Props = { type Props = {
releaseTime: ?number,
releaseTimeEdited: ?number,
updatePublishForm: ({}) => void,
allowDefault: ?boolean, allowDefault: ?boolean,
showNowBtn: ?boolean, showNowBtn: ?boolean,
useMaxDate: ?boolean, useMaxDate: ?boolean,
// --- redux:
releaseTime: ?number,
releaseTimeEdited: ?number,
clock24h: boolean,
updatePublishForm: ({}) => void,
}; };
const PublishReleaseDate = (props: Props) => { const PublishReleaseDate = (props: Props) => {
const { const {
releaseTime, releaseTime,
releaseTimeEdited, releaseTimeEdited,
clock24h,
updatePublishForm, updatePublishForm,
allowDefault = true, allowDefault = true,
showNowBtn = true, showNowBtn = true,
@ -155,7 +158,7 @@ const PublishReleaseDate = (props: Props) => {
onBlur={handleBlur} onBlur={handleBlur}
onChange={onDateTimePickerChanged} onChange={onDateTimePickerChanged}
value={date} value={date}
format="y-MM-dd h:mm a" format={clock24h ? 'y-MM-dd HH:mm' : 'y-MM-dd h:mm a'}
disableClock disableClock
clearIcon={null} clearIcon={null}
/> />