title: How to determine if now(utc) is within the range of the given days of the week and times of the day in ISO 8601 format
body: <p>I run into this question of how to determine if <code>DateTime.UtcNow</code> (e.g. 2018-01-01T20:00:00Z) falls within the given range of days and times that are in another timezone. There are no specific dates given, just the days of the week, and the time of the day. The given time is in ISO 8601 standard format. </p>
  
  <p>To simplify this question, it can be how to check if a UTC time is within business hours in China.</p>
  
  <p>For example, the given day and time range is given by someone form China in time zone +08:00, it can be: <code>FromDayOfWeek = "Friday", FromTimeOfDay = "17:00:00+8:00", ToDayOfWeek = "Monday", ToTimeOfWeek = "08:00:00+8:00".</code> I need to determine if "now" in China is sometime between the given range (Friday 17:00:00+8:00 - Monday 08:00:00+8:00).</p>
  
  <p>I'm stuck at how to convert the DateTime and get the day of the week in that local time, since 2018-01-01T20:00:00Z is Monday in UK, but at the same time, since China is +08:00, it is already Tuesday in China. </p>
  
  <p>My approach:</p>
  
  <pre><code>// parse the time to get the zone first (+08:00)
  TimeSpan ts = TimeSpan.Parse("-08:00");
  
  // Create a custom time zone since the time zone id is not given, and cannot be searched by SearchTimeZoneById
  TimeZoneInfo tzi = TimeZoneInfo.CreateCustomTimeZone(zoneId, ts, displayName, standardName);
  DateTime localDateTime = TimeZoneInfo.ConvertTime(Date.UtcNow, tzi);
  
  String localDay = localDateTime.DayOfWeek;
  
  // Determine if localDay is between FromDayOfWeek and ToDayOfWeek
  // cast the days to integers from 1 (Monday) to 7 (Sunday)  
  // create an array of days in integar days = [5, 6, 7, 1]
  // if days.contains(localDays), check the times
  ...
  </code></pre>
  
  <p>Can anyone suggest some better solutions? I am not sure if mine works, and there are holes in how to deal with Day Light Saving time, since the zone will change, and how to check the time range. I am new to C#, any suggestions of libraries I can use is great!</p>