update ntp lib to moment

This commit is contained in:
proddy
2021-02-01 11:30:12 +01:00
parent 04e15a7337
commit 258ed874ec
7 changed files with 112 additions and 106 deletions

View File

@@ -13,7 +13,7 @@ import RefreshIcon from '@material-ui/icons/Refresh';
import { RestFormProps, FormButton, HighlightAvatar } from '../components';
import { isNtpActive, ntpStatusHighlight, ntpStatus } from './NTPStatus';
import { formatDuration, formatDateTime, formatLocalDateTimeNow, formatLocalDateTime } from './TimeFormat';
import { formatDuration, formatDateTime, formatLocalDateTime } from './TimeFormat';
import { NTPStatus, Time } from './types';
import { redirectingAuthorizedFetch, withAuthenticatedContext, AuthenticatedContextProps } from '../authentication';
import { TIME_ENDPOINT } from '../api';
@@ -38,18 +38,27 @@ class NTPStatusForm extends Component<NTPStatusFormProps, NTPStatusFormState> {
}
updateLocalTime = (event: React.ChangeEvent<HTMLInputElement>) => {
this.setState({ localTime: event.target.value });
this.setState({
localTime: event.target.value
});
}
openSetTime = () => {
this.setState({ localTime: formatLocalDateTimeNow(), settingTime: true, });
this.setState({
localTime: formatLocalDateTime(new Date()),
settingTime: true
});
}
closeSetTime = () => {
this.setState({ settingTime: false });
this.setState({
settingTime: false
});
}
createTime = (): Time => ({ local_time: formatLocalDateTime(this.state.localTime) });
createTime = (): Time => ({
local_time: formatLocalDateTime(new Date(this.state.localTime))
});
configureTime = () => {
this.setState({ processing: true });
@@ -185,4 +194,4 @@ class NTPStatusForm extends Component<NTPStatusFormProps, NTPStatusFormState> {
}
}
export default withAuthenticatedContext(withTheme(NTPStatusForm));
export default withAuthenticatedContext(withTheme(NTPStatusForm));