在代码的其他部分,我试图对b]中解释的伪代码进行编码。 我如何获得
var openTime = DateTime.Parse(“ 11:00 AM”);第二天
所以我可以将其与DateTime.Now
进行比较如果当前时间不在营业时间:
业务将在(插入小时直到打开)小时和(插入分钟直到打开)分钟内打开。” a]如果现在是<11:00 AM b]如果现在是> 10:00 PM(直到第二天11:00 AM)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace testrundo1
{
class Program
{
static void Main(string[] args)
{
var openTime = DateTime.Parse("11:00 AM");
var closeTime = DateTime.Parse("10:00 PM");
var lunchTime = DateTime.Parse("3:00 PM");
Console.WriteLine(DateTime.Now);
Console.WriteLine(openTime);
if (openTime < DateTime.Now && DateTime.Now < lunchTime)
Console.WriteLine("Lunch time!");
else if
(DateTime.Now > lunchTime && DateTime.Now < closeTime)
Console.WriteLine("Dinner time!");
else
Console.WriteLine("Bummer");
Console.ReadLine();
}
}
}
Business will open in (insert hour until opens) hour and (insert minutes until opens) minutes.
a] If now is < 11:00 AM
b] if now is > 10:00 PM (till next day 11:00 AM)