public string timenotworkighours(string timezone) { // string timeinworkighours = null, timenotworkighours =null; IndexPersistence indexpersistence = new IndexPersistence(); string timezo = indexpersistence.timezones(timezone); var inTimeZone = TimeZoneInfo.FindSystemTimeZoneById(timezo); DateTime dttime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, inTimeZone); int time = dttime.Hour; if (time >= 8 && time < 18) { return(null); } else { return(timezone); } }
//change the time of the shipper local time public DateTime mtdtimezone(string timezone) { IndexPersistence indexpersistence = new IndexPersistence(); string timezo = indexpersistence.timezones(timezone); var inTimeZone = TimeZoneInfo.FindSystemTimeZoneById(timezo); DateTime dttime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, inTimeZone); //TimeZoneInfo infotime = TimeZoneInfo.FindSystemTimeZoneById(timezo); //DateTime thisDate = TimeZoneInfo.ConvertTimeToUtc(infotime); //var inTimeZone = TimeZoneInfo.FindSystemTimeZoneById(allvariables.timezones); //DateTime inTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, inTimeZone); //string time = inTime.ToString("HH:mm"); //TimeSpan TS = thisDate- inTime ; //int hour = TS.Hours; //int mins = TS.Minutes; //int secs = TS.Seconds; //DateTime dttime= dttimezone.Add(TS) ; //file.Close(); return(dttime); }