Skip to content

Commit

Permalink
Merge branch 'develop' into datetime-improvements-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
thecalcc committed Jan 23, 2025
2 parents e0a6fd3 + dd7fbf0 commit 0a0bb26
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
10 changes: 5 additions & 5 deletions app-typescript/components/DateTimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface IProps {
hidden?: boolean;
};
dateFormat: string;
onChange: (value: string | null) => void;
onChange: (value: Date | null) => void;
preview?: boolean;
fullWidth?: boolean;
allowSeconds?: boolean;
Expand All @@ -30,10 +30,10 @@ export class DateTimePicker extends React.PureComponent<IProps> {

origDate.setHours(hours, minutes);

this.props.onChange(origDate.toISOString());
this.props.onChange(origDate);
}

handleDateChange = (date?: string) => {
handleDateChange = (date: Date | null) => {
if (date == null) {
this.props.onChange(null);

Expand All @@ -45,7 +45,7 @@ export class DateTimePicker extends React.PureComponent<IProps> {

selectedDate.setHours(origDate.getHours(), origDate.getMinutes());

this.props.onChange(selectedDate.toISOString());
this.props.onChange(selectedDate);
}

prepareFormat(unitOfTime: number) {
Expand All @@ -67,7 +67,7 @@ export class DateTimePicker extends React.PureComponent<IProps> {
hideClearButton={true}
value={this.props.value}
onChange={(val) => {
this.handleDateChange(val?.toString());
this.handleDateChange(val);
}}
dateFormat={this.props.dateFormat}
label={this.props.label.text}
Expand Down
4 changes: 2 additions & 2 deletions examples/pages/components/DateTimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class DateTimePickerExample extends React.PureComponent<{}, {dateTime: Date | nu
render() {
return (
<DateTimePicker
label='Planning datetime'
label={{text: "Planning date"}}
value={this.state.dateTime}
dateFormat="YYYY-MM-DD"
onChange={(val) => {
const parsedVal = val != null && (val.length > 0) ? new Date(val) : null;
const parsedVal = val != null ? new Date(val) : null;

this.setState({dateTime: parsedVal});
}}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "superdesk-ui-framework",
"version": "4.0.9",
"version": "4.0.10",
"license": "AGPL-3.0",
"repository": {
"type": "git",
Expand Down Expand Up @@ -110,5 +110,8 @@
},
"peerDependencies": {
"moment": "*"
},
"volta": {
"node": "14.21.3"
}
}

0 comments on commit 0a0bb26

Please sign in to comment.