gautamsi / ews-javascript-api

EWS API for TypeScript/JavaScript - ported from OfficeDev/ews-managed-api - node, cordova, meteor, Ionic, Electron, Outlook Add-Ins
MIT License
281 stars 72 forks source link

Appointment created by ews-javascript-api are shown in Monrovia timezone #435

Open tareqassi opened 5 months ago

tareqassi commented 5 months ago

On a nodejs app , I am using ews-javascript-api module to create appointments on exchange server (2013) . I've noticed the behavior that when an appointment is created , it is being shown correctly on the outlook calendar view but if I double click on the appointment and open the reply form of the appointment , the appointment's start/end times are shown on Monrovia time zone

Screenshot 2024-03-22 at 2 31 07 PM

I tried it with following code

const event = new ews.Appointment(service)
event.Subject = eventPayload.title
event.Start = new ews.DateTime(eventPayload.start.toString())
event.StartTimeZone =  ews.TimeZoneInfo.Local
event.End = new ews.DateTime(eventPayload.end.toString())
event.EndTimeZone =  ews.TimeZoneInfo.Local

and I also tried it without setting StartTimeZone/EndTimeZone but got the same issue. I am sending the start/end dates on the utc format and the goal is to show the created appointments on outlook same as the user's timezone

any idea how can I achieve this?

gautamsi commented 5 months ago

can you check this in outlook web instead of outlook client? also check what is the value you get for ews.TimeZoneInfo.Local on your server, this auto timezone detection is not very perfect

tareqassi commented 5 months ago

@gautamsi thanks for the quick reply Unfortunately, the issue is on a production server of a client where they have on-premise exchange server. I don't have access to outlook web there.

our nodejs app is on aws , I will add some logs on production and see what value for ews.TimeZoneInfo.Local and re-send it here . just to make sure that I understand , setting event.StartTimeZone = ews.TimeZoneInfo.Local will get the timezone of nodejs server (aws in our case ) and set it to be the timezone of the appointment ? if yes , then its not what I am looking for .

my goal to show the appointment on the same timezone as the user's timezone for example if I am sending "2024-06-04T10:30:00.000Z" as start date , it should appear for a user in Berlin as 11:30 (UTC+1)

On the testing environment, we are only provided with outlook web that is also hosted by the client and I don't see this issue on outlook web

Screenshot 2024-03-22 at 3 29 44 PM
gautamsi commented 5 months ago

you would want to find user timezone and use that timezone instead. if you use ews.TimeZoneInfo.Local it uses moment.tz.guess() which is not something in my control. You have to either set the timezone in code or get it for each user and construct the timezone based on that.