Skip to content

Commit 001002d

Browse files
Fixing calendar time definition for calendars
1 parent 08af081 commit 001002d

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/app/services/calendar.service.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { Injectable, signal } from '@angular/core';
22
import { DateTime } from 'luxon';
3-
import { Observable, map, switchMap, of, from } from 'rxjs';
43
import { CalendarEvent, CalendarProject, CalendarRecurrenceType } from 'ngx-calendar-view';
4+
import { Observable, from, map, of, switchMap } from 'rxjs';
55

6-
import { TaskDto } from '../dto/task-dto';
6+
import { CALENDAR_CONFIG } from '../calendar.config';
77
import { ProjectDto } from '../dto/project-dto';
8-
import { TaskService } from '../task/task.service';
8+
import { TaskDto } from '../dto/task-dto';
99
import { ProjectService } from '../project/project.service';
10-
import { CALENDAR_CONFIG } from '../calendar.config';
10+
import { TaskService } from '../task/task.service';
1111

1212
@Injectable({
1313
providedIn: 'root'
@@ -47,19 +47,25 @@ export class CalendarService {
4747
return tasks
4848
.filter(task => !task.completed && task.dueDate) // Only incomplete tasks with dates
4949
.map(task => {
50+
const eventDate = DateTime.fromJSDate(task.dueDate!);
5051
const calendarEvent: CalendarEvent = {
5152
id: task.uuid,
5253
title: task.title,
5354
description: task.description || undefined,
54-
date: DateTime.fromJSDate(task.dueDate!),
55+
date: eventDate,
5556
duration: CALENDAR_CONFIG.defaultDuration,
5657
project: this.getProjectName(task),
5758
recurrenceType: this.mapRecurrenceType(task.recurring)
5859
};
5960

6061
// Set time if available, otherwise it's an all-day event
6162
if (task.dueTime) {
62-
calendarEvent.time = DateTime.fromJSDate(task.dueTime);
63+
const eventTime = DateTime.fromJSDate(task.dueTime);
64+
calendarEvent.time = eventTime.set({
65+
year: eventDate.year,
66+
month: eventDate.month,
67+
day: eventDate.day,
68+
});
6369
}
6470

6571
return calendarEvent;

0 commit comments

Comments
 (0)