I'm trying to pass in DateTime StartTime = StartDateValue StartTimeNames[0],
How I do this?
StartDateValue is a type of DateTime and StartTimeNames is string type and array of times.
Any help is appreciated. Thanks!
var status = await OrderStatusService.GetOrderStatus(new OrderStatus()
{
StoreCode = s_code,
StartTime = DateTime.Now.StartOfTheDay(), //I want to replace this line with ( StartDateValue StartTimeNames[0] )
EndTime = DateTime.Now.EndOfTheDay()
});
public string[] StartTimeNames { get; set; }
private DateTime _StartDateValue;
public DateTime StartDateValue
{
get
{
return _StartDateValue;
}
set
{
var sdv = _StartDateValue;
Item.StartTime = value.Date Item.StartTime.TimeOfDay;
Item.EndTime = Item.StartTime.AddMinutes(Item.Duration);
SetProperty(ref _StartDateValue, value);
OnPropertyChanged(nameof(StartDateDisp));
if (sdv != value)
{
FilterStartTimeValues();
}
}
}
CodePudding user response:
You can try to convert the string the a int value which is the total minutes. Such as:
DateTime StartDateValue = DateTime.Now;
string a = "12H23M";
string[] strings = a.ToString().Split('H','M');
int num = int.Parse(strings[0])*60 int.Parse(strings[1]);
DateTime StartTime = StartDateValue.AddMinutes(num);