You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would be useful to have an method to get next opening hours, e.g. GetNextOpeningHours()
Maybe with the option to choose whether it should take today into account - maybe with the change of #15
For now I do like this:
var nextDays = openingHours.GetUpcomingDays(7);
var nextDayOpen = nextDays.Where(x => x.IsOpen && !x.IsToday).FirstOrDefault();
<p>We are opening again on @nextDayOpen.WeekDayName at @nextDayOpen.Items[0].Opens.ToString(@"HH\:mm")</p>
The text was updated successfully, but these errors were encountered:
I found that I needed this functionality too. I did want it to take today into account. My version is a little longer because of that and some differences with the text that my version prints (today, tomorrow, or day of week). Anyway, here's the snippet incase it helps anyone.
foreach(OpeningHoursDay day in openingHours.GetUpcomingDays(7))
{
string dayText = "";
string timeText = "";
if(day.IsOpen){
dayText = day.WeekDayName;
if(day.IsToday){ dayText = "today"; }
else if(day.IsTomorrow){ dayText = "tomorrow"; }
foreach(OpeningHoursDayTimeSlot item in day.Items)
{
if(item.Opens < DateTime.Now){ continue; }
// Dump minutes if they equal "00", update format of am/pm to be lowercase include periods (AP style).
timeText = item.Opens.ToString("h:mm tt").ToLower().Replace(":00", "").Replace("m", ".m.");
}
}
// If timeText is empty we'll just go to the next day. Otherwise print the result and break out of the foreach.
if(timeText != ""){
<p class="estimated">Re-opening @dayText at @timeText</p>
break;
}
}
I would be useful to have an method to get next opening hours, e.g.
GetNextOpeningHours()
Maybe with the option to choose whether it should take today into account - maybe with the change of #15
For now I do like this:
The text was updated successfully, but these errors were encountered: