Skip to content

Commit

Permalink
fix planning date without time showing previous date by default (#2218)
Browse files Browse the repository at this point in the history
STT-139
  • Loading branch information
petrjasek authored Feb 28, 2025
1 parent ce6c4df commit 42ab256
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
9 changes: 8 additions & 1 deletion client/components/fields/editor/base/dateTime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,16 @@ export class EditorFieldDateTime extends React.PureComponent<IProps> {
render() {
const field = this.props.field;
const value = get(this.props.item, field, this.props.defaultValue);
const momentValue = value != null ? moment(value) : undefined;
const error = get(this.props.errors ?? {}, field);

let momentValue : moment.Moment;

if (value != null) {
momentValue = this.props.allDay ? moment.utc(value) : moment(value);
} else {
momentValue = undefined;
}

return (
<DateTimeInput
{...this.props}
Expand Down
10 changes: 8 additions & 2 deletions client/utils/planning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1249,9 +1249,11 @@ function getPlanningByDate(
plansInList.forEach((plan) => {
let dates = {};
let groupDate = null;
const planningDate = getPlanningDate(plan);

const setCoverageToDate = (coverage) => {
groupDate = getGroupDate(moment(get(coverage, 'planning.scheduled', plan.planning_date)).clone());
groupDate = getGroupDate(moment(get(coverage, 'planning.scheduled', planningDate)).clone());

if (!isDateInRange(groupDate, startDate, endDate)) {
return;
}
Expand All @@ -1276,7 +1278,7 @@ function getPlanningByDate(
});

if (isEmpty(dates)) {
groupDate = getGroupDate(moment(plan.planning_date).clone());
groupDate = getGroupDate(planningDate);
if (isDateInRange(groupDate, startDate, endDate)) {
dates[groupDate.format('YYYY-MM-DD')] = groupDate;
}
Expand All @@ -1297,6 +1299,10 @@ function getPlanningByDate(
return sortBasedOnTBC(days);
}

function getPlanningDate(planning: IPlanningItem): moment.Moment {
return planning.all_day ? moment.utc(planning.planning_date) : moment(planning.planning_date);
}

function getFeaturedPlanningItemsForDate(items: Array<IPlanningItem>, date: moment.Moment): Array<IPlanningItem> {
const startDate = moment.tz(moment(date.format('YYYY-MM-DD')), appConfig.default_timezone);
const endDate = moment.tz(moment(date), appConfig.default_timezone).set({
Expand Down

0 comments on commit 42ab256

Please sign in to comment.