How to Define your Work Week in the Regional Settings using CSOM in SharePoint 2013 Online

Code Snippet: 
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Net;  
  5. using System.Security;  
  6. using System.Text;  
  7. using System.Threading.Tasks;  
  8. using Microsoft.SharePoint.Client;  
  9.   
  10. namespace CSOMOffice365  
  11. {  
  12.     class Program  
  13.     {  
  14.         static void Main(string[] args)  
  15.         {  
  16.   
  17.             string userName = "[email protected]";  
  18.   
  19.             Console.WriteLine("Enter your password.");  
  20.             SecureString password = GetPassword();  
  21.   
  22.             // ClienContext - Get the context for the SharePoint Online Site  
  23.             // SharePoint site URL - https://c986.sharepoint.com  
  24.   
  25.             using (var clientContext = new ClientContext("https://c986.sharepoint.com"))  
  26.             {  
  27.                 // SharePoint Online Credentials  
  28.                 clientContext.Credentials = new SharePointOnlineCredentials(userName, password);  
  29.   
  30.                 // Get the SharePoint web  
  31.                 Web web = clientContext.Web;  
  32.   
  33.                 // Regional Settings                  
  34.                 RegionalSettings regSet = web.RegionalSettings;  
  35.                 // Work days: https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.regionalsettings.workdays.aspx  
  36.                 // Convert the binary value to decimal: 0110110  - 54  
  37.                 regSet.WorkDays = 54;  
  38.                 // First Day of Week: https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.regionalsettings.firstdayofweek.aspx  
  39.                 regSet.FirstDayOfWeek = 1;  
  40.                 // First Week of Year: https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.regionalsettings.firstweekofyear.aspx  
  41.                 regSet.FirstWeekOfYear = 1;  
  42.                 // Work Day Start Hour - https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.regionalsettings.workdaystarthour.aspx  
  43.                 regSet.WorkDayStartHour = 540;  
  44.                 // Work Day End Hour - https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.regionalsettings.workdayendhour.aspx  
  45.                 regSet.WorkDayEndHour = 1020;  
  46.   
  47.                 // Update the regional Settings  
  48.                 regSet.Update();  
  49.   
  50.                 // Execute the query to the server  
  51.                 clientContext.ExecuteQuery();  
  52.             }  
  53.         }  
  54.   
  55.         private static SecureString GetPassword()  
  56.         {  
  57.             ConsoleKeyInfo info;  
  58.   
  59.             //Get the user's password as a SecureString  
  60.             SecureString securePassword = new SecureString();  
  61.             do  
  62.             {  
  63.                 info = Console.ReadKey(true);  
  64.                 if (info.Key != ConsoleKey.Enter)  
  65.                 {  
  66.                     securePassword.AppendChar(info.KeyChar);  
  67.                 }  
  68.             }  
  69.             while (info.Key != ConsoleKey.Enter);  
  70.             return securePassword;  
  71.         }  
  72.     }  
  73. }   
Output