Exercise: International Meeting Scheduler

Implement a utility to calculate localized meeting times for global offices using DateTimeOffset and TimeZoneInfo.

Problem statement

A CEO based in London is scheduling a global all-hands meeting. The meeting is set for a specific absolute moment in time. You need to build a utility method that calculates the exact local clock time for any regional office when provided with their specific time zone identifier.

Task requirements

  • Implement the GetLocalMeetingTime method in the MeetingScheduler class within the Corporate namespace.

  • Load the time zone rules using the provided timeZoneId parameter.

  • Calculate and return the equivalent local time for that specific time zone.

Constraints

  • Use TimeZoneInfo.FindSystemTimeZoneById to load the time zone rules dynamically based on the passed string.

  • Use TimeZoneInfo.ConvertTime to convert the UTC meeting time into the localized regional DateTimeOffset.

  • Return the localized DateTimeOffset from the utility method.

Good luck trying the exercise! If you’re unsure how to proceed, check the “Solution” tab above.

Get hints

  • The TimeZoneInfo.FindSystemTimeZoneById method expects the exact timeZoneId string passed into your utility method.

  • The TimeZoneInfo.ConvertTime method requires the original DateTimeOffset and the target TimeZoneInfo object as arguments.

  • Ensure you return the newly calculated DateTimeOffset rather than the original UTC value.

Exercise: International Meeting Scheduler

Implement a utility to calculate localized meeting times for global offices using DateTimeOffset and TimeZoneInfo.

Problem statement

A CEO based in London is scheduling a global all-hands meeting. The meeting is set for a specific absolute moment in time. You need to build a utility method that calculates the exact local clock time for any regional office when provided with their specific time zone identifier.

Task requirements

  • Implement the GetLocalMeetingTime method in the MeetingScheduler class within the Corporate namespace.

  • Load the time zone rules using the provided timeZoneId parameter.

  • Calculate and return the equivalent local time for that specific time zone.

Constraints

  • Use TimeZoneInfo.FindSystemTimeZoneById to load the time zone rules dynamically based on the passed string.

  • Use TimeZoneInfo.ConvertTime to convert the UTC meeting time into the localized regional DateTimeOffset.

  • Return the localized DateTimeOffset from the utility method.

Good luck trying the exercise! If you’re unsure how to proceed, check the “Solution” tab above.

Get hints

  • The TimeZoneInfo.FindSystemTimeZoneById method expects the exact timeZoneId string passed into your utility method.

  • The TimeZoneInfo.ConvertTime method requires the original DateTimeOffset and the target TimeZoneInfo object as arguments.

  • Ensure you return the newly calculated DateTimeOffset rather than the original UTC value.

C# 14.0
namespace Corporate;
public class MeetingScheduler
{
public static DateTimeOffset GetLocalMeetingTime(DateTimeOffset meetingUtc, string timeZoneId)
{
// 1. Load the time zone info using the provided timeZoneId
// 2. Convert the meeting time to the local time of that zone and return it
return DateTimeOffset.UtcNow;
}
}