I am creating a form in which the user can specify the start and end times using the given values. I would like to generate a list of string representations of the available 15 minute intervals between 9 AM and 5 PM in one day.
List<string> query = Enumerable.Range(0, 33).Select(i => DateTime.Today.AddHours(9).AddMinutes(i * 15).ToString()).ToList();
or
int i = -1; while(DateTime.Today.AddHours(9).AddMinutes(i * 15).Hour < 17) Console.WriteLine(DateTime.Today.AddHours(9).AddMinutes(15 * (++i)));
Then for the current day, if you save the values in the database.
DateTime has a .AddMinutes method. Start there. (DateTime.Now)
DateTime start = new DateTime(1900, 1, 1, 9, 0, 0); DateTime end = new DateTime(1900, 1, 1, 17, 0, 0); DateTime current = start; while (current <= end) { Console.WriteLine(current.ToString("HH:mm")); current = current.AddMinutes(15); }
- ;
for (var time = new DateTime(2000,1,1,9,0,0); time <= new DateTime(2000,1,1,17,0,0); time = time.AddMinutes(15)) { Console.WriteLine("{0:t}", time); }
Create an outer loop with a start date. Let this cycle use AddDays to add a day to it before the end date.
Create a loop inside this loop and start at 9AM and loop up to 5PM in 15 minute increments, using Silky to specify the DateTime.AddMinutes method. In 15 minute increments, you can add Time to the list of strings.
:)
Source: https://habr.com/ru/post/1715382/More articles:Printing gif using java on 4x6 paper - javaHow to hide flashes without disabling them - jqueryJavascript Line 1 Синтаксическая ошибка в IE - javascriptCreating a separate process from unit test - javaсамый легкий немодальный диалог с jQuery? - jqueryMPMoviePlayer - subview / overlay disappears after snooze / loop - iphoneURI not checked on W3C Markup Validator, identical direct input - htmlHow to debug vs 2008 C # express dll which is called by vb6 / vba application? - debuggingIs JDBC safe? - javaЕсть ли GUI, который я могу использовать для создания XML-документов на основе моей схемы? - user-interfaceAll Articles