cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1838
Views
2
Helpful
2
Replies

TMS Api Recurrence - Wrong days of week?

kabrahams
Level 1
Level 1

Hi All,

I'm having an issue with the API.

I booked a weekly recurring conference that occurs are monday, wednesday and friday that goes from 10:00 PM to 10:30 PM.  (# of recurrences = 5 and Recur every 3 week).

When I call the GetConferenceByID the Conference.ReccurencePattern.DayOfWeek returns Tuesday, Thursday, Saturday.

I'm using the same user in both instances so there should be no time zone conversions.  I see in the database the reccurenceDayofWeekList is 1,3,5 . . . so not sure what's changing this over.

Any suggestions?

Thanks in advanced.

1 Accepted Solution

Accepted Solutions

kabrahams
Level 1
Level 1

For anyone else coming across this:

After thinking about this a little more and going back and reading the API docs the issue was indeed the timezone.

The API saves the daysofweek in UTC format, so those also need to be converted to the local timezone (I was assuming that the conversion would be done for you, but no timezone transformations are applied based on the usertimezone.).

The easiest way to do this is to take the delta between the 2 and then apply it.

EG:

   For reading:

 

//utc to local  - start is the converted local time.

int WeekDayDelta = (int)start.DayOfWeek - (int)DateTime.Parse(c.StartTimeUTC.Trim('Z'

)).DayOfWeek;

//The Local Day Of week . . . d being a dayofweek c.DaysOfWeek -- +7 in case of negative numbers.

// eg: Sunday(0) start day - 1 =  Saturday (6)

(TMSBooking.DayOfWeek)((((int)d + WeekDayDelta) +7) % 7))

   For Writing back to the DB:

//local to utc. c is the conference, dt is the start time of the conference locally.

int WeekDayDelta = (int)DateTime.Parse(c.StartTimeUTC.Trim('Z')).DayOfWeek - (int

)dt.DayOfWeek;

//The UTC Day Of week  d being a DayOfWeek in c.DaysOfWeek -- +7 in case of negatives. 

// eg: Sunday(0) start day - 1 =  Saturday (6)

(Booking.DayOfWeek)((((int)d+ WeekDayDelta) + 7) %7)

View solution in original post

2 Replies 2

kabrahams
Level 1
Level 1

For anyone else coming across this:

After thinking about this a little more and going back and reading the API docs the issue was indeed the timezone.

The API saves the daysofweek in UTC format, so those also need to be converted to the local timezone (I was assuming that the conversion would be done for you, but no timezone transformations are applied based on the usertimezone.).

The easiest way to do this is to take the delta between the 2 and then apply it.

EG:

   For reading:

 

//utc to local  - start is the converted local time.

int WeekDayDelta = (int)start.DayOfWeek - (int)DateTime.Parse(c.StartTimeUTC.Trim('Z'

)).DayOfWeek;

//The Local Day Of week . . . d being a dayofweek c.DaysOfWeek -- +7 in case of negative numbers.

// eg: Sunday(0) start day - 1 =  Saturday (6)

(TMSBooking.DayOfWeek)((((int)d + WeekDayDelta) +7) % 7))

   For Writing back to the DB:

//local to utc. c is the conference, dt is the start time of the conference locally.

int WeekDayDelta = (int)DateTime.Parse(c.StartTimeUTC.Trim('Z')).DayOfWeek - (int

)dt.DayOfWeek;

//The UTC Day Of week  d being a DayOfWeek in c.DaysOfWeek -- +7 in case of negatives. 

// eg: Sunday(0) start day - 1 =  Saturday (6)

(Booking.DayOfWeek)((((int)d+ WeekDayDelta) + 7) %7)

is this for all recurrence types?  Monthly and Weekly?

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: