OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
use the current users timezone in calendar
Klaus Zanders277fcff8ee6f
diff --git a/frontend/src/stimulus/controllers/dynamic/my/time-tracking.controller.ts b/frontend/src/stimulus/controllers/dynamic/my/time-tracking.controller.tsindex f695d3784f4..728e0c849f1 100644--- a/frontend/src/stimulus/controllers/dynamic/my/time-tracking.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/my/time-tracking.controller.ts@@ -3,6 +3,8 @@ import { Calendar } from '@fullcalendar/core';import timeGridPlugin from '@fullcalendar/timegrid';import dayGridPlugin from '@fullcalendar/daygrid';import interactionPlugin from '@fullcalendar/interaction';+import momentTimezonePlugin from '@fullcalendar/moment-timezone';+import { toMoment } from '@fullcalendar/moment';import { TurboRequestsService } from 'core-app/core/turbo/turbo-requests.service';import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';import moment from 'moment';@@ -27,6 +29,7 @@ export default class MyTimeTrackingController extends Controller {forceTimes: Boolean,workingDays: Array,startOfWeek: Number,+ timeZone: String,};declare readonly calendarTarget:HTMLElement;@@ -42,6 +45,7 @@ export default class MyTimeTrackingController extends Controller {declare readonly viewModeValue:string;declare readonly workingDaysValue:number[];declare readonly startOfWeekValue:number;+ declare readonly timeZoneValue:string;private calendar:Calendar;private DEFAULT_TIMED_EVENT_DURATION = '01:00';@@ -71,10 +75,11 @@ export default class MyTimeTrackingController extends Controller {initializeCalendar() {this.calendar = new Calendar(this.calendarTarget, {- plugins: [timeGridPlugin, dayGridPlugin, interactionPlugin],+ plugins: [timeGridPlugin, dayGridPlugin, interactionPlugin, momentTimezonePlugin],initialView: this.calendarView(),locales: allLocales,locale: this.localeValue,+ timeZone: this.timeZoneValue,events: this.timeEntriesValue,headerToolbar: false,height: '100%',@@ -104,7 +109,7 @@ export default class MyTimeTrackingController extends Controller {let timeDetails = '';if (!arg.event.allDay) {- const time = `${moment(arg.event.start).format('LT')} - ${moment(arg.event.end).format('LT')}`;+ const time = `${toMoment(arg.event.start!, this.calendar).format('LT')} - ${toMoment(arg.event.end!, this.calendar).format('LT')}`;timeDetails = `<div class="color-fg-muted mt-2" title="${time}">${time}</div>`;}@@ -142,13 +147,13 @@ export default class MyTimeTrackingController extends Controller {// it does not make sense to resize the events without start & end times// we cannot only disable resize, because we want to be able to drag the events// so we need to revert the event to its original size- if (info.event.allDay) {+ if (info.event.allDay || !info.event.start || !info.event.end) {info.revert();return;}- const startMoment = moment(info.event.startStr);- const endMoment = moment(info.event.endStr);+ const startMoment = toMoment(info.event.start, this.calendar);+ const endMoment = toMoment(info.event.end, this.calendar);const newEventHours = moment.duration(endMoment.diff(startMoment)).asHours();@@ -184,7 +189,7 @@ export default class MyTimeTrackingController extends Controller {},eventDrop: (info) => {- const startMoment = moment(info.event.startStr);+ const startMoment = toMoment(info.event.start!, this.calendar);this.updateTimeEntry(info.event.id,@@ -252,7 +257,7 @@ export default class MyTimeTrackingController extends Controller {if (!eventStart) return;// Format event date for comparison- const eventDateStr = moment(eventStart).format('YYYY-MM-DD');+ const eventDateStr = toMoment(eventStart, this.calendar).format('YYYY-MM-DD');if (eventDateStr === dayStr && event.extendedProps && event.extendedProps.hours) {totalHours += event.extendedProps.hours as number;diff --git a/modules/costs/app/components/my/time_tracking/calendar_component.rb b/modules/costs/app/components/my/time_tracking/calendar_component.rbindex c238905eccf..baa23ed0745 100644--- a/modules/costs/app/components/my/time_tracking/calendar_component.rb+++ b/modules/costs/app/components/my/time_tracking/calendar_component.rb@@ -54,7 +54,8 @@ module My"my--time-tracking-force-times-value" => TimeEntry.must_track_start_and_end_time?,"my--time-tracking-locale-value" => I18n.locale,"my--time-tracking-start-of-week-value" => Setting.start_of_week,- "my--time-tracking-working-days-value" => working_days+ "my--time-tracking-working-days-value" => working_days,+ "my--time-tracking-time-zone-value" => User.current.time_zone.name}end